smoloki


Namesmoloki JSON
Version 0.0.18 PyPI version JSON
download
home_pagehttps://github.com/michaelkryukov/smoloki
SummaryTiny library to push logs to `Grafana Loki` in `logfmt` format.
upload_time2024-12-17 12:00:18
maintainerNone
docs_urlNone
authorMichael Krukov
requires_python>=3.7
licenseNone
keywords library loki
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # smoloki

[![PyPI version](https://badge.fury.io/py/smoloki.svg)](https://badge.fury.io/py/smoloki)
[![npm version](https://badge.fury.io/js/smoloki.svg)](https://badge.fury.io/js/smoloki)

Tiny library to push logs to `Grafana Loki` in `logfmt` format.

## CLI

```text
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

```py
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

```js
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 using `logging`.
- Keys in labels and information must be strings. If `None` is 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_endpoint` provided (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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/michaelkryukov/smoloki",
    "name": "smoloki",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "library, loki",
    "author": "Michael Krukov",
    "author_email": "krukov.michael@ya.ru",
    "download_url": "https://files.pythonhosted.org/packages/a9/1e/9cde15ff8d13343198a49620b4bd349ac338d76f035ac73100e9f6b8d1f3/smoloki-0.0.18.tar.gz",
    "platform": null,
    "description": "# smoloki\n\n[![PyPI version](https://badge.fury.io/py/smoloki.svg)](https://badge.fury.io/py/smoloki)\n[![npm version](https://badge.fury.io/js/smoloki.svg)](https://badge.fury.io/js/smoloki)\n\nTiny library to push logs to `Grafana Loki` in `logfmt` format.\n\n## CLI\n\n```text\nusage: smoloki [-h] [-b BASE_ENDPOINT] [-H HEADERS] labels information\n\ncli for pushing to loki\n\npositional arguments:\n  labels            json-encoded string with labels\n  information       json-encoded string with information\n\noptional arguments:\n  -h, --help        show this help message and exit\n  -b BASE_ENDPOINT  base address of loki server\n  -H HEADERS        json-encoded string with headers for request to loki server\n```\n\n## Usage in Python\n\n```py\nimport smoloki\n\n\nasync def as_request_completed():\n    await smoloki.push(\n        {'service': 'web'},\n        {'level': 'info', 'event': 'request_completed'},\n    )\n\n\ndef as_request_completed():\n    smoloki.push_sync(\n        {'service': 'web'},\n        {'level': 'info', 'event': 'request_completed'},\n    )\n```\n\n## Usage in NodeJS\n\n```js\nconst smoloki = require('smoloki');\n\nasync function as_request_completed() {\n    await smoloki.push({ service: 'web' }, { level: 'info', event: 'request_completed' });\n}\n```\n\n## Implementation details\n\n- Calls to `push` method will never throw. Any exception will just be\n    logged using `logging`.\n- Keys in labels and information must be strings. If `None` is provided as\n    value in case of python, it will be serialized as empty string.\n- Values in labels and information must be string, integers or floats.\n- If no `base_endpoint` provided (using parameter or env), nothing will happen.\n\n## Configuration\n\n- `SMOLOKI_BASE_ENDPOINT` \u2013 base address of loki server.\n- `SMOLOKI_HEADERS` - headers for request to loki server (can be used for authorization).\n- `SMOLOKI_BASE_LABELS` - base labels that will be added to logs.\n- `SMOLOKI_BASE_INFORMATION` - base information that will be added to logs.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Tiny library to push logs to `Grafana Loki` in `logfmt` format.",
    "version": "0.0.18",
    "project_urls": {
        "Homepage": "https://github.com/michaelkryukov/smoloki"
    },
    "split_keywords": [
        "library",
        " loki"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8ef0105cf37752a77305b68f051eb8f951b67d8766df65e5d9dbfd0a64bff311",
                "md5": "c69783db6b4c4ba3ae2cf6a70db18ad6",
                "sha256": "12e5c8f0b784a2bc35f38b1cc669ac3033023facb92dab330e3984193f88af14"
            },
            "downloads": -1,
            "filename": "smoloki-0.0.18-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c69783db6b4c4ba3ae2cf6a70db18ad6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 4503,
            "upload_time": "2024-12-17T12:00:15",
            "upload_time_iso_8601": "2024-12-17T12:00:15.674103Z",
            "url": "https://files.pythonhosted.org/packages/8e/f0/105cf37752a77305b68f051eb8f951b67d8766df65e5d9dbfd0a64bff311/smoloki-0.0.18-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a91e9cde15ff8d13343198a49620b4bd349ac338d76f035ac73100e9f6b8d1f3",
                "md5": "449c4b2f1ecaf974920262b9bba8dabb",
                "sha256": "1ac83eb1ae6229829827d15a2f12edc7a33b885d11fa319da8c438b723dbeb4d"
            },
            "downloads": -1,
            "filename": "smoloki-0.0.18.tar.gz",
            "has_sig": false,
            "md5_digest": "449c4b2f1ecaf974920262b9bba8dabb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4685,
            "upload_time": "2024-12-17T12:00:18",
            "upload_time_iso_8601": "2024-12-17T12:00:18.328028Z",
            "url": "https://files.pythonhosted.org/packages/a9/1e/9cde15ff8d13343198a49620b4bd349ac338d76f035ac73100e9f6b8d1f3/smoloki-0.0.18.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-17 12:00:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "michaelkryukov",
    "github_project": "smoloki",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "smoloki"
}
        
Elapsed time: 2.94163s