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": "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
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
File details
Details for the file logzio-structlog-handler-0.1.1.tar.gz
.
File metadata
- Download URL: logzio-structlog-handler-0.1.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.8.10 Linux/5.4.0-92-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77b4cba51e4cdf85ede96fb02da697c79b22bfa77085eb564b9c081a575b16cb |
|
MD5 | 049bdbaf347d4a4958d822de687d283b |
|
BLAKE2b-256 | d88c5c36dd177b057ba251bd324360cf7db8c29fece00db6a069806d8d85dec7 |
File details
Details for the file logzio_structlog_handler-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: logzio_structlog_handler-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.8.10 Linux/5.4.0-92-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc5a287947f966e7564ae6495ef92be219e75ec8f312d376674d8b4d337033fc |
|
MD5 | 6754a5cb58f0ddc67e70504bb58441ef |
|
BLAKE2b-256 | 5946e61c853d5ed070bd9f604bdf2f0e10d005973276f668505a855313cb2aa9 |