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
    # First create ESStructLogExtension instance.
    es_extension = ESStructLogExtension(
        host="http://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"),
            elastic_structlog.elastic_processor.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="http://HOST:PORT",
    basic_auth=("USER_NAME", "PASSWORD"),
    index="INDEX_EXAMPLE",
    flush_frequency=5,
    verify_certs=False,
)

SDI Team - Nuriel Gadilov - 1.19.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.0.6.tar.gz (7.4 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.0.6-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: elastic_structlog-0.0.6.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.6

File hashes

Hashes for elastic_structlog-0.0.6.tar.gz
Algorithm Hash digest
SHA256 89537c81bd1e9f20d1c989ea82db239041b44f175fd2e58b00fdfd73abf8db8c
MD5 90cb3d0e52e69c3c42e1ad95dd95667f
BLAKE2b-256 ff6bd10efe88f5b40f76076445bfa68545b0362d1a3b80d8c7f89d0aeaebc1f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for elastic_structlog-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f707307a026bca5c8b690d1b2a4338091ed05e22c80cb409ddb706da5c589897
MD5 ed66e1f0fdd83b2cd4791c32b18a408c
BLAKE2b-256 bd106a54d9ef2356c412d329cefdc46d5591abed773a0df932128fa1479ab88d

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