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
def as_request_completed():
smoloki.push_sync(
{'service': 'web'},
{'level': 'info', 'event': 'request_completed'},
)
Usage in Python via client
from smoloki import SmolokiAsyncClient
async def push_via_client():
async with SmolokiAsyncClient(
base_endpoint = 'https://example.com',
headers = {...}
) as client:
await client.push(
{'service': 'web'},
{'level': 'info', 'event': 'request_completed'},
)
# or push in background
await client.push_in_background(
{'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. - When using SmolokiAsyncClient, the context manager waits for all background tasks to be completed when exiting.
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.
Metadata
Release files for smoloki 0.1.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 |
|---|---|---|---|---|
| smoloki-0.1.2.tar.gz | 5.6 kB | Without provenance | Details for smoloki-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smoloki-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for smoloki-0.1.2-py3-none-any.whl |
Total release size: 11.0 kB
Release files / smoloki-0.1.2.tar.gz
| Download URL | smoloki-0.1.2.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
05831c57e603ab67c14b6e09ebd1c137e72bc28aae13494a3929e113662f1d0e
|
|
BLAKE2b-256 checksum How to use checksums |
d801c4f8386a1379e04413d8f8ef3563d6e5eefe46e438924de878ea795c78bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Release files / smoloki-0.1.2-py3-none-any.whl
| Download URL | smoloki-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8b4c2c1eb4be1d927671a1505ebb96434e5d7c5f9f7b617a0880d989825d845
|
|
BLAKE2b-256 checksum How to use checksums |
06ec9b5926e7a7645e6cae54d6b5432fd23f74bee21aeeb8a79e894ae13c90af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Security for smoloki 0.1.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.