Name | django-aetos JSON |
Version |
0.3.0
JSON |
| download |
home_page | None |
Summary | Export Django monitoring metrics for prometheus.io |
upload_time | 2024-08-21 13:25:59 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | Copyright (c) 2023 uberspace.de Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
exporter
metrics
prometheus
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
Django Aetos
============
A Django app to expose metrics to be scraped by prometheus.io.
Usage
-----
First, install django-aetos:
.. code-block:: python
pip install django-aetos
then, add the app to `settings.py`:
.. code-block:: python
INSTALLED_APPS = [
# ... other apps ...
"django_aetos",
# ... other apps ...
]
configure aetos in `settings.py`:
> ℹ️ **Important**: When using `django-aetos` in a project behind a reverse proxy, include [`django-xff`](https://pypi.org/project/django-xff/) in your project, so that a request's `REMOTE_ADDR` header gets rewritten to the correct client ip.
.. code-block:: python
# on enabled ip allowlist with empty list, requests are denied
AETOS_ENABLE_IP_ALLOWLIST = True
AETOS_IP_ALLOWLIST = ["127.0.0.1"]
# enables authentication via bearer token
# if enabled with empty list, requests are denied
AETOS_ENABLE_AUTH = True
AETOS_AUTH_TOKENS = ["ooy9Evuth0zahka"]
and send requests to `/metrics` to Aetos in your `urls.py`:
.. code-block:: python
from django.urls import include
urlpatterns = [
path("", include("django_aetos.urls")),
# ... your other patterns ...
]
Then, add your own metrics by listening for the `collect_metrics` signal.
Refer to [the django docs](https://docs.djangoproject.com/en/dev/topics/signals/)
on details how to do this.
Your signal handler can return multiple metrics, each represented as a dict
within a list of generator.
Your `src/app/signals.py`:
.. code-block:: python
from django.dispatch import receiver
from django_aetos.signals import collect_metrics
@receiver(collect_metrics, dispatch_uid='metric_universes_count')
def metric_universes_count(sender, **kwargs):
yield {
"name": "universes_count",
"help": "Total number of universes",
"type": "counter",
"value": 1,
}
You can do anything you like here, like make database queries or look at files
in the filesystem.
To make sure your receiver actually connects, add an import to your
`src/app/apps.py`:
.. code-block:: python
from django.apps import AppConfig
class YourAppConfig(AppConfig):
name = "yourapp"
def ready(self):
from . import signals # NOQA
Dev Setup
---------
.. code-block::
python3 -m venv venv
source venv/bin/activate
make setup
make install-dev
Testing
---------
.. code-block::
make test
Packaging
---------
.. code-block::
git pull
make bump-version part=minor
git push origin main v$(bump-my-version show current_version)
.. code-block::
make build
make upload-test
once the package looks good, run `make upload`.
Raw data
{
"_id": null,
"home_page": null,
"name": "django-aetos",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "\"uberspace.de\" <hallo@uberspace.de>",
"keywords": "exporter, metrics, prometheus",
"author": null,
"author_email": "\"uberspace.de\" <hallo@uberspace.de>",
"download_url": "https://files.pythonhosted.org/packages/3b/df/9c185ac513213cd2e5ad728c45f6167bd2f9b7e1b6a09cacb8e3eff7e04d/django_aetos-0.3.0.tar.gz",
"platform": null,
"description": "Django Aetos\n============\n\nA Django app to expose metrics to be scraped by prometheus.io.\n\nUsage\n-----\n\nFirst, install django-aetos:\n\n.. code-block:: python\n\n pip install django-aetos\n\nthen, add the app to `settings.py`:\n\n.. code-block:: python\n\n INSTALLED_APPS = [\n # ... other apps ...\n \"django_aetos\",\n # ... other apps ...\n ]\n\nconfigure aetos in `settings.py`:\n\n> \u2139\ufe0f **Important**: When using `django-aetos` in a project behind a reverse proxy, include [`django-xff`](https://pypi.org/project/django-xff/) in your project, so that a request's `REMOTE_ADDR` header gets rewritten to the correct client ip.\n\n.. code-block:: python\n\n # on enabled ip allowlist with empty list, requests are denied\n AETOS_ENABLE_IP_ALLOWLIST = True\n AETOS_IP_ALLOWLIST = [\"127.0.0.1\"]\n\n # enables authentication via bearer token\n # if enabled with empty list, requests are denied\n AETOS_ENABLE_AUTH = True\n AETOS_AUTH_TOKENS = [\"ooy9Evuth0zahka\"]\n\nand send requests to `/metrics` to Aetos in your `urls.py`:\n\n.. code-block:: python\n\n from django.urls import include\n\n urlpatterns = [\n path(\"\", include(\"django_aetos.urls\")),\n # ... your other patterns ...\n ]\n\nThen, add your own metrics by listening for the `collect_metrics` signal.\nRefer to [the django docs](https://docs.djangoproject.com/en/dev/topics/signals/)\non details how to do this.\n\nYour signal handler can return multiple metrics, each represented as a dict\nwithin a list of generator.\n\nYour `src/app/signals.py`:\n\n.. code-block:: python\n\n from django.dispatch import receiver\n\n from django_aetos.signals import collect_metrics\n\n\n @receiver(collect_metrics, dispatch_uid='metric_universes_count')\n def metric_universes_count(sender, **kwargs):\n yield {\n \"name\": \"universes_count\",\n \"help\": \"Total number of universes\",\n \"type\": \"counter\",\n \"value\": 1,\n }\n\nYou can do anything you like here, like make database queries or look at files\nin the filesystem.\n\nTo make sure your receiver actually connects, add an import to your\n`src/app/apps.py`:\n\n.. code-block:: python\n\n from django.apps import AppConfig\n\n class YourAppConfig(AppConfig):\n name = \"yourapp\"\n\n def ready(self):\n from . import signals # NOQA\n\nDev Setup\n---------\n\n.. code-block::\n\n python3 -m venv venv\n source venv/bin/activate\n make setup\n make install-dev\n\nTesting\n---------\n\n.. code-block::\n\n make test\n\nPackaging\n---------\n\n.. code-block::\n\n git pull\n make bump-version part=minor\n git push origin main v$(bump-my-version show current_version)\n\n.. code-block::\n\n make build\n make upload-test\n\nonce the package looks good, run `make upload`.\n",
"bugtrack_url": null,
"license": "Copyright (c) 2023 uberspace.de Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "Export Django monitoring metrics for prometheus.io",
"version": "0.3.0",
"project_urls": {
"Homepage": "https://github.com/uberspace/django-aetos",
"Issues": "https://github.com/uberspace/django-aetos/issues"
},
"split_keywords": [
"exporter",
" metrics",
" prometheus"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ef6e018a3e8281892e6cdd35c033db28762d252e7eb7222f526d8934b690d2ba",
"md5": "d39e0da0e6bf5fd2eca18fe5272e7617",
"sha256": "153f8004a886b2c829949e03a82fccb1ad8536996a4d96de078d072ee35ab610"
},
"downloads": -1,
"filename": "django_aetos-0.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d39e0da0e6bf5fd2eca18fe5272e7617",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 6293,
"upload_time": "2024-08-21T13:25:57",
"upload_time_iso_8601": "2024-08-21T13:25:57.918103Z",
"url": "https://files.pythonhosted.org/packages/ef/6e/018a3e8281892e6cdd35c033db28762d252e7eb7222f526d8934b690d2ba/django_aetos-0.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3bdf9c185ac513213cd2e5ad728c45f6167bd2f9b7e1b6a09cacb8e3eff7e04d",
"md5": "42985a614284ac5df80217bdf3dcad82",
"sha256": "f8ae2cff816c65a9b4c20abd4ebcb346271ee50177c804220a862c01de8f1189"
},
"downloads": -1,
"filename": "django_aetos-0.3.0.tar.gz",
"has_sig": false,
"md5_digest": "42985a614284ac5df80217bdf3dcad82",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 10273,
"upload_time": "2024-08-21T13:25:59",
"upload_time_iso_8601": "2024-08-21T13:25:59.119233Z",
"url": "https://files.pythonhosted.org/packages/3b/df/9c185ac513213cd2e5ad728c45f6167bd2f9b7e1b6a09cacb8e3eff7e04d/django_aetos-0.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-21 13:25:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "uberspace",
"github_project": "django-aetos",
"github_not_found": true,
"lcname": "django-aetos"
}