Skip to main content
Glama

prometheus_query_range

Execute a Prometheus range query to retrieve metrics within a specified time range, with defined start, end timestamps, and step resolution for monitoring and analysis.

Instructions

Execute a Prometheus range query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endYesend timestamp (RFC3339 or unix timestamp)
queryYesprometheus query expression
startYesstart timestamp (RFC3339 or unix timestamp)
stepYesquery resolution step width

Implementation Reference

  • Handler function that executes the prometheus_query_range tool logic by calling client.queryRange with the provided query, start, end, and step parameters.
    handle: async (client: PrometheusClient, args) => client.queryRange(args.query, args.start, args.end, args.step),
  • Zod schema defining the input parameters for the prometheus_query_range tool: query (PromQL expression), start, end (timestamps), step (resolution).
    const PrometheusQueryRangeSchema = z.object({ query: z.string().describe("prometheus query expression"), start: z.string().describe("start timestamp (RFC3339 or unix timestamp)"), end: z.string().describe("end timestamp (RFC3339 or unix timestamp)"), step: z.string().describe("query resolution step width"), });
  • Registration of the prometheus_query_range tool in the tools array, specifying its capability, name, schema, and handler.
    defineTool<typeof PrometheusQueryRangeSchema, QueryResult>({ capability: "query", name: "prometheus_query_range", title: "Prometheus Query Range", description: "Execute a Prometheus range query", inputSchema: PrometheusQueryRangeSchema, type: "readonly", handle: async (client: PrometheusClient, args) => client.queryRange(args.query, args.start, args.end, args.step), }),
  • Supporting method in PrometheusClient that performs the actual HTTP request to Prometheus /api/v1/query_range endpoint, called by the tool handler.
    async queryRange( query: string, start: string, end: string, step: string, ): Promise<QueryResult> { const endpoint = "/api/v1/query_range"; const params: Record<string, string> = { query, start, end, step }; return this.request<QueryResult>(endpoint, params); }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/idanfishman/prometheus-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server