Open
Description
Describe the bug
The helm charts indicate that there's a metric django_migrations_unapplied_total
to check if all DB migrations were properly applied[1].
To Reproduce
- Configure a prometheus endpoint
- Send GET a request against
/metrics
:django_http_*
metrics will be there,django_migrations_*
won't.
Expected behavior
To have this metric available.
Screenshots
n/a
Logs
n/a
Version and Deployment (please complete the following information):
- authentik version: 2024.4.2
- Deployment: custom
Additional context
I managed to identify two issues:
django-prometheus
requires you to explicitly turn this on nowadays[2]. This can be fixed by addingPROMETHEUS_EXPORT_MIGRATIONS
toauthentik.root.settings
:
diff --git a/authentik/root/settings.py b/authentik/root/settings.py
index 15e689b06..7668a444b 100644
--- a/authentik/root/settings.py
+++ b/authentik/root/settings.py
@@ -19,6 +19,7 @@ from authentik.stages.password import BACKEND_APP_PASSWORD, BACKEND_INBUILT, BAC
BASE_DIR = Path(__file__).absolute().parent.parent.parent
+PROMETHEUS_EXPORT_MIGRATIONS = True
DEBUG = CONFIG.get_bool("debug")
SECRET_KEY = CONFIG.get("secret_key")
- For some reason I can't explain this option doesn't have any effect until you remove the
run_migrations()
invocation from the gunicorn config. I can't explain way which is why I refrain from filing a patch for now.
EDIT: for it to work currently, you also need to setpreload_app
toFalse
.
[1] https://github.com/goauthentik/helm/blob/main/charts/authentik/templates/prometheusrule.yaml#L142C36-L142C69
[2] korfuri/django-prometheus#425