Get AppDynamics health rule violations
appd_get_health_rule_violationsRetrieve open or recently-closed health rule violations for any application over a specified time window. Quickly identify critical rule breaches to resolve issues.
Instructions
Retrieve open / recently-closed health rule violations for an application within a time window.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| application | Yes | ||
| timeRange | No | AppD time range. Defaults to BEFORE_NOW with durationMinutes=30 if omitted by the caller. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| summary | Yes | ||
| evidence | No | ||
| entities | Yes | ||
| timeRange | No | ||
| sourceEndpoints | Yes | ||
| pagination | No | ||
| warnings | Yes | ||
| truncated | Yes |
Implementation Reference
- Input schema for the tool: requires application (appRefSchema) and optional timeRange.
const inputShape = { application: appRefSchema, timeRange: timeRangeSchema.optional(), }; interface Violation { id?: number; name?: string; description?: string; severity?: string; affectedEntityDefinition?: { entityType?: string; entityId?: number; name?: string }; triggeredEntityDefinition?: { entityType?: string; entityId?: number; name?: string }; startTimeInMillis?: number; endTimeInMillis?: number; detectedTimeInMillis?: number; incidentStatus?: string; // varies by API version } interface ViolationsEvidence { application: AppRef; count: number; violations: Violation[]; } - TypeScript interfaces Violation and ViolationsEvidence defining the shape of output data.
interface Violation { id?: number; name?: string; description?: string; severity?: string; affectedEntityDefinition?: { entityType?: string; entityId?: number; name?: string }; triggeredEntityDefinition?: { entityType?: string; entityId?: number; name?: string }; startTimeInMillis?: number; endTimeInMillis?: number; detectedTimeInMillis?: number; incidentStatus?: string; // varies by API version } interface ViolationsEvidence { application: AppRef; count: number; violations: Violation[]; } - src/tools/getHealthRuleViolations.ts:39-81 (registration)Tool registration: exports getHealthRuleViolationsTool as a ToolRegistration with name 'appd_get_health_rule_violations', profile 'read', and register() function that calls server.registerTool.
export const getHealthRuleViolationsTool: ToolRegistration = { name: 'appd_get_health_rule_violations', profile: 'read', register(server, services) { server.registerTool( 'appd_get_health_rule_violations', { title: 'Get AppDynamics health rule violations', description: 'Retrieve open / recently-closed health rule violations for an application within a time window.', inputSchema: inputShape, outputSchema: envelopeOutputShape, }, wrapHandler<{ application: AppRef; timeRange?: TimeRange | undefined }, ViolationsEvidence>( services.log, 'appd_get_health_rule_violations', async (input) => { const tr = input.timeRange ?? DEFAULT_TIME_RANGE; const params = applyTimeRangeToParams(tr); const appPath = appRefToPath(input.application); const path = `applications/${appPath}/problems/healthrule-violations`; const res = await services.controller.get<Violation[]>(path, Object.fromEntries(params)); const violations = Array.isArray(res.body) ? res.body : []; return toToolResult( buildEnvelope({ summary: `${violations.length} health rule violation${violations.length === 1 ? '' : 's'}.`, evidence: { application: input.application, count: violations.length, violations, } as ViolationsEvidence, entities: [{ kind: 'application', id: input.application }], timeRange: toEnvelopeTimeRange(tr), sourceEndpoints: [`GET /controller/rest/${path}`], warnings: timeRangeWarnings(tr), }), ); }, ), ); }, }; - Handler function that fetches health rule violations from the AppDynamics controller API (/applications/{app}/problems/healthrule-violations), processes time range, and returns results wrapped in an envelope.
async (input) => { const tr = input.timeRange ?? DEFAULT_TIME_RANGE; const params = applyTimeRangeToParams(tr); const appPath = appRefToPath(input.application); const path = `applications/${appPath}/problems/healthrule-violations`; const res = await services.controller.get<Violation[]>(path, Object.fromEntries(params)); const violations = Array.isArray(res.body) ? res.body : []; return toToolResult( buildEnvelope({ summary: `${violations.length} health rule violation${violations.length === 1 ? '' : 's'}.`, evidence: { application: input.application, count: violations.length, violations, } as ViolationsEvidence, entities: [{ kind: 'application', id: input.application }], timeRange: toEnvelopeTimeRange(tr), sourceEndpoints: [`GET /controller/rest/${path}`], warnings: timeRangeWarnings(tr), }), ); },