mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2025-12-16 00:53:39 +00:00
Add prometheus metrics endpoint. Closes #67
This commit is contained in:
@@ -7,6 +7,7 @@ import pytz
|
||||
|
||||
from core.config import SERVER_OWNER_CALLSIGN
|
||||
from core.constants import SOFTWARE_VERSION
|
||||
from core.prometheus_metrics_handler import memory_use_gauge, spots_gauge, alerts_gauge
|
||||
|
||||
|
||||
# Provides a timed update of the application's status data.
|
||||
@@ -60,8 +61,15 @@ class StatusReporter:
|
||||
self.status_data["webserver"] = {"status": self.web_server.status,
|
||||
"last_api_access": self.web_server.last_api_access_time.replace(
|
||||
tzinfo=pytz.UTC).timestamp() if self.web_server.last_api_access_time else 0,
|
||||
"api_access_count": self.web_server.api_access_counter,
|
||||
"last_page_access": self.web_server.last_page_access_time.replace(
|
||||
tzinfo=pytz.UTC).timestamp() if self.web_server.last_page_access_time else 0}
|
||||
tzinfo=pytz.UTC).timestamp() if self.web_server.last_page_access_time else 0,
|
||||
"page_access_count": self.web_server.page_access_counter}
|
||||
|
||||
# Update Prometheus metrics
|
||||
memory_use_gauge.set(psutil.Process(os.getpid()).memory_info().rss * 1024)
|
||||
spots_gauge.set(len(self.spots))
|
||||
alerts_gauge.set(len(self.alerts))
|
||||
|
||||
self.run_timer = Timer(self.run_interval, self.run)
|
||||
self.run_timer.start()
|
||||
|
||||
Reference in New Issue
Block a user