{ "info": { "author": "Martin Brochhaus", "author_email": "mbrochh@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "Django InfluxDB Metrics\n=======================\n\nA reusable Django app that sends metrics about your project to InfluxDB.\n\nIMPORTANT NOTE: This release only supports InfluxDB >= 0.9. We have also dropped\na few measurements like CPU, memory and disk-space because\n[Telegraf](https://github.com/influxdb/telegraf) can collect these in a much\nmuch better way.\n\nPrerequisites\n-------------\n\nThis module has celery support but you don't have to use it, if you don't want\nto.\n\nInstallation\n------------\n\nTo get the latest stable release from PyPi\n\n.. code-block:: bash\n\n pip install django-influxdb-metrics\n\nTo get the latest commit from GitHub\n\n.. code-block:: bash\n\n pip install -e git+git://github.com/bitmazk/django-influxdb-metrics.git#egg=influxdb_metrics\n\nAdd ``influxdb_metrics`` to your ``INSTALLED_APPS``\n\n.. code-block:: python\n\n INSTALLED_APPS = (\n ...,\n 'influxdb_metrics',\n )\n\nSettings\n--------\n\nYou need to set the following settings::\n\n INFLUXDB_HOST = 'your.influxdbhost.com'\n INFLUXDB_PORT = '8086'\n INFLUXDB_USER = 'youruser'\n INFLUXDB_PASSWORD = 'yourpassword'\n INFLUXDB_DATABASE = 'yourdatabase'\n\n # This is for tagging the data sent to your influxdb instance so that you\n # can query by host\n INFLUXDB_TAGS_HOST = 'your_hostname'\n\n # Seconds to wait for the request to the influxdb server before timing out\n INFLUXDB_TIMEOUT = 5\n\n # Set this to True if you are using Celery\n INFLUXDB_USE_CELERY = True\n\n # Set this to True if you are not using Celery\n INFLUXDB_USE_THREADING = False\n\nIf you would like to disable sending of metrics (i.e. for local development),\nyou can set::\n\n INFLUXDB_DISABLED = True\n\nIf you are having trouble getting the postgresql database size, you might need\nto set::\n\n INFLUXDB_POSTGRESQL_USE_LOCALHOST = True\n\nUse ssl with INFLUXDB_HOST::\n\n INFLUXDB_SSL = True # default is False\n\nOptional with ssl::\n\n INFLUXDB_VERIFY_SSL = True # default is False\n\n\nUsage\n-----\n\nThe app comes with several management commands which you should schedule via\ncrontab.\n\n\ninfluxdb_get_postgresql_size\n++++++++++++++++++++++++++++\n\nCollects the total disk usage for the given database.\n\nYou can run it like this::\n\n ./manage.py influxdb_get_postgresql_size db_role db_name\n\nYou should provide role and name for the database you want to measure. Make\nsure that you have a ``.pgpass`` file in place so that you don't need to enter\na password for this user.\n\nYou could schedule it like this::\n\n 0 */1 * * * cd /path/to/project/ && /path/to/venv/bin/python /path/to/project/manage.py influxdb_get_postgresql_size db_role db_name > $HOME/mylogs/cron/influxdb-get-postgresql-size.log 2>&1\n\nThe measurement created in your InfluxDB will be named `postgresql_size` and\nwill have the following fields:\n\n* ``value``: The total database size in bytes\n\n\nInfluxDbEmailBackend\n++++++++++++++++++++\n\nIf you would like to track the number of emails sent, you can set your\n`EMAIL_BACKEND`::\n\n EMAIL_BACKEND = 'influxdb_metrics.email.InfluxDbEmailBackend'\n\nWhen the setting is set, metrics will be sent every time you run ``.manage.py\nsend_mail``.\n\nThe measurement created in your InfluxDB will be named ``django_email_sent``\nand will have the following fields:\n\n* ``value``: The number of emails sent\n\n\nInfluxDBRequestMiddleware\n+++++++++++++++++++++++++\n\nIf you would like to track the number and speed of all requests, you can add\nthe ``InfluxDBRequestMiddleware`` at the top of your ``MIDDLEWARE_CLASSES``::\n\n MIDDLEWARE_CLASSES = [\n 'influxdb_metrics.middleware.InfluxDBRequestMiddleware',\n ...\n ]\n\nThe measurement created in your InfluxDB will be named ``django.request`` and\nwill have the following fields:\n\n* ``value``: The request time in milliseconds.\n\nAdditionally, it will have the following tags:\n\n* ``is_ajax``: `true` if it was an AJAX request, otherwise `false`\n* ``is_authenticated``: `true` if user was authenticated, otherwise `false`\n* ``is_staff``: `true` if user was a staff user, otherwise `false`\n* ``is_superuser``: `true` user was a superuser, otherwise `false`\n* ``method``: The request method (`GET` or `POST`)\n* ``module``: The python module that handled the request\n* ``view``: The view class or function that handled the request\n* ``referer``: The full URL from `request.META['HTTP_REFERER']`\n* ``referer_tld``: The top level domain of the referer. It tries to be smart\n and regards ``google.co.uk`` as a top level domain (instead of ``co.uk``)\n* ``full_path``: The full path that was requested\n* ``path``: The path without GET params that was requested\n* ``campaign``: A value that is extracted from the GET-parameter `campaign`,\n if present. You can change the name of this keyword from `campaign` to\n anything via the setting `INFLUXDB_METRICS_CAMPAIGN_KEYWORD`.\n\nIf you have a highly frequented site, this table could get big really quick.\nYou should make sure to create a shard with a low retention time for this\nseries (i.e. 7d) and add a continuous query to downsample the data into\nhourly/daily averages. When doing that, you will obviously lose the detailed\ninformation like ``referer`` and ``referer_tld`` but it might make sense to\ncreate a second continuous query to count and downsample at least the\n``referer_tld`` values.\n\nNOTE: I don't know what impact this has on overall request time or how much\nstress this would put on the InfluxDB server if you get thousands of requests.\nIt would probably wise to consider something like statsd to aggregate the\nrequests first and then send them to InfluxDB in bulk.\n\n\nTracking Users\n++++++++++++++\n\nThis app's ``models.py`` contains a ``post_save`` and a ``post_delete`` handler\nwhich will detect when a user is created or deleted.\n\nIt will create three measurements in your InfluxDB:\n\nThe first one will be named ``django_auth_user_create`` and will have the\nfollowing fields:\n\n* ``value``: 1\n\nThe second one will be named ``django_auth_user_delete`` and will have the\nfollowing fields:\n\n* ``value``: 1\n\nThe third one will be named ``django_auth_user_count`` and will have the\nfollowing fields:\n\n* ``value``: The total number of users in the database\n\n\nTracking User Logins\n++++++++++++++++++++\n\nThis app's ``models.py`` contains a handler for the ``user_logged_in`` signal.\n\nThe measurement created in your InfluxDB will be named\n``django_auth_user_login`` and will have the following fields:\n\n* ``value``: 1\n\n\nMaking Queries\n++++++++++++++\n\nIf you need to get data out of your InfluxDB instance, you can easily do it\nlike so::\n\n from influxdb_metrics.utils import query\n query('select * from series.name', time_precision='s', chunked=False)\n\nThe method declaration is the same as the one in ``InfluxDBClient.query()``.\nThis wrapper simply instanciates a client based on your settings.\n\n\nContribute\n----------\n\nIf you want to contribute to this project, please perform the following steps\n\n.. code-block:: bash\n\n # Fork this repository\n # Clone your fork\n mkvirtualenv -p python2.7 django-influxdb-metrics\n make develop\n\n git co -b feature_branch master\n # Implement your feature and tests\n git add . && git commit\n git push -u origin feature_branch\n # Send us a pull request for your feature branch\n\n\nRuning tests\n------------\n\nFor running the tests [Docker](https://docs.docker.com/) and\n[Docker compose](https://www.docker.com/products/docker-compose) is required.\n\nThe test setup a Influxdb database for testing against real queries.\n\nIn order to run the tests just run the command::\n\n ./run_tests_with_docker.sh\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bitmazk/django-influxdb-metrics", "keywords": "django", "license": "The MIT License", "maintainer": "", "maintainer_email": "", "name": "inb-django-influxdb-metrics", "package_url": "https://pypi.org/project/inb-django-influxdb-metrics/", "platform": "OS Independent", "project_url": "https://pypi.org/project/inb-django-influxdb-metrics/", "project_urls": { "Homepage": "https://github.com/bitmazk/django-influxdb-metrics" }, "release_url": "https://pypi.org/project/inb-django-influxdb-metrics/1.3.3/", "requires_dist": null, "requires_python": "", "summary": "A reusable Django app that sends metrics about your project to InfluxDB\n", "version": "1.3.3" }, "last_serial": 2798715, "releases": { "1.3.2": [ { "comment_text": "", "digests": { "md5": "dccbb0107dbf5d480a241bbe6d10bbe6", "sha256": "9f9ec551842032a68fd1c5ade1f2355e42e35cf4d812280d9f9e8a4ed221ec72" }, "downloads": -1, "filename": "inb-django-influxdb-metrics-1.3.2.tar.gz", "has_sig": false, "md5_digest": "dccbb0107dbf5d480a241bbe6d10bbe6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16397, "upload_time": "2017-04-05T15:42:37", "url": "https://files.pythonhosted.org/packages/a9/01/0d2c48a725a8882afa7622449e006ad803313b518edad7bd0f34e1315794/inb-django-influxdb-metrics-1.3.2.tar.gz" } ], "1.3.3": [ { "comment_text": "", "digests": { "md5": "43855af048b0a98c74b110ae9c8e1748", "sha256": "8e1a6b3e75aa8e0d70d1ca7b42325ac300a793fa779ed8f560ff7adaf337e3c5" }, "downloads": -1, "filename": "inb-django-influxdb-metrics-1.3.3.tar.gz", "has_sig": false, "md5_digest": "43855af048b0a98c74b110ae9c8e1748", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16382, "upload_time": "2017-04-12T11:56:48", "url": "https://files.pythonhosted.org/packages/d7/73/4795f54f8783175d43a5b34f7896f3634557e9dc13c1a69ea3f13fcb5341/inb-django-influxdb-metrics-1.3.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "43855af048b0a98c74b110ae9c8e1748", "sha256": "8e1a6b3e75aa8e0d70d1ca7b42325ac300a793fa779ed8f560ff7adaf337e3c5" }, "downloads": -1, "filename": "inb-django-influxdb-metrics-1.3.3.tar.gz", "has_sig": false, "md5_digest": "43855af048b0a98c74b110ae9c8e1748", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16382, "upload_time": "2017-04-12T11:56:48", "url": "https://files.pythonhosted.org/packages/d7/73/4795f54f8783175d43a5b34f7896f3634557e9dc13c1a69ea3f13fcb5341/inb-django-influxdb-metrics-1.3.3.tar.gz" } ] }