Skip to main content

loki-client

A Python client interacting with Grafana Loki.

Quickstart

Install:

pip install loki-client

Usage:

# example.py
from loki_client import LokiClient
from loki_client import SUPPORTED_DIRECTION


loki_url = 'http://localhost:3100'
loki_client = LokiClient(url=loki_url, disable_ssl=True)

# 1 test ready()
loki_ready = loki_client.ready()
if not loki_ready:
    print('Loki is not ready.')
    exit(1)

# 2 test query_range_with_context()
query = r'{host="ubuntu"}|~"error"'
result = loki_client.query_range_with_context(query=query, context_before=5, context_after=3)
if result[0]:
    print(result)

# 3 test post()
label_dic = {'host': 'windows', 'env': 'test'}
logs_lst = ['This is line 1', 'This is line 2', 'This is line 3', 'This is line 4']
result = loki_client.post(label_dic, logs_lst)
if not result[0]:
    print(result[1])

# 4 test labels()
result = loki_client.labels()
print(result)

# 5 test query_range()
query = r'{host="ubuntu"}|~"error"'
result = loki_client.query_range(query, direction=SUPPORTED_DIRECTION[1], limit=10)
print(result)

if result[0]:
    print(result[1]['status'])
    print(result[1]['data']['resultType'])

# 6 test query()
result = loki_client.query(query, direction=SUPPORTED_DIRECTION[1], limit=10)
print(result)

Metadata

Release files for loki-client 0.0.2

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-client 0.0.2
File Size Uploaded Provenance Actions
loki-client-0.0.2.tar.gz 2.3 kB Without provenance Details for loki-client-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for loki-client 0.0.2
File Interpreter ABI Platform Actions
loki_client-0.0.2-py3-none-any.whl Python 3 none any Details for loki_client-0.0.2-py3-none-any.whl

Total release size: 4.8 kB

Release files / loki-client-0.0.2.tar.gz

Download URL loki-client-0.0.2.tar.gz
Size 2.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6178e74ad7b874994c813210511f8d4dec92068d1cbe8176c78a2f92d648d298
BLAKE2b-256 checksum
How to use checksums
4bd66a797f1fa8145f077234f6ea5053f69795200bfee2d5b42875f620c3da54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.0

Release files / loki_client-0.0.2-py3-none-any.whl

Download URL loki_client-0.0.2-py3-none-any.whl
Size 2.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bba04d4dd9049f49759185d1ef5e43355d1e084021ff6f018b36f7be184d947d
BLAKE2b-256 checksum
How to use checksums
2802805ca5a3ef9d40169630488b94dbe4627aada4ec374fd887e68ab69b106c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.0

Security for loki-client 0.0.2

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.0.2 This release

2 release files 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