Skip to main content
Glama

prometheus_list_labels

Discover all available Prometheus labels to identify and filter metrics for monitoring queries and analysis.

Instructions

List all available Prometheus labels

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Implements the core logic of the prometheus_list_labels tool by making an HTTP GET request to the Prometheus /api/v1/labels endpoint via the private request method, returning a list of label names.
    async listLabels(): Promise<Labels> { const endpoint = "/api/v1/labels"; return this.request<Labels>(endpoint); }
  • Registers the 'prometheus_list_labels' tool in the tools array, defining its metadata, empty input schema, and handler that delegates to PrometheusClient.listLabels().
    capability: "discovery", name: "prometheus_list_labels", title: "List Prometheus Labels", description: "List all available Prometheus labels", inputSchema: EmptySchema, type: "readonly", handle: async (client: PrometheusClient) => client.listLabels(), }),
  • Defines the empty input schema (no parameters required) used by the prometheus_list_labels tool.
    const EmptySchema = z.object({});
  • Private helper method in PrometheusClient that handles all HTTP requests to Prometheus API, used by listLabels() including URL construction, fetch, status checks, JSON parsing, and comprehensive error handling/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