From e09a27cf8748b08d28bdf190322e4e79705738aa Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 3 Sep 2021 17:55:12 +0200 Subject: [PATCH] events: remove authentik_events gauge Signed-off-by: Jens Langhammer --- Dockerfile | 1 + authentik/events/apps.py | 12 ------------ authentik/events/models.py | 15 --------------- 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1bc626034..59b2684b5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -98,5 +98,6 @@ COPY --from=builder /work/authentik /authentik-proxy USER authentik ENV TMPDIR /dev/shm/ ENV PYTHONUBUFFERED 1 +ENV prometheus_multiproc_dir /dev/shm/ ENV PATH "/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/lifecycle" ENTRYPOINT [ "/lifecycle/ak" ] diff --git a/authentik/events/apps.py b/authentik/events/apps.py index e033b747c..ad9e7d205 100644 --- a/authentik/events/apps.py +++ b/authentik/events/apps.py @@ -1,10 +1,7 @@ """authentik events app""" -from datetime import timedelta from importlib import import_module from django.apps import AppConfig -from django.db import ProgrammingError -from django.utils.timezone import now class AuthentikEventsConfig(AppConfig): @@ -16,12 +13,3 @@ class AuthentikEventsConfig(AppConfig): def ready(self): import_module("authentik.events.signals") - try: - from authentik.events.models import Event - - date_from = now() - timedelta(days=1) - - for event in Event.objects.filter(created__gte=date_from): - event._set_prom_metrics() - except ProgrammingError: - pass diff --git a/authentik/events/models.py b/authentik/events/models.py index 3cc04d322..243496c20 100644 --- a/authentik/events/models.py +++ b/authentik/events/models.py @@ -10,7 +10,6 @@ from django.db import models from django.http import HttpRequest from django.utils.timezone import now from django.utils.translation import gettext as _ -from prometheus_client import Gauge from requests import RequestException, post from structlog.stdlib import get_logger @@ -28,11 +27,6 @@ from authentik.tenants.models import Tenant from authentik.tenants.utils import DEFAULT_TENANT LOGGER = get_logger("authentik.events") -GAUGE_EVENTS = Gauge( - "authentik_events", - "Events in authentik", - ["action", "user_username", "app", "client_ip"], -) def default_event_duration(): @@ -182,14 +176,6 @@ class Event(ExpiringModel): return self.context["geo"] = city - def _set_prom_metrics(self): - GAUGE_EVENTS.labels( - action=self.action, - user_username=self.user.get("username"), - app=self.app, - client_ip=self.client_ip, - ).set(self.created.timestamp()) - def save(self, *args, **kwargs): if self._state.adding: LOGGER.debug( @@ -200,7 +186,6 @@ class Event(ExpiringModel): user=self.user, ) super().save(*args, **kwargs) - self._set_prom_metrics() @property def summary(self) -> str: