32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import { createMetricsRegistry } from "@hivegrid/metrics";
|
|
import { Counter, Gauge, Histogram } from "prom-client";
|
|
|
|
export function createControllerMetrics(revision: string, collectDefaultProcessMetrics = true) {
|
|
const registry = createMetricsRegistry({
|
|
serviceName: "portal-domain-controller",
|
|
collectDefaultProcessMetrics,
|
|
defaultLabels: { revision },
|
|
});
|
|
const commands = new Counter({
|
|
name: "hivegrid_portal_domain_commands_total",
|
|
help: "Portal domain commands by action and outcome.",
|
|
labelNames: ["action", "status"] as const,
|
|
registers: [registry],
|
|
});
|
|
const duration = new Histogram({
|
|
name: "hivegrid_portal_domain_command_duration_seconds",
|
|
help: "Portal domain command processing duration.",
|
|
labelNames: ["action"] as const,
|
|
buckets: [0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30],
|
|
registers: [registry],
|
|
});
|
|
const ready = new Gauge({
|
|
name: "hivegrid_portal_domain_controller_ready",
|
|
help: "Whether Redis and the dedicated Traefik config directory are ready.",
|
|
registers: [registry],
|
|
});
|
|
return { registry, commands, duration, ready };
|
|
}
|
|
|
|
export type ControllerMetrics = ReturnType<typeof createControllerMetrics>;
|