grafana_fetch_label_values
Retrieve available label values for dashboard variables from Prometheus data sources. Use this tool to fetch values for specific labels like 'instance' or 'job' to populate dynamic dashboard filters.
Instructions
Fetches label values for dashboard variables from Prometheus datasource. Retrieves available values for specific labels (e.g., 'instance', 'job').
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| datasource_uid | Yes | Prometheus datasource UID | |
| label_name | Yes | Label name to fetch values for (e.g., 'instance', 'job') | |
| metric_match_filter | No | Optional metric name filter (e.g., 'up', 'node_cpu_seconds_total') |
Implementation Reference
- The handler function grafana_fetch_label_values that orchestrates fetching label values using the grafana_processor.
def grafana_fetch_label_values(datasource_uid, label_name, metric_match_filter=None): """Fetch label values for dashboard variables from Prometheus datasource""" try: grafana_processor = current_app.config.get("grafana_processor") if not grafana_processor: return { "status": "error", "message": "Grafana processor not initialized. Check configuration.", } result = grafana_processor.grafana_fetch_dashboard_variable_label_values(datasource_uid, label_name, metric_match_filter) return result except Exception as e: logger.error(f"Error fetching label values: {e!s}") return {"status": "error", "message": f"Failed to fetch label values: {e!s}"} - src/grafana_mcp_server/mcp_server.py:216-235 (registration)Registration of the grafana_fetch_label_values tool in the MCP server definition.
"name": "grafana_fetch_label_values", "description": "Fetches label values for dashboard variables from Prometheus datasource. " "Retrieves available values for specific labels (e.g., 'instance', 'job').", "inputSchema": { "type": "object", "properties": { "datasource_uid": { "type": "string", "description": "Prometheus datasource UID", }, "label_name": { "type": "string", "description": "Label name to fetch values for (e.g., 'instance', 'job')", }, "metric_match_filter": { "type": "string", "description": "Optional metric name filter (e.g., 'up', 'node_cpu_seconds_total')", }, }, "required": ["datasource_uid", "label_name"],