list_open_incidents
Retrieve and filter all open incidents in your New Relic account by account ID and priority to manage and monitor issues effectively.
Instructions
List all open incidents in your New Relic account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| priority | No | Filter by incident priority | |
| target_account_id | No | Optional New Relic account ID |
Implementation Reference
- src/tools/alert.ts:105-164 (handler)The main handler function that executes an NRQL query via NerdGraph to list open incidents, filtered by account ID and optional priority.async listOpenIncidents(input: { target_account_id?: string; priority?: 'CRITICAL' | 'HIGH' | 'MEDIUM' | 'LOW'; }): Promise<Record<string, unknown>[]> { const accountId = input.target_account_id; if (!accountId) { throw new Error('Account ID must be provided'); } if (!/^\d+$/.test(accountId)) { throw new Error('Invalid account ID format'); } let filter = `accountId = '${accountId}' AND state = 'OPEN'`; if (input.priority) { filter += ` AND priority = '${input.priority}'`; } const query = `{ actor { entitySearch(query: "${filter}") { results { entities { ... on AiIssuesEntity { issues { issues { issueId title priority state createdAt sources } } } } } } } }`; const response = await this.client.executeNerdGraphQuery<{ actor?: { entitySearch?: { results?: { entities?: Array<{ issues?: { issues?: Record<string, unknown>[] } }> }; }; }; }>(query); const entities = (response.data?.actor?.entitySearch?.results?.entities || []) as Array<{ issues?: { issues?: Record<string, unknown>[] }; }>; const incidents: Record<string, unknown>[] = []; entities.forEach((entity) => { if (entity.issues?.issues) { incidents.push(...entity.issues.issues); } }); return incidents; }
- src/tools/alert.ts:27-46 (schema)The Tool object definition returned by getIncidentsTool(), including name, description, and inputSchema for validation.getIncidentsTool(): Tool { return { name: 'list_open_incidents', description: 'List all open incidents in your New Relic account', inputSchema: { type: 'object', properties: { target_account_id: { type: 'string', description: 'Optional New Relic account ID', }, priority: { type: 'string', enum: ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'], description: 'Filter by incident priority', }, }, }, }; }
- src/server.ts:74-76 (registration)Registration of AlertTool methods, including getIncidentsTool(), into the server's tools list during server initialization.alertTool.getPoliciesTool(), alertTool.getIncidentsTool(), alertTool.getAcknowledgeTool(),
- src/server.ts:210-214 (registration)Dispatch handler in executeTool switch statement that invokes the listOpenIncidents handler with resolved account ID.case 'list_open_incidents': return await new AlertTool(this.client).listOpenIncidents({ ...args, target_account_id: accountId, });
- src/server.ts:302-302 (registration)Listed in requiresAccountId array to enforce account ID requirement for this tool.'list_open_incidents',