{"id":26650590,"url":"https://github.com/koslibpro/django-traffic","last_synced_at":"2025-03-25T02:01:49.537Z","repository":{"id":50213239,"uuid":"72279392","full_name":"koslib/django-traffic","owner":"koslib","description":"Django middleware that helps visualize your app's traffic in Kibana","archived":false,"fork":false,"pushed_at":"2022-12-26T20:00:14.000Z","size":24,"stargazers_count":57,"open_issues_count":1,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-05-19T07:28:56.110Z","etag":null,"topics":["django","django-middleware","elasticsearch","kibana"],"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/koslib.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":"2016-10-29T10:50:48.000Z","updated_at":"2021-12-09T10:51:42.000Z","dependencies_parsed_at":"2023-01-31T00:55:12.517Z","dependency_job_id":null,"html_url":"https://github.com/koslib/django-traffic","commit_stats":null,"previous_names":["koslibpro/django-traffic"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koslib%2Fdjango-traffic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koslib%2Fdjango-traffic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koslib%2Fdjango-traffic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koslib%2Fdjango-traffic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koslib","download_url":"https://codeload.github.com/koslib/django-traffic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245383037,"owners_count":20606265,"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":["django","django-middleware","elasticsearch","kibana"],"created_at":"2025-03-25T02:01:47.959Z","updated_at":"2025-03-25T02:01:49.531Z","avatar_url":"https://github.com/koslib.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# django-traffic\nA Django middleware that helps visualize your app's traffic in Kibana\n\nIn a nutshell, by using this middleware you need no more effort to stream your app's traffic in your\nElasticSearch host(s) and use Kibana for visualizations around it.\n\nRequest information transmitted to ElasticSearch:\n- `timestamp` | type: `date`\n- `location` | type: `geo_point`\n- `method` | type: `string`\n- `body` | type: `string`\n- `path` | type: `string`\n- `path_info` | type: `string`\n- `scheme` | type: `string`\n- `encoding` | type: `string`\n- `encoding_type` | type: `string`, supported only in `Django 1.10` and later\n- `ip` | type: `ip`\n\nGeolocation is achieved by using `django.contrib.gis.geoip2.GeoIP2` wrapper, included in Django 1.9 and latter.\n\n# Quick Start\n  **1. Install using pip:**\n\n  ```\n  pip install django-traffic\n  ```\n  To install the latest version directly from GitHub:\n  \n  ```\n  pip install git+https://github.com/koslibpro/django-traffic\n  ```\n\n  **2. Include \"django-traffic\" in your INSTALLED_APPS:**\n\n  ```\n  INSTALLED_APPS = [\n      ...\n      'django_traffic',\n  ]\n  ```\n\n  **3. Include \"ESTrafficInfoMiddleware\" to your MIDDLEWARE_CLASSES:**\n\n  ```\n  MIDDLEWARE_CLASSES = (\n      ...\n      'django_traffic.middleware.ESTrafficInfoMiddleware',\n  )\n  ```\n\n  The middleware is created in a way that supports both `MIDDLEWARE_CLASSES` on Django older versions and `MIDDLEWARE` in latest Django versions.\n\n# Configuration\nThere are some variables required in your `settings.py` file to function normally.\n- `TRAFFIC_INDEX_NAME`: this is the name of the index that will be used in ElasticSearch.\n If you leave this empty or do not define it, the default index name will be applied: `django-traffic`.\n\n- `ES_CLIENT`: if you already have an ElasticSearch() client instance ready in your app, we'll use this one be default.\n\n- `ES_HOST`: this is required only if you don't have an `ES_CLIENT` defined. Here the lib expects to find a hostname\n(including the port) of your ElasticSearch instance.\n\n- `GEO_DB_PATH`: if you don't have `GEOIP_PATH` already defined, you need to define the path where django can find your\ngeolocation database.\n\n- `LOG_WITHOUT_LOCATION`: (default `False`) log data even when `ip` cannot be translated to `location`\n\nAfter you deploy your project or locally run your django server, requests and traffic to your web app will be sent to\nthe ElasticSearch hosts defined. Practically you are ready to create a Kibana map-tile visualization and start watching\nwhere traffic is flooding you in.\n\n# Contributing - Error Reporting\nThis lib was made with my own needs in mind, so it's uncommon to fit everyone's project out there.\nFor Error Reporting, open an issue in Github and I will try to take care of it as soon as possible.\nIf you are able to contribute to this lib and make it better, feel free to fork it and adjust it to your use-case.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoslibpro%2Fdjango-traffic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoslibpro%2Fdjango-traffic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoslibpro%2Fdjango-traffic/lists"}