{ "info": { "author": "Andrey Maslov", "author_email": "greyzmeem@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Logging" ], "description": "python-logging-loki\n===================\n\n[![PyPI version](https://img.shields.io/pypi/v/python-logging-loki.svg)](https://pypi.org/project/python-logging-loki/)\n[![Python version](https://img.shields.io/badge/python-3.5%20%7C%203.6%20%7C%203.7-blue.svg)](https://www.python.org/)\n[![License](https://img.shields.io/pypi/l/python-logging-loki.svg)](https://opensource.org/licenses/MIT)\n\nPython logging handler for Loki. \nhttps://grafana.com/loki\n\nInstallation\n============\n```bash\npip install python-logging-loki\n```\n\nUsage\n=====\n\n```python\nimport logging\nimport logging_loki\n\n\nhandler = logging_loki.LokiHandler(\n url=\"https://my-loki-instnace/api/prom/push\", \n tags={\"application\": \"my-app\"},\n auth=(\"username\", \"password\"), \n)\n\nlogger = logging.getLogger(\"my-logger\")\nlogger.addHandler(handler)\nlogger.error(\n \"Something happened\", \n extra={\"tags\": {\"service\": \"my-service\"}},\n)\n```\n\nExample above will send `Something happened` message along with these labels:\n- Default labels from handler\n- Message level as `serverity`\n- Logger's name as `logger` \n- Labels from `tags` item of `extra` dict\n\nThe given example is blocking (i.e. each call will wait for the message to be sent). \nBut you can use the built-in `QueueHandler` and` QueueListener` to send messages in a separate thread. \n\n```python\nimport logging.handlers\nimport logging_loki\nfrom queue import Queue\n\n\nqueue = Queue(-1)\nhandler = logging.handlers.QueueHandler(queue)\nhandler_loki = logging_loki.LokiHandler(\n url=\"https://my-loki-instnace/api/prom/push\", \n tags={\"application\": \"my-app\"},\n auth=(\"username\", \"password\"), \n)\nlogging.handlers.QueueListener(queue, handler_loki)\n\nlogger = logging.getLogger(\"my-logger\")\nlogger.addHandler(handler)\nlogger.error(...)\n```\n\nOr you can use `LokiQueueHandler` shortcut, which will automatically create listener and handler.\n\n```python\nimport logging.handlers\nimport logging_loki\nfrom queue import Queue\n\n\nhandler = logging_loki.LokiQueueHandler(\n Queue(-1),\n url=\"https://my-loki-instnace/api/prom/push\", \n tags={\"application\": \"my-app\"},\n auth=(\"username\", \"password\"),\n)\n\nlogger = logging.getLogger(\"my-logger\")\nlogger.addHandler(handler)\nlogger.error(...)\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/greyzmeem/python-logging-loki", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "python-logging-loki", "package_url": "https://pypi.org/project/python-logging-loki/", "platform": "", "project_url": "https://pypi.org/project/python-logging-loki/", "project_urls": { "Homepage": "https://github.com/greyzmeem/python-logging-loki" }, "release_url": "https://pypi.org/project/python-logging-loki/0.2.0/", "requires_dist": [ "rfc3339 (>=6.1)", "requests" ], "requires_python": ">=3.5", "summary": "Python logging handler for Grafana Loki.", "version": "0.2.0" }, "last_serial": 5759959, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "a879e4acb90cab5a6d706a64ac7ef70e", "sha256": "d014411db34f00380e3d191be3c5e3ad67420d0c8d13189250d8a9042656069f" }, "downloads": -1, "filename": "python_logging_loki-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "a879e4acb90cab5a6d706a64ac7ef70e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 4566, "upload_time": "2019-02-20T14:58:59", "url": "https://files.pythonhosted.org/packages/2f/19/520f706008c4903a5527143e0f3c4dd39872a98074889607014d80b3b65e/python_logging_loki-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7ea13140cb91ab77b6642a80d6a5896d", "sha256": "8c5850b065e6a0bfbb24bf98d6e5c73d3bab44a28ef934521d3b0c8c217c7aef" }, "downloads": -1, "filename": "python-logging-loki-0.1.0.tar.gz", "has_sig": false, "md5_digest": "7ea13140cb91ab77b6642a80d6a5896d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 3320, "upload_time": "2019-02-20T14:59:01", "url": "https://files.pythonhosted.org/packages/b5/cb/cbde9911204ea944785a3e752c6a4ec7506bb590c378b726b317c95b2d76/python-logging-loki-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "fc5ffdda7dc87accb25efdf9ec63f97e", "sha256": "5f4e5052420204e33ce7c54a9380f3f53eb9cd502f31ea69ae9d0ec7f793a111" }, "downloads": -1, "filename": "python_logging_loki-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "fc5ffdda7dc87accb25efdf9ec63f97e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 4584, "upload_time": "2019-08-30T11:54:41", "url": "https://files.pythonhosted.org/packages/04/32/0467fe047765ef408083e7bed88c4a15c5598fc4e622305c1c4b67b12c8b/python_logging_loki-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "08b6e5d6932ec4f5cc79ce60e95e0b4b", "sha256": "9dee4a51d265894314eacae55a501a8eadaff2b07b4c482ef365190ec1954c2d" }, "downloads": -1, "filename": "python-logging-loki-0.2.0.tar.gz", "has_sig": false, "md5_digest": "08b6e5d6932ec4f5cc79ce60e95e0b4b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 3475, "upload_time": "2019-08-30T11:54:42", "url": "https://files.pythonhosted.org/packages/02/99/e47f7bab601579e8c5fef4da894ebb46f3cac5613ea2170113e9392ca5bf/python-logging-loki-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fc5ffdda7dc87accb25efdf9ec63f97e", "sha256": "5f4e5052420204e33ce7c54a9380f3f53eb9cd502f31ea69ae9d0ec7f793a111" }, "downloads": -1, "filename": "python_logging_loki-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "fc5ffdda7dc87accb25efdf9ec63f97e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 4584, "upload_time": "2019-08-30T11:54:41", "url": "https://files.pythonhosted.org/packages/04/32/0467fe047765ef408083e7bed88c4a15c5598fc4e622305c1c4b67b12c8b/python_logging_loki-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "08b6e5d6932ec4f5cc79ce60e95e0b4b", "sha256": "9dee4a51d265894314eacae55a501a8eadaff2b07b4c482ef365190ec1954c2d" }, "downloads": -1, "filename": "python-logging-loki-0.2.0.tar.gz", "has_sig": false, "md5_digest": "08b6e5d6932ec4f5cc79ce60e95e0b4b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 3475, "upload_time": "2019-08-30T11:54:42", "url": "https://files.pythonhosted.org/packages/02/99/e47f7bab601579e8c5fef4da894ebb46f3cac5613ea2170113e9392ca5bf/python-logging-loki-0.2.0.tar.gz" } ] }