A simple loki client using urllib3
Project description
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file loki_urllib3_client-0.2.2.tar.gz.
File metadata
- Download URL: loki_urllib3_client-0.2.2.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88b3ba427139bbb35e29aabb2218cc161a958a78d8167a2c3292cced9843dbeb
|
|
| MD5 |
025ac313d9061d7b47f9da5c228fad3a
|
|
| BLAKE2b-256 |
0fb105626d27b0bfa9de680457ee11114a95156aa2e062dc61c99a4efc9400c9
|
File details
Details for the file loki_urllib3_client-0.2.2-py3-none-any.whl.
File metadata
- Download URL: loki_urllib3_client-0.2.2-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14085cc083efbe20c0ed4f94a55abef38261c552e38de7be447032cf3de0ebee
|
|
| MD5 |
b0a951784256639e015789a17662da0e
|
|
| BLAKE2b-256 |
0edaf7651403441ad63c2abbf20bd3895361e9b68e992edb28209638ac788f69
|