Skip to main content

Extension / Wrapper for structlog library.

Project description

Elastic Structlog Extension - 'elastic_structlog'

elastic_structlog is python package that provides functionality in order to send logs to elastic directly. This package is an extension for the package 'structlog'. In order to use the library suggesting to read the official documentation of structlog

Installation

Use the package manager pip to install elastic_structlog.

pip install elastic_structlog

Usage

Configuration:

In order to configure the logger, the package provide two options:

Manual Confuguration:

from elastic_structlog import ESStructLogExtension, ESStructLogProcessor
import structlog
# First create ESStructLogExtension instance.
es_extension = ESStructLogExtension(
    host="https://HOST:PORT",
    basic_auth=("USER_NAME", "PASSWORD"),
    index="INDEX_EXAMPLE",
    flush_frequency=5,
    raise_on_indexing_error=False,
    verify_certs=True
)

# Second, configure the structlog - use directly the original module of structlog.
# Notice how you should use the processor that the package offers:
structlog.configure(
    processors=[
        structlog.contextvars.merge_contextvars,
        structlog.processors.format_exc_info,
        structlog.processors.TimeStamper(fmt="iso"),
        ESStructLogProcessor(es_extension=es_extension),
        structlog.processors.KeyValueRenderer()
    ]
)

Built-in 'configure_es_structlog_logger' function:

from elastic_structlog.elastic_processor import configure_es_structlog_logger

configure_es_structlog_logger(
    host="https://HOST:PORT",
    basic_auth=("USER_NAME", "PASSWORD"),
    index="INDEX_EXAMPLE",
    flush_frequency=5,
    verify_certs=False, #Default - True
    raise_on_indexing_error=True #Default - False
)

SDI Team - Nuriel Gadilov - 1.20.2025

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elastic_structlog-0.2.5.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

elastic_structlog-0.2.5-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file elastic_structlog-0.2.5.tar.gz.

File metadata

  • Download URL: elastic_structlog-0.2.5.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for elastic_structlog-0.2.5.tar.gz
Algorithm Hash digest
SHA256 d9dad72d9aae457f6ac841f88342259ac2b23d96c2bc9f309f578e1765482219
MD5 ba976fd7bad2bf7ba3c6042819f06f90
BLAKE2b-256 2de8eae0c74e2f2ee7d4b4de29924b9891b58a3a3b8750fe8e0ec652b80870a7

See more details on using hashes here.

File details

Details for the file elastic_structlog-0.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for elastic_structlog-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9c3ec56fd384ba44fea130e525a95a71e4e8172913d1af359a42f147a6a8963f
MD5 76bb28c717826992f25627ba97f21d83
BLAKE2b-256 9ef5442ff6571bf72653c6281f64287c2d59e71f28bd238804bbc05057b7be5f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page