get-events
Search and retrieve Datadog events within a defined time range to analyze deployments, alerts, and system activities. Helps correlate events with system behaviors for monitoring insights.
Instructions
Search for events in Datadog within a specified time range. Events include deployments, alerts, comments, and other activities. Useful for correlating system behaviors with specific events.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end | Yes | ||
| excludeAggregation | No | ||
| limit | No | ||
| priority | No | ||
| sources | No | ||
| start | Yes | ||
| tags | No | ||
| unaggregated | No |
Implementation Reference
- src/tools/getEvents.ts:34-71 (handler)The execute function that implements the core logic for fetching events from Datadog API using the EventsApi.listEvents method, destructuring input params, making the API call, applying optional limit, and handling errors.execute: async (params: GetEventsParams) => { try { const { start, end, priority, sources, tags, unaggregated, excludeAggregation, limit } = params; const apiInstance = new v1.EventsApi(configuration); const apiParams: v1.EventsApiListEventsRequest = { start: start, end: end, priority: priority, sources: sources, tags: tags, unaggregated: unaggregated, excludeAggregate: excludeAggregation }; const response = await apiInstance.listEvents(apiParams); // Apply client-side limit if specified if (limit && response.events && response.events.length > limit) { response.events = response.events.slice(0, limit); } return response; } catch (error) { console.error("Error fetching events:", error); throw error; } }
- src/index.ts:176-195 (registration)Registers the 'get-events' tool with MCP server, providing description, Zod input schema validation, and handler that calls getEvents.execute and formats response.server.tool( "get-events", "Search for events in Datadog within a specified time range. Events include deployments, alerts, comments, and other activities. Useful for correlating system behaviors with specific events.", { start: z.number(), end: z.number(), priority: z.enum(["normal", "low"]).optional(), sources: z.string().optional(), tags: z.string().optional(), unaggregated: z.boolean().optional(), excludeAggregation: z.boolean().optional(), limit: z.number().default(100) }, async (args) => { const result = await getEvents.execute(args); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } );
- src/tools/getEvents.ts:3-12 (schema)TypeScript type definition for the input parameters of the get-events tool, matching the Zod schema used in registration.type GetEventsParams = { start: number; end: number; priority?: "normal" | "low"; sources?: string; tags?: string; unaggregated?: boolean; excludeAggregation?: boolean; limit?: number; };
- src/tools/getEvents.ts:17-32 (helper)Initialization function that sets up the Datadog client configuration with API keys and site variable for use in the execute handler.initialize: () => { const configOpts = { authMethods: { apiKeyAuth: process.env.DD_API_KEY, appKeyAuth: process.env.DD_APP_KEY } }; configuration = client.createConfiguration(configOpts); if (process.env.DD_SITE) { configuration.setServerVariables({ site: process.env.DD_SITE }); } },