list_pyroscope_label_values
Retrieve all available label values for a specific label name within profiling data, enabling targeted analysis of application performance metrics across defined time ranges.
Instructions
Lists all available label values for a particular label name in profiles
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data_source_uid | Yes | The UID of the datasource to query | |
| end_rfc_3339 | No | End time in RFC3339 format | |
| matchers | No | Prometheus-style matchers | |
| name | Yes | A label name | |
| start_rfc_3339 | No | Start time in RFC3339 format |
Implementation Reference
- src/tools/pyroscope.ts:98-126 (handler)Full ToolDefinition for 'list_pyroscope_label_values' including the inline handler function that queries the Pyroscope API (/pyroscope/api/v1/label-values) for label values using axios.export const listPyroscopeLabelValues: ToolDefinition = { name: 'list_pyroscope_label_values', description: 'Lists all available label values for a particular label name in profiles', inputSchema: ListPyroscopeLabelValuesSchema, handler: async (params, context: ToolContext) => { try { const client = createPyroscopeClient(context.config.grafanaConfig, params.data_source_uid); const timeRange = params.start_rfc_3339 || params.end_rfc_3339 ? { start: '', end: '' } : getDefaultTimeRange(); const queryParams: any = { label: params.name, start: params.start_rfc_3339 || timeRange.start, end: params.end_rfc_3339 || timeRange.end, }; if (params.matchers) { queryParams.matchers = params.matchers; } const response = await client.get('/pyroscope/api/v1/label-values', { params: queryParams }); return createToolResult(response.data.data || []); } catch (error: any) { return createErrorResult(error.response?.data?.message || error.message); } }, };
- src/tools/pyroscope.ts:13-19 (schema)Zod schema defining the input parameters for the list_pyroscope_label_values tool.const ListPyroscopeLabelValuesSchema = z.object({ data_source_uid: z.string().describe('The UID of the datasource to query'), name: z.string().describe('A label name'), start_rfc_3339: z.string().optional().describe('Start time in RFC3339 format'), end_rfc_3339: z.string().optional().describe('End time in RFC3339 format'), matchers: z.string().optional().describe('Prometheus-style matchers'), });
- src/tools/pyroscope.ts:198-203 (registration)Registration function that registers all Pyroscope tools with the MCP server, including listPyroscopeLabelValues.export function registerPyroscopeTools(server: any) { server.registerTool(listPyroscopeLabelNames); server.registerTool(listPyroscopeLabelValues); server.registerTool(listPyroscopeProfileTypes); server.registerTool(fetchPyroscopeProfile); }
- src/tools/pyroscope.ts:37-53 (helper)Helper function to create an authenticated axios client for querying a Pyroscope datasource via Grafana proxy.function createPyroscopeClient(config: any, datasourceUid: string) { const headers: any = { 'User-Agent': 'mcp-grafana/1.0.0', }; if (config.serviceAccountToken) { headers['Authorization'] = `Bearer ${config.serviceAccountToken}`; } else if (config.apiKey) { headers['Authorization'] = `Bearer ${config.apiKey}`; } return axios.create({ baseURL: `${config.url}/api/datasources/proxy/uid/${datasourceUid}`, headers, timeout: 30000, }); }
- src/tools/pyroscope.ts:56-63 (helper)Helper function providing default time range (last hour) for queries when not specified.function getDefaultTimeRange(): { start: string; end: string } { const now = new Date(); const oneHourAgo = new Date(now.getTime() - 60 * 60 * 1000); return { start: oneHourAgo.toISOString(), end: now.toISOString(), }; }