Implement Monlet MVP stack and UI updates
This commit is contained in:
54
server/monlet_server/metrics.py
Normal file
54
server/monlet_server/metrics.py
Normal file
@@ -0,0 +1,54 @@
|
||||
from prometheus_client import CollectorRegistry, Counter, Gauge, Histogram, generate_latest
|
||||
from prometheus_client.exposition import CONTENT_TYPE_LATEST
|
||||
|
||||
REGISTRY = CollectorRegistry()
|
||||
|
||||
heartbeats_total = Counter(
|
||||
"monlet_server_heartbeats_total",
|
||||
"Total heartbeats received.",
|
||||
["result"],
|
||||
registry=REGISTRY,
|
||||
)
|
||||
events_total = Counter(
|
||||
"monlet_server_events_total",
|
||||
"Total events ingested.",
|
||||
["result"],
|
||||
registry=REGISTRY,
|
||||
)
|
||||
incidents_opened_total = Counter(
|
||||
"monlet_server_incidents_opened_total",
|
||||
"Total incidents opened.",
|
||||
registry=REGISTRY,
|
||||
)
|
||||
incidents_resolved_total = Counter(
|
||||
"monlet_server_incidents_resolved_total",
|
||||
"Total incidents resolved.",
|
||||
registry=REGISTRY,
|
||||
)
|
||||
agents_gauge = Gauge(
|
||||
"monlet_server_agents",
|
||||
"Agents by status.",
|
||||
["status"],
|
||||
registry=REGISTRY,
|
||||
)
|
||||
open_incidents_gauge = Gauge(
|
||||
"monlet_server_open_incidents",
|
||||
"Number of open incidents.",
|
||||
registry=REGISTRY,
|
||||
)
|
||||
notifications_total = Counter(
|
||||
"monlet_server_notifications_total",
|
||||
"Notification delivery attempts by notifier and result.",
|
||||
["notifier", "result"],
|
||||
registry=REGISTRY,
|
||||
)
|
||||
request_duration = Histogram(
|
||||
"monlet_server_request_duration_seconds",
|
||||
"Request duration seconds.",
|
||||
["path"],
|
||||
registry=REGISTRY,
|
||||
)
|
||||
|
||||
|
||||
def render() -> tuple[bytes, str]:
|
||||
return generate_latest(REGISTRY), CONTENT_TYPE_LATEST
|
||||
Reference in New Issue
Block a user