Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django_migrations_unapplied_total = 1 but no migrations are unapplied #405

Open
discordianfish opened this issue May 15, 2023 · 2 comments · May be fixed by #428
Open

django_migrations_unapplied_total = 1 but no migrations are unapplied #405

discordianfish opened this issue May 15, 2023 · 2 comments · May be fixed by #428

Comments

@discordianfish
Copy link

Hi,

django_migrations_unapplied_total is 1 even after we applied the migration:

Running migrations:
No migrations to apply.

@discordianfish
Copy link
Author

Restarting the app helped, so maybe it only detects the unapplied migrations once and doesn't reset the value when you run the migrations?

@discordianfish
Copy link
Author

I'd suggest turning

into a custom collector as documented here: https://github.com/prometheus/client_python#custom-collectors
In collect it would execute the same as in ExportMigrationsForDatabase and return a GaugeMetricFamily directly. That would cause it to get the unapplied migrations on every scrape. I'm not entirely sure about the costs associated but this is what you'd do in general for such use cases.
Alternatively maybe this could be implemented as a mixin but dunno if there is a way to hook that up to the django in a way similar like you do with the models..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant