AXVin / aioloki

An asynchronous python logging handler to stream logs to Grafana Loki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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())

About

An asynchronous python logging handler to stream logs to Grafana Loki

License:GNU Affero General Public License v3.0


Languages

Language:Python 100.0%