Skip to main content
Glama

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
NameRequiredDescriptionDefault
queryYesprometheus query expression
timeNooptional time parameter for the query, in RFC3339 format

Implementation Reference

  • 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), }),
  • 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"), });
  • 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); }

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