Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion webapp/models/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ def combined_updated_at(self) -> datetime:
return self.realtime_data_updated_at
if self.static_data_updated_at:
return self.static_data_updated_at
return self.modified_at
return self.modified
15 changes: 14 additions & 1 deletion webapp/prometheus_api/prometheus_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ def __init__(
def get_metrics(self) -> str:
sources = self.source_repository.fetch_sources()

last_modified_metrics = Metrics(
help='Last modification in seconds from now',
type=MetricType.gauge,
identifier='app_ocpdb_source_last_modified',
)
last_static_update_metrics = Metrics(
help='Last static update in seconds from now',
type=MetricType.gauge,
Expand Down Expand Up @@ -77,6 +82,13 @@ def get_metrics(self) -> str:
if source.static_status in [SourceStatus.DISABLED, SourceStatus.PROVISIONED]:
continue

last_modified_metrics.metrics.append(
SourceMetric(
source=source.uid,
value=int((datetime.now(tz=timezone.utc) - source.modified).total_seconds()),
)
)

if source.static_data_updated_at:
last_static_update_metrics.metrics.append(
SourceMetric(
Expand Down Expand Up @@ -121,7 +133,8 @@ def get_metrics(self) -> str:
)

metrics = (
failed_static_sources.to_metrics()
last_modified_metrics.to_metrics()
+ failed_static_sources.to_metrics()
+ last_static_update_metrics.to_metrics()
+ source_static_errors.to_metrics()
+ failed_realtime_sources.to_metrics()
Expand Down
Loading