{"id":27386404,"url":"https://github.com/awelzel/influxpy","last_synced_at":"2025-04-13T17:24:34.085Z","repository":{"id":62570969,"uuid":"143539960","full_name":"awelzel/influxpy","owner":"awelzel","description":"Python logging handler for InfluxDB","archived":false,"fork":false,"pushed_at":"2018-08-05T22:07:50.000Z","size":17,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T06:19:45.088Z","etag":null,"topics":["influxdb","logger","logging","python","udp"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awelzel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-04T15:19:06.000Z","updated_at":"2024-10-31T09:20:41.000Z","dependencies_parsed_at":"2022-11-03T17:15:43.216Z","dependency_job_id":null,"html_url":"https://github.com/awelzel/influxpy","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awelzel%2Finfluxpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awelzel%2Finfluxpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awelzel%2Finfluxpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awelzel%2Finfluxpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awelzel","download_url":"https://codeload.github.com/awelzel/influxpy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248751253,"owners_count":21155857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["influxdb","logger","logging","python","udp"],"created_at":"2025-04-13T17:24:33.595Z","updated_at":"2025-04-13T17:24:34.080Z","avatar_url":"https://github.com/awelzel.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ``influxpy``\n\n[![Coverage Status](https://coveralls.io/repos/github/awelzel/influxpy/badge.svg?branch=master)](https://coveralls.io/github/awelzel/influxpy?branch=master) [![Build Status](https://travis-ci.org/awelzel/influxpy.svg?branch=master)](https://travis-ci.org/awelzel/influxpy)\n\n# About\nPython logging handler that sends messages to InfluxDB via UDP using\nthe line protocol. There is decidedly no support for the HTTP input.\n\nThe code was heavily inspired by and based on [graypy][1].\n\n# Usage\n\n## Example\n\n    import logging\n    import influxpy\n\n    my_logger = logging.getLogger(\"test_logger\")\n    my_logger.setLevel(logging.DEBUG)\n\n    handler = influxpy.UDPHandler(\"localhost\", 8089, \"influxpy_logs\",\n                                  global_tags={\"app\": \"example\"})\n    my_logger.addHandler(handler)\n\n    my_logger.debug(\"Hello InfluxDB.\")\n\n\nTracebacks are added as full messages::\n\n    try:\n        puff_the_magic_dragon()\n    except NameError:\n        my_logger.debug(\"No dragons here.\", exc_info=1)\n\n\n## InfluxDB Configuration\n\nThe UDP Input for InfluxDB has to be enabled in order to make use of this\nlibrary.\n\n    # influxdb.conf:\n    ...\n    [[udp]]\n    enabled = true\n    bind-address = \":8089\"\n    database = \"udp\"\n\nAlso take note of the [InfluxDB UDP documentation][2].\n\n\n## Configuration parameters\n\n``influxpy.UDPHandler``:\n\n  * **host** - The host of the InfluxDB server.\n  * **port** - The UDP port of the InfluxDB server.\n  * **measurement** - The name of the measurement/table in InfluxDB.\n  * **debugging_fields** -  Send debugging fields if set to True. Defaults is to not include debugging fields.\n  * **extra_fields** - send extra fields on the log record to InfluxDB if true (the default).\n  * **fqdn** - Use ``socket.getfqdn()`` instead of ``socket.gethostname()`` to set the source host.\n  * **localname** - Use the specified hostname as source host.\n  * **global_tags** - optional dict of tags to add to every message.\n\n\n# Schema\n\n## Tags\n\nThe following tags will be added to every message:\n\n    host, level, level_name, logger\n\nThe ``host`` is set to ``socket.gethostname()``, but can be changed\nby setting ``fqdn``, or overriding it completly by providing ``localname``.\n``level`` is the syslog level mapped to this message. ``level_name`` is\nthe respective Python logging level name (``INFO``, ``ERROR``, etc.).\nThe ``logger`` tag is simply the name of the Python logger.\n\nIt is possible to pass ``global_tags`` and thereby configure a set of\nstatic tags that are added to every message. For example, the following\nwill put ``datacenter=us-west`` and ``app=snakeoil`` as global tags.\n\n    handler = influxpy.UDPHandler(\"127.0.0.1\", 8089, \"\",\n                                  global_tags={\n                                      \"datacenter\": \"us-west\",\n                                      \"app\": \"snakeoil\"})\n\n## Fields\n\n    message, full_message\n\nThe ``full_message`` field is added only to messages for which an exception\ntraceback is available. That is, when using ``logger.exception()``\nor setting ``exec_info=1`` explicitly.\n\nWhen ``debugging_fields`` is set to True, the following fields are added\nadditionally:\n\n    file, function, line, pid, process_name, thread_name\n\nWhen ``extra_fields`` is set to True, any extra fields on the ``LogRecord``\ninstance are sent to InfluxDB. Adding extra fields can be achieved by\npassing the ``extra`` keyword argument to a logger call, or using\n``logging.LoggerAdapter``. See the Python logging documentation for\nmore information.\n\n    my_logger.debug(\"Login successful.\", extra={\"username\": \"John\"})\n    my_logger.info(\"It is warm.\", extra={\"temperature\": 26.3})\n    my_logger.warn(\"Disk Report.\", extra={\"disk_utilization\": 73.4,\n                                          \"disk_free_space_mb\": 63129})\n\nThis allows to conveniently add timeseries information that can be\nvisualized using Grafana.\n\n\n# Using with Django\n\nIt should be easy to integrate ``influxpy`` with Django's logging settings.\n\n\n# Credits:\n  * [graypy][1] / Sever Banesiu\n\n\n[1]: https://github.com/severb/graypy\n[2]: https://docs.influxdata.com/influxdb/v1.6/supported_protocols/udp/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawelzel%2Finfluxpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawelzel%2Finfluxpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawelzel%2Finfluxpy/lists"}