logs-prometheus 1.1.2

Creator: codyrutscher

Last updated:

Add to Cart

Description:

logsprometheus 1.1.2

Logging prometheus
Poetry plugin to set package version based on git tag.







Functionality

Logs handler, creating metrics
Setup labels


Quick start
install:
pip install logs-prometheus

usage:
import logging

from logging_prometheus.handlers import PrometheusHandler

logger = logging.getLogger()
logger.addHandler(PrometheusHandler('python_logging_', ['name', 'levelname', 'module']))
# or
# from logging_prometheus import setup_prometheus_handler_for_root
# setup_prometheus_handler_for_root()

logger = logging.getLogger('app')

logger.debug('debug')
logger.info('info')
logger.warning('warning')
logger.error('error')

Django setup
LOGGING = {
...
"handlers": {
"prometheus": {
"class": "logging_prometheus.PrometheusHandler",
"prefix": "python_logging_",
"labels": ["name", "levelname", "module"],
},
...
},
"loggers": {
"django": {
"handlers": ["prometheus", ...],
"level": "DEBUG",
"propagate": True,
},
...
},
...
}

Labels
The handler supports all values that are in the log object. more details: https://docs.python.org/3/library/logging.html#logging.LogRecord
Contribute
Issue Tracker: https://gitlab.com/rocshers/python/logs-prometheus/-/issues
Source Code: https://gitlab.com/rocshers/python/logs-prometheus
Before adding changes:
make install-dev

After changes:
make format test

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.