Skip to main content

logs-based prometheus metrics tool

Project description

Logging prometheus

Poetry plugin to set package version based on git tag.

PyPI PyPI - Python Version GitLab last commit Docs

Test coverage Downloads GitLab stars

Functionality

  • Logs handler, creating metrics
  • Setup labels

example

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 details)

Uploaded Source

Built Distribution

logs_prometheus-1.1.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file logs_prometheus-1.1.2.tar.gz.

File metadata

  • Download URL: logs_prometheus-1.1.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.8.16 Linux/5.15.0-97-generic

File hashes

Hashes for logs_prometheus-1.1.2.tar.gz
Algorithm Hash digest
SHA256 ea1207af9ebd1eb8934075fc446b593dc693f1f6ae0470456d65fab978dfc52a
MD5 5986f4abdc7923de57920eb7693c808f
BLAKE2b-256 fdbea70ec5b01e3cc5f33df25b21747e7b12be8280eaf8df3aa37da641577ff6

See more details on using hashes here.

File details

Details for the file logs_prometheus-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: logs_prometheus-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.8.16 Linux/5.15.0-97-generic

File hashes

Hashes for logs_prometheus-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 49b563bc3b71e64db6e376612946c94fa67129cf46a82df561e16d35d65a5529
MD5 a207930827065ba3cffe95d117861095
BLAKE2b-256 1ebd1fb344ddb71e5b6ea414b7606231d2d2e5f79adc59ea63779073a92aa3dd

See more details on using hashes here.

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