Tiny library to push logs to `Grafana Loki` in `logfmt` format.
Project description
smoloki
Tiny library to push logs to Grafana Loki in logfmt format.
CLI
usage: smoloki [-h] [-b BASE_ENDPOINT] [-H HEADERS] labels information
cli for pushing to loki
positional arguments:
labels json-encoded string with labels
information json-encoded string with information
optional arguments:
-h, --help show this help message and exit
-b BASE_ENDPOINT base address of loki server
-H HEADERS json-encoded string with headers for request to loki server
Usage in Python
import smoloki
async def as_request_completed():
await smoloki.push(
{'service': 'web'},
{'level': 'info', 'event': 'request_completed'},
)
def as_request_completed():
smoloki.push_sync(
{'service': 'web'},
{'level': 'info', 'event': 'request_completed'},
)
Usage in NodeJS
const smoloki = require('smoloki');
async function as_request_completed() {
await smoloki.push({ service: 'web' }, { level: 'info', event: 'request_completed' });
}
Implementation details
- Calls to
pushmethod will never throw. Any exception will just be logged usinglogging. - Keys in labels and information must be strings. If
Noneis provided as value in case of python, it will be serialized as empty string. - Values in labels and information must be string, integers or floats.
- If no
base_endpointprovided (using parameter or env), nothing will happen.
Configuration
SMOLOKI_BASE_ENDPOINT– base address of loki server.SMOLOKI_HEADERS- headers for request to loki server (can be used for authorization).SMOLOKI_BASE_LABELS- base labels that will be added to logs.SMOLOKI_BASE_INFORMATION- base information that will be added to logs.
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
smoloki-0.0.19.tar.gz
(4.7 kB
view details)
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 smoloki-0.0.19.tar.gz.
File metadata
- Download URL: smoloki-0.0.19.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82ac1951340fd0940711a87ddd3e18748791e16fffd3a3c2862273b38310de10
|
|
| MD5 |
63c622de1bd5327965622a5788cad73a
|
|
| BLAKE2b-256 |
81626f367d18ad4e646f3dfab7dae2fdbd8a17ad4ea03d69cf1a11acb9420b9c
|
File details
Details for the file smoloki-0.0.19-py3-none-any.whl.
File metadata
- Download URL: smoloki-0.0.19-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fca1e309160134e6f6e3243ddbf8a777c41035fbda7a22934bc6c0a7eeaebd9
|
|
| MD5 |
a0d8203ad61f1c71ea3e04d657c7749d
|
|
| BLAKE2b-256 |
153ce734fdecf91cf5cedab6637812535c4351f2d3421946c0a47f173f7e5843
|