elasticsearch-logging-handler
This is a minimalistic Elasticsearch logging handler for python. This handler uses only url as an authentication method. For more robust authentication consider CMRESHandler.
Package on PyPI - https://pypi.org/project/elasticsearch-logging-handler/
Parameters for ElasticHandler:
| Name | Type | Required | Default | Description | Example |
|---|---|---|---|---|---|
| host | str | True | - | Url for Elasticsearch cluster. Currently, this handler support only basic authentication through providing user and password in the url. | https://user:password@my-cluster.es:9200, https://my-cluster.es:9200 |
| index | str | True | - | Name of the Index to write in. | preprocessing-logs |
| level | int | False | 0 (NOTSET) | Minimal logging level for the handler. Handler will only process messages with level larger than this parameter. | 20, logging.WARNING |
| batch_size | int | False | 1000 | Size of the buffer that stores logs before sending to Elasticsearch. If buffer is full, send batch immediately, without waiting for the flush_period | 2000 - send batches of maximum size 2000 |
| flush_period | float | False | 1.0 | Period during which handler will accumulate logs into batch before sending it ot the cluster. | 10.0 - wait 10 seconds before sending |
| timezone | str | False | None | Timezone for which to transform @timestamp for the record. | 'Europe/Amsterdam', 'Australia/Sydney' |
ElasticHandler is nonblocking, meaning any logging call e.g. logging.exception will not block calling thread. which is useful in the case of high logging load.
Install
pip install python-elasticsearch-logging
Build
poetry build -f wheel
Uses
logging.ini file
[loggers]
keys = root
[handlers]
keys = file, console, elasticsearch
[formatters]
keys = default
[logger_root]
level = DEBUG
handlers = file, console, elasticsearch
[handler_console]
class = StreamHandler
level = DEBUG
formatter = default
args = (sys.stdout,)
[handler_file]
class = handlers.RotatingFileHandler
level = DEBUG
formatter = default
args = ("service.log","a",10000000,10,"utf-8")
;args = [filename,mode,maxBytes,backupCount,encoding}
[handler_elasticsearch]
class = python_elasticsearch_logging.ElasticHandler
args = ('http://elastic:changeme@localhost:9200','pylogger')
level = DEBUG
formatter = default
[formatter_default]
format = %(asctime)s - %(name)s-%(threadName)-10s-%(levelname)s - %(message)s
datefmt =
class = logging.Formatter
Metadata
Release files for python-elasticsearch-logging 2.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_elasticsearch_logging-2.0.8.tar.gz | 4.5 kB | Without provenance | Details for python_elasticsearch_logging-2.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_elasticsearch_logging-2.0.8-py3-none-any.whl | Python 3 | none | any | Details for python_elasticsearch_logging-2.0.8-py3-none-any.whl |
Total release size: 10.3 kB
Release files / python_elasticsearch_logging-2.0.8.tar.gz
| Download URL | python_elasticsearch_logging-2.0.8.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8cea5ec3007ed673336ef90d76d8623d39591266362e84e6495673877f11753c
|
|
BLAKE2b-256 checksum How to use checksums |
13b713c21f12ea8aa6a09baf0c6a55154089ac237991454aff609c818cf59fb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.13
|
Release files / python_elasticsearch_logging-2.0.8-py3-none-any.whl
| Download URL | python_elasticsearch_logging-2.0.8-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4045ce586d5a2fd31c2da35f553d5c4cfc086e859640fc173b769af0c8d9535c
|
|
BLAKE2b-256 checksum How to use checksums |
2d7d6ab3aa4953a675312fad8d82c529e8ef70a8515cb998fb782400796382d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.13
|
Security for python-elasticsearch-logging 2.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.