{"id":19140958,"url":"https://github.com/gridscale/flask-graylog2","last_synced_at":"2025-05-06T23:17:17.562Z","repository":{"id":57430370,"uuid":"272935083","full_name":"gridscale/flask-graylog2","owner":"gridscale","description":"Flask extension that configures a Graylog GELF UDP logging handler for you","archived":false,"fork":false,"pushed_at":"2020-06-19T16:38:38.000Z","size":27,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-06T23:17:11.114Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gridscale.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","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":"2020-06-17T09:39:28.000Z","updated_at":"2023-04-03T11:14:18.000Z","dependencies_parsed_at":"2022-08-26T05:01:44.570Z","dependency_job_id":null,"html_url":"https://github.com/gridscale/flask-graylog2","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gridscale%2Fflask-graylog2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gridscale%2Fflask-graylog2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gridscale%2Fflask-graylog2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gridscale%2Fflask-graylog2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gridscale","download_url":"https://codeload.github.com/gridscale/flask-graylog2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252782835,"owners_count":21803410,"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":[],"created_at":"2024-11-09T07:19:35.045Z","updated_at":"2025-05-06T23:17:17.544Z","avatar_url":"https://github.com/gridscale.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask-Graylog2\n\n[![PyPI version](https://badge.fury.io/py/Flask-Graylog2.svg)](https://badge.fury.io/py/Flask-Graylog2)\n\nFork of [github.com/underdogio/flask-graylog](https://github.com/underdogio/flask-graylog) with additional patches and features.\n\nThis is a Flask extension that allows you to configure a Graylog GELF UDP logging handler as well as some middleware to log every request/response pair to Graylog.\n\nSee also:\n\n- [Flask docs](https://flask.palletsprojects.com/en/1.1.x/logging/)\n- [Graylog docs](https://docs.graylog.org/en/latest/index.html)\n- [graypy docs](https://graypy.readthedocs.io/en/stable/?badge=stable#)\n\n## Installation\n\nYou can install it with [`pip`](https://pypi.org/):\n\n    $ pip install Flask-Graylog2\n\n## Usage\n\nYou only need to import and initialize your app\n\n```python\n# Import dependencies\nfrom flask import Flask\nfrom flask_graylog import Graylog\n\n# Configure app and Graylog logger\napp = Flask(__name__)\ngraylog = Graylog(app)\n\n# Log to graylog\ngraylog.info(\"Message\", extra={\"extra\": \"metadata\",})\n\n# Use Graylog log handler in another logger\nimport logging\n\nlogger = logging.getLogger(__name__)\nlogger.addHandler(graylog.handler)\nlogger.info(\"Message\")\n```\n\n## Configuration options\n\nThe following options can be use to configure the graylog logger.\n\n```python\nfrom flask import Flask\nfrom flask_graylog import Graylog\n\napp = Flask(__name__)\n\n# Use configuration from `app`\napp.config[\"GRAYLOG_HOST\"] = \"10.1.1.1\"\ngraylog = Graylog(app)\n\n# Provide configuration\nconfig = {\"GRAYLOG_HOST\": \"10.1.1.1\"}\ngraylog = Graylog(app, config=config)\n```\n\n- `GRAYLOG_HOST` - the host to send messages to [default: 'localhost']\n- `GRAYLOG_PORT` - the port to send messages to [default: 12201]\n- `GRAYLOG_FACILITY` - the facility to report with [default: 'flask']\n- `GRAYLOG_EXTRA_FIELDS` - whether or not to include the `extra` data from each message [default: True]\n- `GRAYLOG_ADD_DEBUG_FIELDS` - whether extra python debug fields should be added to each message [default: True]\n- `GRAYLOG_CONFIGURE_MIDDLEWARE` - whether to setup middleware to log each response [default: True]\n\n## Example message format\n\n```json\n{\n    \"_process_name\": \"MainProcess\",\n    \"_request\": {\n        \"content_length\": \"\",\n        \"remote_addr\": \"127.0.0.1\",\n        \"headers\": {\n            \"upgrade_insecure_requests\": \"1\",\n            \"connection\": \"keep-alive\",\n            \"accept\": \"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\",\n            \"dnt\": \"1\",\n            \"host\": \"localhost:5000\",\n            \"user_agent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36\",\n            \"accept_language\": \"en-US,en;q=0.8,ms;q=0.6\",\n            \"cache_control\": \"max-age=0\",\n            \"accept_encoding\": \"gzip, deflate, sdch\"\n        },\n        \"path_info\": \"/\",\n        \"content_type\": \"\",\n        \"query_string\": \"\",\n        \"method\": \"GET\"\n    },\n    \"level\": 6,\n    \"_logger\": \"flask_graylog\",\n    \"timestamp\": 1460502169.950895,\n    \"_pid\": 6010,\n    \"facility\": \"flask\",\n    \"_function\": \"after_request\",\n    \"_thread_name\": \"Thread-1\",\n    \"host\": \"voltaire.local\",\n    \"version\": \"1.0\",\n    \"file\": \"Flask-Graylog/flask_graylog.py\",\n    \"full_message\": \"Finishing request for \\\"GET http://localhost:5000/\\\" from -\",\n    \"line\": 130,\n    \"_response\": {\n        \"headers\": {\n            \"content_length\": \"6\",\n            \"content_type\": \"text/html; charset=utf-8\"\n        },\n        \"time_ms\": 0,\n        \"status_code\": 200\n    },\n    \"_flask\": {\n        \"view_args\": {},\n        \"endpoint\": \"root\"\n    },\n    \"short_message\": \"Finishing request for \\\"GET http://localhost:5000/\\\" from -\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgridscale%2Fflask-graylog2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgridscale%2Fflask-graylog2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgridscale%2Fflask-graylog2/lists"}