python-elasticsearch-logging


Namepython-elasticsearch-logging JSON
Version 2.0.6 PyPI version JSON
download
home_pagehttps://github.com/ashokpant/python-elasticsearch-logging
SummaryMinimalistic Elasticsearch logging handler
upload_time2023-08-14 12:58:14
maintainer
docs_urlNone
authorBohdan Sydorov
requires_python>=3.7,<4
license
keywords elasticsearch logging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # 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](https://github.com/cmanaha/python-elasticsearch-logger).

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.

## 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
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ashokpant/python-elasticsearch-logging",
    "name": "python-elasticsearch-logging",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4",
    "maintainer_email": "",
    "keywords": "elasticsearch,logging",
    "author": "Bohdan Sydorov",
    "author_email": "",
    "download_url": "",
    "platform": null,
    "description": "# elasticsearch-logging-handler\n\nThis is a minimalistic Elasticsearch logging handler for python. This handler uses only url as an authentication method. For more robust authentication consider [CMRESHandler](https://github.com/cmanaha/python-elasticsearch-logger).\n\nPackage on PyPI - https://pypi.org/project/elasticsearch-logging-handler/\n\nParameters for **ElasticHandler**:\n| Name | Type | Required | Default | Description | Example | \n| --- | --- | --- | --- | --- | --- |\n| 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 |\n| index | str | True | - | Name of the Index to write in. | preprocessing-logs |\n| 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 |\n| 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 |\n| 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 |\n| timezone | str | False | None | Timezone for which to transform @timestamp for the record. | 'Europe/Amsterdam', 'Australia/Sydney' |\n\n**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.\n\n## Build\n``` \npoetry build -f wheel\n```\n\n## Uses\n logging.ini file\n``` \n[loggers]\nkeys = root\n\n[handlers]\nkeys = file, console, elasticsearch\n\n[formatters]\nkeys = default\n\n[logger_root]\nlevel = DEBUG\nhandlers = file, console, elasticsearch\n\n[handler_console]\nclass = StreamHandler\nlevel = DEBUG\nformatter = default\nargs = (sys.stdout,)\n\n[handler_file]\nclass = handlers.RotatingFileHandler\nlevel = DEBUG\nformatter = default\nargs = (\"service.log\",\"a\",10000000,10,\"utf-8\")\n;args = [filename,mode,maxBytes,backupCount,encoding}\n\n[handler_elasticsearch]\nclass = python_elasticsearch_logging.ElasticHandler\nargs = ('http://elastic:changeme@localhost:9200','pylogger')\nlevel = DEBUG\nformatter = default\n\n[formatter_default]\nformat = %(asctime)s - %(name)s-%(threadName)-10s-%(levelname)s - %(message)s\ndatefmt =\nclass = logging.Formatter\n```\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Minimalistic Elasticsearch logging handler",
    "version": "2.0.6",
    "project_urls": {
        "Homepage": "https://github.com/ashokpant/python-elasticsearch-logging",
        "Repository": "https://github.com/ashokpant/python-elasticsearch-logging"
    },
    "split_keywords": [
        "elasticsearch",
        "logging"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d01301dbb8d95311ab01940205110bf85ffdebf92c9482dd4fd55e5e4788dd4e",
                "md5": "6c91554faf9fdc1aaef4ee9b511dcae6",
                "sha256": "0f0f541606f9fde2a869749946287f01ba911c97469cbc4647e3e9fda66ae6fb"
            },
            "downloads": -1,
            "filename": "python_elasticsearch_logging-2.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6c91554faf9fdc1aaef4ee9b511dcae6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4",
            "size": 5853,
            "upload_time": "2023-08-14T12:58:14",
            "upload_time_iso_8601": "2023-08-14T12:58:14.227033Z",
            "url": "https://files.pythonhosted.org/packages/d0/13/01dbb8d95311ab01940205110bf85ffdebf92c9482dd4fd55e5e4788dd4e/python_elasticsearch_logging-2.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-14 12:58:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ashokpant",
    "github_project": "python-elasticsearch-logging",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": false,
    "lcname": "python-elasticsearch-logging"
}
        
Elapsed time: 0.13916s