Skip to content

Commit

Permalink
Fix prometheus unapplied_migrations false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
olzhasar-reef committed Oct 21, 2024
1 parent 804862a commit c6c286a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions {{cookiecutter.repostory_name}}/app/envs/prod/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# We assume that WORKDIR is defined in Dockerfile

./prometheus-cleanup.sh
./manage.py wait_for_database --timeout 10
PROMETHEUS_EXPORT_MIGRATIONS=0 ./manage.py wait_for_database --timeout 10
# this seems to be the only place to put this for AWS deployments to pick it up
./manage.py migrate
PROMETHEUS_EXPORT_MIGRATIONS=0 ./manage.py migrate

gunicorn -c gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def wrapped(*args, **kwargs):
]

{%- if cookiecutter.monitoring == "y" %}
PROMETHEUS_EXPORT_MIGRATIONS = True
PROMETHEUS_EXPORT_MIGRATIONS = env.bool("PROMETHEUS_EXPORT_MIGRATIONS", default=True)
{%- endif %}
{%- if cookiecutter.monitor_view_execution_time_in_djagno == "y" and cookiecutter.monitoring == "y" %}
PROMETHEUS_LATENCY_BUCKETS = (
Expand Down Expand Up @@ -536,4 +536,4 @@ def configure_structlog():
},
{%- endfor %}
}
{%- endif %}
{%- endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from django.conf import settings
from django.http import HttpResponse
from django_prometheus.exports import ExportToDjangoView
from django_prometheus.migrations import ExportMigrations
from prometheus_client import multiprocess

from ..celery import get_num_tasks_in_queue
Expand All @@ -26,8 +25,6 @@ def collect(self):

def metrics_view(request):
"""Exports metrics as a Django view"""
# Export Django migration metrics
ExportMigrations()
if os.environ.get(ENV_VAR_NAME):
registry = prometheus_client.CollectorRegistry()
RecursiveMultiProcessCollector(registry)
Expand All @@ -47,4 +44,4 @@ def metrics_view(request):
)
num_tasks_in_queue[queue.name] = gauge
gauge.set_function(partial(get_num_tasks_in_queue, queue.name))
{% endif %}
{% endif %}

0 comments on commit c6c286a

Please sign in to comment.