get-events
Search Datadog events like deployments, alerts, and comments within a specified time range to correlate system behaviors with specific activities.
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 |
|---|---|---|---|
| start | Yes | ||
| end | Yes | ||
| priority | No | ||
| sources | No | ||
| tags | No | ||
| unaggregated | No | ||
| excludeAggregation | No | ||
| limit | No |
Implementation Reference
- src/tools/getEvents.ts:34-71 (handler)The main handler function that performs the Datadog API call to list events using the provided parameters.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:179-188 (schema)Zod input schema defining parameters for the get-events tool: time range (start/end), filters (priority, sources, tags), aggregation options, and limit.{ 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) },
- src/index.ts:176-195 (registration)Registers the 'get-events' tool with the MCP server, providing name, description, input schema, and execution wrapper.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 GetEventsParams matching the tool input schema.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 sets up Datadog client configuration with API keys and site.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 }); } },