prom_active_alerts
Monitor and list currently firing Prometheus alerts to identify active infrastructure issues requiring immediate attention.
Instructions
List all currently firing Prometheus alerts
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/prometheus/alerts.ts:4-24 (handler)The actual handler logic for `prom_active_alerts`, which fetches alerts from the Prometheus API and formats them into a table.
export async function activeAlerts(): Promise<string> { const url = `${config.prometheusUrl}/api/v1/alerts`; const res = await fetch(url); if (!res.ok) throw new Error(`Failed to fetch alerts: ${res.status}`); const data = (await res.json()) as { data: { alerts: Array<{ state: string; labels: Record<string, string>; annotations: Record<string, string> }> } }; const alerts = data.data?.alerts || []; const firing = alerts.filter((a: { state: string }) => a.state === "firing"); if (firing.length === 0) return "No active alerts firing."; const headers = ["ALERT", "STATE", "SEVERITY", "SUMMARY"]; const rows = firing.map((a: { labels: Record<string, string>; annotations: Record<string, string>; state: string }) => [ a.labels.alertname || "unknown", a.state, a.labels.severity || "N/A", (a.annotations?.summary || a.annotations?.description || "").substring(0, 60), ]); return `Active alerts (${firing.length} firing):\n\n${formatTable(headers, rows)}`; } - src/tools/prometheus/index.ts:33-36 (registration)Registration of the `prom_active_alerts` tool in the Prometheus tools list.
name: "prom_active_alerts", description: "List all currently firing Prometheus alerts", inputSchema: { type: "object" as const, properties: {} }, }, - src/tools/prometheus/index.ts:58-58 (handler)Routing logic inside `handlePrometheusTool` that dispatches the `prom_active_alerts` tool call to the `activeAlerts` function.
case "prom_active_alerts": return activeAlerts();