Skip to main content

An asynchronous python logging handler to stream logs to Grafana Loki

Project description

aioloki

An asynchronous python logging handler to stream logs to Grafana Loki

Installation

pip install aioloki

Usage

import asyncio
import logging
import aiohttp
import aioloki

async def main():
    session = aiohttp.ClientSession()
    handler = aioloki.AioLokiHandler(
        'http://localhost:3100',
        tags={'cluser': '1'},
        session=session
    )
    log = logging.getLogger('test-logging')
    log.addHandler(handler)
    log.info(
        'Setup aioloki successfully',
        extra={'tags': {'function': 'main'}}
    )
    await session.close()

asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioloki-0.0.1a1.tar.gz (15.4 kB view hashes)

Uploaded Source

Built Distribution

aioloki-0.0.1a1-py3-none-any.whl (16.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page