Skip to main content

Library for logging to Elastic Search.

Project description

elasticsearch-logger

Simple package for logging to Elasticsearch. Expected usage is to use this package inside your k8s cluster.

Installation

pip install elasticsearch_logger

Example of usage

In this example we write 3 messages (1-3) to buffer and after that write to Elasticsearch running on address 127.0.0. :9200 one-by-one (that should be changed to bulk write). Logger has 4 levels of severity (DEBUG, INFO, WARNING, ERROR) and writes messages in the following format: appName:default-app-name appName.keyword:default-app-name env:default-env-name env.keyword:default-env-name payload:Hi 3 severity:INFO severity.keyword:INFO timestamp:Jun 30, 2021 @ 18:46:54.620 _index:app-name-logs-default-app-name-30-06-2021 _score: - _type:doc.

from elasticsearch_logger import ElasticLogger
mh_logger = ElasticLogger(
    buffer_size=3,
    index='app-name-logs',
    app_name='app_name',
    env='dev',
    port=9200,
    ip_addr='127.0.0.1'
)

mh_logger.info('Hi! 1')
mh_logger.info('Hi! 2')
mh_logger.info('Hi! 3')
mh_logger.info('Hi! 4')

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

elasticsearch-logger-0.0.1.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

elasticsearch_logger-0.0.1-py3-none-any.whl (4.4 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