logs-based prometheus metrics tool
Project description
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
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
logs_prometheus-1.1.2.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for logs_prometheus-1.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49b563bc3b71e64db6e376612946c94fa67129cf46a82df561e16d35d65a5529 |
|
MD5 | a207930827065ba3cffe95d117861095 |
|
BLAKE2b-256 | 1ebd1fb344ddb71e5b6ea414b7606231d2d2e5f79adc59ea63779073a92aa3dd |