Skip to main content
Glama

prometheus_label_values

Retrieve all available values for a specific label in your Prometheus monitoring system to filter and analyze metrics effectively.

Instructions

Get all values for a specific Prometheus label

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
labelYeslabel name to get values for

Implementation Reference

  • Executes the tool logic by making an HTTP GET request to the Prometheus API endpoint `/api/v1/label/{label}/values` to retrieve all values for the specified label.
    async getLabelValues(label: string): Promise<LabelValues> { const endpoint = `/api/v1/label/${encodeURIComponent(label)}/values`; return this.request<LabelValues>(endpoint); }
  • Zod schema defining the input parameters for the tool: a required 'label' string.
    const PrometheusLabelValuesSchema = z.object({ label: z.string().describe("label name to get values for"), });
  • Registers the tool in the tools array with metadata, schema, and handler function that delegates to PrometheusClient.getLabelValues.
    defineTool<typeof PrometheusLabelValuesSchema, LabelValues>({ capability: "discovery", name: "prometheus_label_values", title: "Get Label Values", description: "Get all values for a specific Prometheus label", inputSchema: PrometheusLabelValuesSchema, type: "readonly", handle: async (client: PrometheusClient, args) => client.getLabelValues(args.label), }),
  • Registers filtered tools (including prometheus_label_values if discovery enabled) with the MCP server via _registerTool.
    const prometheusTools: ToolAny[] = tools.filter( (tool) => validatedConfig[capabilityMap[tool.capability]] ?? false, ); prometheusTools.forEach((tool) => this._registerTool(tool)); }
  • Private helper method that performs all HTTP requests to Prometheus API, handles responses, errors, and logging.
    private async request<T>( endpoint: string, params?: Record<string, string>, ): Promise<T> { const url = new URL(endpoint, this.baseUrl); const queryParams = new URLSearchParams(params); if (queryParams) { url.search = queryParams.toString(); } logger.debug("making prometheus request", { endpoint, url }); try { const response = await fetch(url.toString(), { method: "GET", headers: this.headers, }); if (!response.ok) { const error = `http ${response.status}: ${response.statusText}`; logger.error(error, { endpoint, status: response.status }); throw new Error(error); } const result: Response<T> = await response.json(); if (result.status !== "success") { const errorMsg = result.error || "unknown error"; const error = `prometheus api error: ${errorMsg}`; logger.error(error, { endpoint, status: result.status }); throw new Error(error); } logger.debug("prometheus request successful", { endpoint }); return result.data; } catch (error) { logger.error("prometheus request failed", { endpoint, error: error instanceof Error ? error.message : String(error), }); throw error; }

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