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] labels information
cli for pushing to loki
positional arguments:
labels json-encoded string with labels
information json-encoded string with information
options:
-h, --help show this help message and exit
-b BASE_ENDPOINT base address of 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
push
method will never throw. Any exception will just be logged usinglogging
. - Keys in labels and information must be strings.
- Values in labels and information must be string, integers or floats.
- If no
base_endpoint
provided (using parameter or env), nothing will happen.
Configuration
SMOLOKI_BASE_ENDPOINT
– base address of loki server.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.12.tar.gz
(4.5 kB
view details)
Built Distributions
smoloki-0.0.12-py3.10.egg
(7.6 kB
view details)
File details
Details for the file smoloki-0.0.12.tar.gz
.
File metadata
- Download URL: smoloki-0.0.12.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 672075962fb660cf2223c426dfed13ff2b152886855371b65df132953cf7967d |
|
MD5 | 50f15cf6ea346f7586ede193afb16b42 |
|
BLAKE2b-256 | 18e1d34f0105d48ce9d8564805a7a999b9a4b670ae5d82948b0d1c8563167077 |
File details
Details for the file smoloki-0.0.12-py3.10.egg
.
File metadata
- Download URL: smoloki-0.0.12-py3.10.egg
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbdf57c6f36e5ca7b0f1ea5714c7c73633cf5fcbf4b75267764e856124a896f4 |
|
MD5 | 81b773786fa185764be709590db12c0c |
|
BLAKE2b-256 | e52591baf7c2d4283ddfb2fed0da105f3799471376f0bcec885d7c3bbdfb6bfc |
File details
Details for the file smoloki-0.0.12-py3-none-any.whl
.
File metadata
- Download URL: smoloki-0.0.12-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8682d9748ea8a1fe45c11c8d818e1d3727dc684892447b2d8c464900289a0fec |
|
MD5 | 043b1f43010a51e5c49c6f67ca98a327 |
|
BLAKE2b-256 | 6a1cf5d93f948b2ae6027ce73ba463d02510ae3e6b2ebf9a0556ba8ef2b960e3 |