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:
- Install
❯ pip install logzio-structlog-handler
- Add the following handler to you LOGGING file:
LOGGING = {
"handlers": {
"logzio": {
"class": "logzio-structlog-handler.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for logzio-structlog-handler-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98fcbf05a4d9f896611250ec4f165802a4ac4a0261da4f212b906092427ddaf2 |
|
MD5 | e7e0ee244ca0bae131a637f36e94b787 |
|
BLAKE2b-256 | ad6dfb4564bf52b275ba1a48e1e276beea68e6e7fda93ad6239315bb5642f85e |
Close
Hashes for logzio_structlog_handler-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f8b5c5e64e897184ede1917bfc1275391833638011e129a73116dffedb7b13e |
|
MD5 | 4e0f55efd7f9980531a0604b56241c1a |
|
BLAKE2b-256 | 302da332c3ce4df06312920c3272ae5ff824f60916aa13aab47a3067da828877 |