django-traffic

A Django middleware that helps visualize your app's traffic in Kibana

In a nutshell, by using this middleware you need no more effort to stream your app's traffic in your ElasticSearch host(s) and use Kibana for visualizations around it.

Request information transmitted to ElasticSearch:

Geolocation is achieved by using django.contrib.gis.geoip2.GeoIP2 wrapper, included in Django 1.9 and latter.

Quick Start

1. Install using pip:

  pip install django-traffic

To install the latest version directly from GitHub:

  pip install git+https://github.com/koslibpro/django-traffic

2. Include "django-traffic" in your INSTALLED_APPS:

  INSTALLED_APPS = [
      ...
      'django_traffic',
  ]

3. Include "ESTrafficInfoMiddleware" to your MIDDLEWARE_CLASSES:

  MIDDLEWARE_CLASSES = (
      ...
      'django_traffic.middleware.ESTrafficInfoMiddleware',
  )

The middleware is created in a way that supports both MIDDLEWARE_CLASSES on Django older versions and MIDDLEWARE in latest Django versions.

Configuration

There are some variables required in your settings.py file to function normally.

After you deploy your project or locally run your django server, requests and traffic to your web app will be sent to the ElasticSearch hosts defined. Practically you are ready to create a Kibana map-tile visualization and start watching where traffic is flooding you in.

Contributing - Error Reporting

This lib was made with my own needs in mind, so it's uncommon to fit everyone's project out there. For Error Reporting, open an issue in Github and I will try to take care of it as soon as possible. If you are able to contribute to this lib and make it better, feel free to fork it and adjust it to your use-case.