Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

loki_urllib3_client-0.2.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

loki_urllib3_client-0.2.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

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

Hashes for loki_urllib3_client-0.2.2.tar.gz
Algorithm Hash digest
SHA256 88b3ba427139bbb35e29aabb2218cc161a958a78d8167a2c3292cced9843dbeb
MD5 025ac313d9061d7b47f9da5c228fad3a
BLAKE2b-256 0fb105626d27b0bfa9de680457ee11114a95156aa2e062dc61c99a4efc9400c9

See more details on using hashes here.

File details

Details for the file loki_urllib3_client-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for loki_urllib3_client-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 14085cc083efbe20c0ed4f94a55abef38261c552e38de7be447032cf3de0ebee
MD5 b0a951784256639e015789a17662da0e
BLAKE2b-256 0edaf7651403441ad63c2abbf20bd3895361e9b68e992edb28209638ac788f69

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page