Skip to main content

Package for sending structlog-s to logzio

Project description

logzio-structlog-handler

Handler to send structlog logger to logzio

All logs have host, pid and tid added to them.

Example of log created with handler:

logger.info(
    "request_finished",
    request=f"{METHOD} {ENDPOINT}",
    code=response.status_code,
    request_id=uuid4()
)

Logzio:

  "_source": {
    "request": "GET /account/ping",
    "code": 200,
    "level": "info",
    "logger": "django_structlog.middlewares.request",
    "ip": "127.0.0.1",
    "log_level": "INFO",
    "pid": 1,
    "type": "http-bulk",
    "message": "request_finished FOR GET /account/ping",
    "tid": [
      140649178957632
    ],
    "tags": [
      "_logz_http_bulk_json_8070"
    ],
    "@timestamp": "2022-01-10T19:34:19.932Z",
    "line_number": 71,
    "host": "name-of-host",
    "event": "request_finished",
    "request_id": "3777349e-0247-4c89-ace2-ea2174930f39",
    "path_name": "path/to/file.py",
    "timestamp": "2022-01-10T19:34:19.931955Z",
    "random_tag_1": "some_value",
    "random_tag_2": 123
  }

Instructions:

  1. Install
 pip install logzio-structlog-handler
  1. Add the following handler to you LOGGING file:
LOGGING = {
    "handlers": {
        "logzio": {
            "class": "structlogzio.LogzIoStructlogHandler",
            "level": "INFO",
            "token": "YOUR_TOKEN",
            "logs_drain_timeout": 5,
            "url": "https://listener.logz.io:8071",
            "network_timeout": 10,
            # accepts any Dict[str, Any] value and passes it to all logs
            "tags": {"random_tag_1": "some_value", "random_tag_2": 123},
        }
    },
    "loggers": {
        "": {"level": "INFO", "handlers": ["logzio"], "propagate": True},
    },
}   

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

logzio-structlog-handler-0.1.1.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

logzio_structlog_handler-0.1.1-py3-none-any.whl (4.8 kB view hashes)

Uploaded Python 3

Supported by

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