list_labels
Discover available label names in Prometheus metrics to identify filtering options for data analysis and troubleshooting.
Instructions
Get all label names available in Prometheus. Use this to discover what labels you can filter by.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| metric | No | Optional metric name to get labels for |
Implementation Reference
- src/tools/prometheus_tools.py:184-216 (handler)The actual implementation of the 'list_labels' tool, which queries Prometheus for label names.
async def list_labels( client: PrometheusClient, metric: Optional[str] = None ) -> Dict[str, Any]: """ Get all label names in Prometheus. Args: client: Prometheus client metric: Optional metric to get labels for Returns: List of label names """ try: match = [f"{{{metric}}}"] if metric else None result = await client.labels(match) if result.get("status") == "success": labels = result.get("data", []) return { "success": True, "count": len(labels), "labels": labels } else: return { "success": False, "error": "Failed to fetch labels" } except Exception as e: logger.error(f"Error listing labels: {e}") return {