--- id: python-logging-loki version: "0.3.1" license: MIT license_treatment: permissive maintenance: dormant --- # python-logging-loki — Python logging handler for Grafana Loki. License: permissive · Maintenance: dormant · Downloads: 1.1M/mo ## What it is and what it does python-logging-loki is a Python logging handler that integrates with Grafana Loki, a log aggregation system. It captures log records from Python's standard logging module and ships them to a Loki instance via HTTP POST requests, attaching custom labels to organize and filter logs. The handler supports basic authentication and can operate in blocking mode or asynchronously via Python's built-in QueueHandler and QueueListener to avoid blocking application threads. The package depends on requests for HTTP communication and rfc3339 for timestamp handling. It is designed for developers running Loki as their log backend who want to centralize Python application logs. The handler automatically includes message severity, logger name, and custom tags in each log entry sent to Loki. Use it for: - Centralize Python application logs into Grafana Loki for unified log aggregation and querying. - Send application error and warning logs to Loki with custom labels for service identification. - Integrate Python services with a Loki-based observability stack without external log shipping agents. - Asynchronously forward logs to Loki using QueueHandler to avoid blocking application performance. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A Python logging handler that sends log records to Grafana Loki via HTTP with support for custom labels and authentication. Yes, if you run Grafana Loki and need to ship Python logs to it. The package is straightforward, has low dependencies, and carries no known vulnerabilities. However, maintenance is dormant since 2019-11-28, so compatibility with recent Loki API changes or Python versions beyond 3.8 is unverified. For active projects, confirm the handler works with your Loki version before relying on it in production. ## Install pip install python-logging-loki uv add python-logging-loki poetry add python-logging-loki ## Installing python-logging-loki Before you install: Low install friction with only 2 runtime dependencies (rfc3339, requests). Maintenance is dormant—last release was 2019-11-28 and last commit 2024-05-14—but the repository remains unarchived with 171 stars. License in practice: MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions. Quickstart: pip install python-logging-loki import logging import python_logging_loki handler = python_logging_loki.LokiHandler( url="https://my-loki-instance/loki/api/v1/push", tags={"application": "my-app"}, auth=("username", "password"), version="1" ) logger = logging.getLogger("my-logger") logger.addHandler(handler) logger.error("Something happened") Requires a reachable Loki instance endpoint and network connectivity to push logs. Verify before relying: - Whether the package works with Python versions beyond 3.8, given classifiers list only up to 3.8. - Current compatibility with recent Loki API versions, given the gap since last release in 2019-11-28. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: dormant - Downloads: 1.1M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags loki logging handler, grafana loki python, send logs to loki, python logging aggregation, loki http log shipper, logging, loki, observability [View on SkillFed](https://skillfed.io/packages/python-logging-loki) · [View on PyPI](https://pypi.org/project/python-logging-loki/)