Export Django monitoring metrics for prometheus.io
Project description
A Django app to expose metrics to be scraped by prometheus.io.
Usage
First, install django-aetos:
pip install django-aetos
then, add the app to settings.py:
INSTALLED_APPS = [
# ... other apps ...
"django_aetos",
# ... other apps ...
]
and send requests to /metrics to Aetos in your urls.py:
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:
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:
from django.apps import AppConfig
class YourAppConfig(AppConfig):
name = "yourapp"
def ready(self):
from . import signals # NOQA
Dev Setup
python3 -m venv venv
source venv/bin/activate
make setup
make install-dev
Testing
make test
Packaging
git pull
make bump-version part=minor
git push origin main v$(bump-my-version show current_version)
make build
make upload-test
once the package looks good, run make upload.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_aetos-0.2.0.tar.gz
.
File metadata
- Download URL: django_aetos-0.2.0.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b20fed3fb9cb30882be03d4ff74a25822a8b80ed174bda086071aefa71ba115f |
|
MD5 | 3ab50e8060288ceacf57bc97e6620a5d |
|
BLAKE2b-256 | 5e26071e8053f450dc68af2a1029d9b6604966f937b1724a79cd5021615120f2 |
File details
Details for the file django_aetos-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: django_aetos-0.2.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1cc978c192f551d58f5034511b8840d47269a12b88b6f18a50c37f48bec8067 |
|
MD5 | cde1e88708514b1d96808080ee32afb8 |
|
BLAKE2b-256 | 9d7d90fd6c73138ab7510307d307a70ae53c161feabdee4b30c1014ae03a51d0 |