reef-technologies / cookiecutter-rt-django

CookieCutter template for Django application projects with docker-compose etc.
BSD 3-Clause "New" or "Revised" License
18 stars 22 forks source link

Metrics for migrations do not update after migration #186

Closed luca-medeiros-reef closed 3 months ago

luca-medeiros-reef commented 4 months ago

The django_migrations_unapplied_total metric is not resetting the values even after migrations are completed, causing the alert never to go off. (unless the app is restarted)

Also, the founder of Prometheus node-exporter raised the same issue here: https://github.com/korfuri/django-prometheus/issues/405

Reproduce: Rolled back some migrations using: pdm run manage.py migrate auth 0005

Then, I started the server: pdm run manage.py runserver

Observed the metrics at /metrics endpoint:

django_migrations_unapplied_total{connection="default"} 7.0 
django_migrations_applied_total{connection="default"} 15.0

Ran the migrate command on a different process: pdm run manage.py migrate Rechecked the metrics at /metrics endpoint. Observed no update in the metrics.

Restarted the server: pdm run manage.py runserver

Observed the updated metrics at /metrics endpoint:

django_migrations_unapplied_total{connection="default"} 0.0
django_migrations_applied_total{connection="default"} 22.0

Related ticket: https://reeftechnologies.atlassian.net/jira/software/c/projects/NICE/boards/41?selectedIssue=NICE-325