prom_range
Execute a PromQL range query to retrieve time-series data between specified start and end timestamps, with a defined step interval, using Prometheus MCP Server.
Instructions
Execute a PromQL range query
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end | Yes | End timestamp | |
| includes | No | Metric properties to include in response (optional) | |
| query | Yes | PromQL query expression | |
| start | Yes | Start timestamp | |
| step | Yes | Step interval (e.g., "15s", "1m") |
Implementation Reference
- src/tools.ts:101-107 (handler)Handler logic for the 'prom_range' tool in handleToolCall function: validates input and delegates to PrometheusClient.range.case 'prom_range': { if (!isPromRangeArgs(args)) { throw new Error('Invalid arguments for prom_range'); } const { query, start, end, step, includes } = args; result = await prometheusClient.range(query, start, end, step, includes); break;
- src/prometheus-client.ts:84-95 (handler)Core execution logic for prom_range: performs HTTP GET to Prometheus /api/v1/query_range API with filtering.async range(query: string, start: string, end: string, step: string, includes?: string[]): Promise<PrometheusResponse<QueryResult>> { const response = await this.client.get<PrometheusResponse<QueryResult>>('/api/v1/query_range', { params: { query, start, end, step }, timeout: 30000, }); if (response.data.data && includes) { response.data.data = this.filterQueryResult(response.data.data, includes); } return response.data; }
- src/types.ts:16-22 (schema)TypeScript interface defining the structure of arguments for prom_range tool.export interface PromRangeArgs { query: string; start: string; end: string; step: string; includes?: string[]; }
- src/tools.ts:24-37 (registration)Tool registration entry for 'prom_range' including name, description, and JSON input schema.{ name: 'prom_range', description: 'Execute a PromQL range query', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'PromQL query expression' }, start: { type: 'string', description: 'Start timestamp' }, end: { type: 'string', description: 'End timestamp' }, step: { type: 'string', description: 'Step interval (e.g., "15s", "1m")' }, includes: { type: 'array', items: { type: 'string' }, description: 'Metric properties to include in response (optional)' }, }, required: ['query', 'start', 'end', 'step'], },
- src/tools.ts:70-72 (helper)Type guard helper to validate if arguments match PromRangeArgs structure.function isPromRangeArgs(args: unknown): args is PromRangeArgs { return typeof args === 'object' && args !== null && 'query' in args && 'start' in args && 'end' in args && 'step' in args;