logs-prometheus


Namelogs-prometheus JSON
Version 1.1.2 PyPI version JSON
download
home_pagehttps://gitlab.com/rocshers/python/logs-prometheus
Summarylogs-based prometheus metrics tool
upload_time2024-03-24 10:54:57
maintainerNone
docs_urlNone
authorAleksei Marusich
requires_python<4,>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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**

![example](https://gitlab.com/rocshers/python/logs-prometheus/-/raw/main/docs/grafana_example.png)

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/rocshers/python/logs-prometheus",
    "name": "logs-prometheus",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Aleksei Marusich",
    "author_email": "Aleksei.Marusich@rocshers.com",
    "download_url": "https://files.pythonhosted.org/packages/fd/be/a70ec5b01e3cc5f33df25b21747e7b12be8280eaf8df3aa37da641577ff6/logs_prometheus-1.1.2.tar.gz",
    "platform": null,
    "description": "# Logging prometheus\n\nPoetry plugin to set package version based on git tag.\n\n[![PyPI](https://img.shields.io/pypi/v/logs-prometheus)](https://pypi.org/project/logs-prometheus/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/logs-prometheus)](https://pypi.org/project/logs-prometheus/)\n[![GitLab last commit](https://img.shields.io/gitlab/last-commit/rocshers/python/logs-prometheus)](https://gitlab.com/rocshers/python/logs-prometheus)\n[![Docs](https://img.shields.io/badge/docs-exist-blue)](https://rocshers.gitlab.io/python/logs-prometheus/)\n\n[![Test coverage](https://codecov.io/gitlab/rocshers:python/logs-prometheus/graph/badge.svg?token=3C6SLDPHUC)](https://codecov.io/gitlab/rocshers:python/logs-prometheus)\n[![Downloads](https://static.pepy.tech/badge/logs-prometheus)](https://pepy.tech/project/logs-prometheus)\n[![GitLab stars](https://img.shields.io/gitlab/stars/rocshers/python/logs-prometheus)](https://gitlab.com/rocshers/python/logs-prometheus)\n\n## Functionality\n\n- Logs **handler**, creating metrics\n- Setup **labels**\n\n![example](https://gitlab.com/rocshers/python/logs-prometheus/-/raw/main/docs/grafana_example.png)\n\n## Quick start\n\ninstall:\n\n```bash\npip install logs-prometheus\n```\n\nusage:\n\n```python\nimport logging\n\nfrom logging_prometheus.handlers import PrometheusHandler\n\nlogger = logging.getLogger()\nlogger.addHandler(PrometheusHandler('python_logging_', ['name', 'levelname', 'module']))\n# or\n# from logging_prometheus import setup_prometheus_handler_for_root\n# setup_prometheus_handler_for_root()\n\nlogger = logging.getLogger('app')\n\nlogger.debug('debug')\nlogger.info('info')\nlogger.warning('warning')\nlogger.error('error')\n```\n\n## Django setup\n\n```python\nLOGGING = {\n    ...\n    \"handlers\": {\n        \"prometheus\": {\n            \"class\": \"logging_prometheus.PrometheusHandler\",\n            \"prefix\": \"python_logging_\",\n            \"labels\": [\"name\", \"levelname\", \"module\"],\n        },\n        ...\n    },\n    \"loggers\": {\n        \"django\": {\n            \"handlers\": [\"prometheus\", ...],\n            \"level\": \"DEBUG\",\n            \"propagate\": True,\n        },\n        ...\n    },\n    ...\n}\n```\n\n## Labels\n\nThe handler supports `all values` that are in the log object. more details: <https://docs.python.org/3/library/logging.html#logging.LogRecord>\n\n## Contribute\n\nIssue Tracker: <https://gitlab.com/rocshers/python/logs-prometheus/-/issues>  \nSource Code: <https://gitlab.com/rocshers/python/logs-prometheus>\n\nBefore adding changes:\n\n```bash\nmake install-dev\n```\n\nAfter changes:\n\n```bash\nmake format test\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "logs-based prometheus metrics tool",
    "version": "1.1.2",
    "project_urls": {
        "Homepage": "https://gitlab.com/rocshers/python/logs-prometheus",
        "Repository": "https://gitlab.com/rocshers/python/logs-prometheus"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1ebd1fb344ddb71e5b6ea414b7606231d2d2e5f79adc59ea63779073a92aa3dd",
                "md5": "a207930827065ba3cffe95d117861095",
                "sha256": "49b563bc3b71e64db6e376612946c94fa67129cf46a82df561e16d35d65a5529"
            },
            "downloads": -1,
            "filename": "logs_prometheus-1.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a207930827065ba3cffe95d117861095",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.8",
            "size": 4067,
            "upload_time": "2024-03-24T10:54:56",
            "upload_time_iso_8601": "2024-03-24T10:54:56.281876Z",
            "url": "https://files.pythonhosted.org/packages/1e/bd/1fb344ddb71e5b6ea414b7606231d2d2e5f79adc59ea63779073a92aa3dd/logs_prometheus-1.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fdbea70ec5b01e3cc5f33df25b21747e7b12be8280eaf8df3aa37da641577ff6",
                "md5": "5986f4abdc7923de57920eb7693c808f",
                "sha256": "ea1207af9ebd1eb8934075fc446b593dc693f1f6ae0470456d65fab978dfc52a"
            },
            "downloads": -1,
            "filename": "logs_prometheus-1.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "5986f4abdc7923de57920eb7693c808f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.8",
            "size": 3666,
            "upload_time": "2024-03-24T10:54:57",
            "upload_time_iso_8601": "2024-03-24T10:54:57.907466Z",
            "url": "https://files.pythonhosted.org/packages/fd/be/a70ec5b01e3cc5f33df25b21747e7b12be8280eaf8df3aa37da641577ff6/logs_prometheus-1.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-24 10:54:57",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "rocshers",
    "gitlab_project": "python",
    "lcname": "logs-prometheus"
}
        
Elapsed time: 0.29411s