prometheus_query
Execute Prometheus queries to retrieve and analyze monitoring metrics from your infrastructure, enabling data-driven insights through direct API integration.
Instructions
Execute a Prometheus query
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | prometheus query expression | |
| time | No | optional time parameter for the query, in RFC3339 format |
Implementation Reference
- src/server/tools.ts:169-178 (handler)Tool definition including handler function that executes prometheus_query by calling client.query(query, time). This registers the tool in the tools array.defineTool<typeof PrometheusQuerySchema, QueryResult>({ capability: "query", name: "prometheus_query", title: "Prometheus Query", description: "Execute a Prometheus query", inputSchema: PrometheusQuerySchema, type: "readonly", handle: async (client: PrometheusClient, args) => client.query(args.query, args.time), }),
- src/server/tools.ts:49-55 (schema)Zod input schema for the prometheus_query tool defining required 'query' string and optional 'time' string.const PrometheusQuerySchema = z.object({ query: z.string().describe("prometheus query expression"), time: z .string() .optional() .describe("optional time parameter for the query, in RFC3339 format"), });
- src/prometheus/client.ts:112-119 (helper)Core implementation of Prometheus instant query in PrometheusClient, constructing API request to /api/v1/query with query and optional time parameters.async query(query: string, time?: string): Promise<QueryResult> { const endpoint = "/api/v1/query"; const params: Record<string, string> = { query }; if (time) { params.time = time; } return this.request<QueryResult>(endpoint, params); }