Metadata-Version: 2.1
Name: logs-prometheus
Version: 0.1.1
Summary: logs-based prometheus metrics tool
Home-page: https://gitlab.com/rocshers/python/logs-prometheus
License: MIT
Author: Aleksei Marusich
Author-email: Aleksei.Marusich@rocshers.com
Requires-Python: >=3.8,<4
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Project-URL: Repository, https://gitlab.com/rocshers/python/logs-prometheus
Description-Content-Type: text/markdown

# Logging prometheus

Poetry plugin to set package version based on git tag.

[![PyPI](https://img.shields.io/pypi/v/logs-prometheus)](https://pypi.org/project/logs-prometheus/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/logs-prometheus)](https://pypi.org/project/logs-prometheus/)
[![GitLab last commit](https://img.shields.io/gitlab/last-commit/rocshers/python/logs-prometheus)](https://gitlab.com/rocshers/python/logs-prometheus)
[![Docs](https://img.shields.io/badge/docs-exist-blue)](https://rocshers.gitlab.io/python/logs-prometheus/)

[![Test coverage](https://codecov.io/gitlab/rocshers:python/logs-prometheus/graph/badge.svg?token=3C6SLDPHUC)](https://codecov.io/gitlab/rocshers:python/logs-prometheus)
[![Downloads](https://static.pepy.tech/badge/logs-prometheus)](https://pepy.tech/project/logs-prometheus)
[![GitLab stars](https://img.shields.io/gitlab/stars/rocshers/python/logs-prometheus)](https://gitlab.com/rocshers/python/logs-prometheus)

## Functionality

- Logs **handler**, creating metrics
- Setup **labels**

## Quick start

install:

```bash
pip install logs-prometheus
```

usage:

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

```python
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:

```bash
make install-dev
```

After changes:

```bash
make format test
```

