events: fix missing labels on prometheus metrics (#8309)
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -14,11 +14,12 @@ GAUGE_TASKS = Gauge(
|
||||
SYSTEM_TASK_TIME = Histogram(
|
||||
"authentik_system_tasks_time_seconds",
|
||||
"Runtime of system tasks",
|
||||
["tenant"],
|
||||
)
|
||||
SYSTEM_TASK_STATUS = Gauge(
|
||||
"authentik_system_tasks_status",
|
||||
"System task status",
|
||||
["task_name", "task_uid", "status"],
|
||||
["tenant", "task_name", "task_uid", "status"],
|
||||
)
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@ from typing import Optional
|
||||
from uuid import uuid4
|
||||
|
||||
from django.apps import apps
|
||||
from django.db import models
|
||||
from django.db import connection, models
|
||||
from django.db.models import Count, ExpressionWrapper, F
|
||||
from django.db.models.fields import DurationField
|
||||
from django.db.models.functions import Extract
|
||||
@ -642,12 +642,16 @@ class SystemTask(SerializerModel, ExpiringModel):
|
||||
duration = max(self.finish_timestamp - self.start_timestamp, 0)
|
||||
# TODO: Deprecated metric - remove in 2024.2 or later
|
||||
GAUGE_TASKS.labels(
|
||||
tenant=connection.schema_name,
|
||||
task_name=self.name,
|
||||
task_uid=self.uid or "",
|
||||
status=self.status.lower(),
|
||||
).set(duration)
|
||||
SYSTEM_TASK_TIME.observe(duration)
|
||||
SYSTEM_TASK_TIME.labels(
|
||||
tenant=connection.schema_name,
|
||||
).observe(duration)
|
||||
SYSTEM_TASK_STATUS.labels(
|
||||
tenant=connection.schema_name,
|
||||
task_name=self.name,
|
||||
task_uid=self.uid or "",
|
||||
status=self.status.lower(),
|
||||
|
Reference in New Issue
Block a user