Skip to main content

loki-urllib3-client

A simple Python Loki client using urllib3

This is a modified version of loki-client

Quickstart

Install :

pip3 install loki-urllib3-client

Usage

from loki_urllib3_client import LokiClient

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

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

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

# 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])

# test query_range()
query = r'{host="ubuntu"}|~"error"'
result = loki_client.query_range(query, direction=LokiClient.Direction.backward, limit=10)
print(result)

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

# test query()
result = loki_client.query(query, direction=LokiClient.Direction.backward, limit=10)
print(result)

Metadata

Release files for loki-urllib3-client 0.2.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-urllib3-client 0.2.2
File Size Uploaded
loki_urllib3_client-0.2.2.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for loki-urllib3-client 0.2.2
File Interpreter ABI Platform
loki_urllib3_client-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 8.4 kB

Release files / loki_urllib3_client-0.2.2.tar.gz

Download URL loki_urllib3_client-0.2.2.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
88b3ba427139bbb35e29aabb2218cc161a958a78d8167a2c3292cced9843dbeb
BLAKE2b-256 checksum
How to use checksums
0fb105626d27b0bfa9de680457ee11114a95156aa2e062dc61c99a4efc9400c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.15

Release files / loki_urllib3_client-0.2.2-py3-none-any.whl

Download URL loki_urllib3_client-0.2.2-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
14085cc083efbe20c0ed4f94a55abef38261c552e38de7be447032cf3de0ebee
BLAKE2b-256 checksum
How to use checksums
0edaf7651403441ad63c2abbf20bd3895361e9b68e992edb28209638ac788f69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.15

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

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