Skip to main content

loki-handler

PyPI version License CircleCI

Python logging handler for Loki.
https://grafana.com/loki

Backport of Andrey Maslov's python-logging-loki for Python 2.X.

Installation

pip install loki-handler

Usage

import logging
import loki_handler


handler = loki_handler.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", 
    extra={"tags": {"service": "my-service"}},
)

Example above will send Something happened message along with these labels:

  • Default labels from handler
  • Message level as serverity
  • Logger's name as logger
  • Labels from tags item of extra dict

The given example is blocking (i.e. each call will wait for the message to be sent).

Metadata

Release files for loki-handler 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for loki-handler 0.1.1
File Size Uploaded Provenance Actions
loki-handler-0.1.1.tar.gz 6.2 kB Without provenance Details for loki-handler-0.1.1.tar.gz

Release files / loki-handler-0.1.1.tar.gz

Download URL loki-handler-0.1.1.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
69bb3a27bff49adcfb974494349060f9763bc9839ef19cc50eb77c3657d4b7cd
BLAKE2b-256 checksum
How to use checksums
93fad24eee108ddf340d44ec4b381d056b569bfefc92883e19f63f48b5eb11ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.7.0 requests/2.23.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/2.7.17

Security for loki-handler 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page