49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
from prometheus_client import CollectorRegistry, Counter, Gauge, 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,
|
|
)
|
|
|
|
|
|
def render() -> tuple[bytes, str]:
|
|
return generate_latest(REGISTRY), CONTENT_TYPE_LATEST
|