get-alert-details
Retrieve detailed information about a specific alert from Prometheus Alertmanager using its fingerprint to investigate and respond to monitoring issues.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fingerprint | Yes | Alert fingerprint |
Implementation Reference
- src/index.ts:163-209 (handler)The handler function fetches all alerts from Alertmanager, finds the one matching the provided fingerprint, formats its details, and returns them as JSON. Handles errors appropriately.async ({ fingerprint }) => { try { // Fetch alert list const alerts = await fetchFromAlertmanager('alerts') as Alert[]; // Find the alert matching the fingerprint const alert = alerts.find((a: Alert) => a.fingerprint === fingerprint); if (!alert) { return { content: [{ type: "text", text: `Alert with fingerprint ${fingerprint} not found` }], isError: true }; } // Format the detailed alert information const details = { fingerprint: alert.fingerprint, alertname: alert.labels.alertname, labels: alert.labels, annotations: alert.annotations, startsAt: alert.startsAt, endsAt: alert.endsAt, generatorURL: alert.generatorURL, status: alert.status, }; return { content: [{ type: "text", text: JSON.stringify(details, null, 2) }] }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error fetching alert details: ${errorMessage}` }], isError: true }; } }
- src/index.ts:160-162 (schema)Zod input schema defining the required 'fingerprint' parameter for the tool.{ fingerprint: z.string().describe("Alert fingerprint"), },
- src/index.ts:158-210 (registration)Registration of the 'get-alert-details' tool using server.tool(), including input schema and handler function.server.tool( "get-alert-details", { fingerprint: z.string().describe("Alert fingerprint"), }, async ({ fingerprint }) => { try { // Fetch alert list const alerts = await fetchFromAlertmanager('alerts') as Alert[]; // Find the alert matching the fingerprint const alert = alerts.find((a: Alert) => a.fingerprint === fingerprint); if (!alert) { return { content: [{ type: "text", text: `Alert with fingerprint ${fingerprint} not found` }], isError: true }; } // Format the detailed alert information const details = { fingerprint: alert.fingerprint, alertname: alert.labels.alertname, labels: alert.labels, annotations: alert.annotations, startsAt: alert.startsAt, endsAt: alert.endsAt, generatorURL: alert.generatorURL, status: alert.status, }; return { content: [{ type: "text", text: JSON.stringify(details, null, 2) }] }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error fetching alert details: ${errorMessage}` }], isError: true }; } } );