Loki Assistant
The Loki Assistant has been created to send log messages to the LOKI server. The labels can be specified individually.
Install
You can install this package with pip tool from https://pypi.org/.
pip install loki-assistant
Usage
There are three ways to send messages to the server.
Each message individually
Sending every single message takes a lot of time. 6000 messages takes 3.67 s to send.
from datetime import datetime
from loki_assistant import LokiAssistant
loki = LokiAssistant('http://localhost:3100/loki/api/v1/push', primary_tags={"application": "test"})
loki.post(loki.LogLevels.VERBOSE, {"thread": "1"}, datetime.now(), f"messsage: DEBUG")
loki.post(loki.LogLevels.DEBUG, {"thread": "1"}, datetime.now(), f"message: DEBUG")
loki.post(loki.LogLevels.INFO, {"thread": "1"}, datetime.now(), f"message: INFO")
loki.post(loki.LogLevels.WARNING, {"thread": "1"}, datetime.now(), f"message: WARNING")
loki.post(loki.LogLevels.ERROR, {"thread": "1"}, datetime.now(), f"message: ERROR")
loki.post(loki.LogLevels.FATAL, {"thread": "1"}, datetime.now(), f"message: FATAL")
Collect messages
If several messages are sent together, a lot of time can be saved and the performance can be increased. Sending 60000 messages takes 0.660 s.
Push all together
from datetime import datetime
from loki_assistant import LokiAssistant
loki = LokiAssistant('http://localhost:3100/loki/api/v1/push', primary_tags={"application": "test"})
loki.commit(loki.LogLevels.VERBOSE, {"thread": "1"}, datetime.now(), f"messsage: DEBUG")
loki.commit(loki.LogLevels.DEBUG, {"thread": "1"}, datetime.now(), f"message: DEBUG")
loki.commit(loki.LogLevels.INFO, {"thread": "1"}, datetime.now(), f"message: INFO")
loki.commit(loki.LogLevels.WARNING, {"thread": "1"}, datetime.now(), f"message: WARNING")
loki.commit(loki.LogLevels.ERROR, {"thread": "1"}, datetime.now(), f"message: ERROR")
loki.commit(loki.LogLevels.FATAL, {"thread": "1"}, datetime.now(), f"message: FATAL")
loki.push()
Push them over a time interval.
from datetime import datetime
from loki_assistant import LokiAssistant
loki = LokiAssistant('http://localhost:3100/loki/api/v1/push', primary_tags={"application": "test"}, push_interval=1)
loki.commit(loki.LogLevels.VERBOSE, {"thread": "1"}, datetime.now(), f"messsage: DEBUG")
loki.commit(loki.LogLevels.DEBUG, {"thread": "1"}, datetime.now(), f"message: DEBUG")
loki.commit(loki.LogLevels.INFO, {"thread": "1"}, datetime.now(), f"message: INFO")
loki.commit(loki.LogLevels.WARNING, {"thread": "1"}, datetime.now(), f"message: WARNING")
loki.commit(loki.LogLevels.ERROR, {"thread": "1"}, datetime.now(), f"message: ERROR")
loki.commit(loki.LogLevels.FATAL, {"thread": "1"}, datetime.now(), f"message: FATAL")
Metadata
Release files for loki-assistant 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| loki-assistant-0.0.2.tar.gz | 4.3 kB | Without provenance | Details for loki-assistant-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| loki_assistant-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for loki_assistant-0.0.2-py3-none-any.whl |
Total release size: 8.7 kB
Release files / loki-assistant-0.0.2.tar.gz
| Download URL | loki-assistant-0.0.2.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec4824f26ef2f0c970e3d273fbca2dd96fdaaeed38d3a340406687a24b20f506
|
|
BLAKE2b-256 checksum How to use checksums |
6763e305207dc175e978a03a9badc9ddb700ee54efb2ede1bc96385d5de25031
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / loki_assistant-0.0.2-py3-none-any.whl
| Download URL | loki_assistant-0.0.2-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5b1f3ad680a86e3685cc62b86c43e70eb79cdf107ab76a7393c9b56e4597caf9
|
|
BLAKE2b-256 checksum How to use checksums |
f958b72b57fb4bc88caaa046b6393d758a414880851966414cce516ac68ada72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for loki-assistant 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.