Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2024-01-13 23:07:40 +01:00
parent 82e27a7458
commit 4a6f956c28
No known key found for this signature in database
3 changed files with 6 additions and 2 deletions

View File

@ -41,9 +41,11 @@ class SystemTaskSerializer(ModelSerializer):
return instance.name
def get_start_timestamp(self, instance: SystemTask) -> datetime:
"""Timestamp when the task started"""
return datetime.fromtimestamp(instance.start_timestamp, tz=timezone.utc)
def get_finish_timestamp(self, instance: SystemTask) -> datetime:
"""Timestamp when the task finished"""
return datetime.fromtimestamp(instance.finish_timestamp, tz=timezone.utc)
def get_duration(self, instance: SystemTask) -> float:

View File

@ -625,13 +625,13 @@ 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(
task_name=self.name.split(":")[0],
task_name=self.name,
task_uid=self.uid or "",
status=self.status.lower(),
).set(duration)
SYSTEM_TASK_TIME.observe(duration)
SYSTEM_TASK_STATUS.labels(
task_name=self.name.split(":")[0],
task_name=self.name,
task_uid=self.uid or "",
status=self.status.lower(),
).inc()

View File

@ -42719,10 +42719,12 @@ components:
start_timestamp:
type: string
format: date-time
description: Timestamp when the task started
readOnly: true
finish_timestamp:
type: string
format: date-time
description: Timestamp when the task finished
readOnly: true
duration:
type: number