Skip to main content
Glama
agarwalvivek29

OpenTelemetry MCP Server

list_metrics

Discover available Prometheus metrics to identify what data is being collected for monitoring and troubleshooting purposes.

Instructions

List all available metrics in Prometheus. Useful for discovering what metrics are being collected.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
prefixNoOptional prefix to filter metrics (e.g., 'http_', 'cpu_')

Implementation Reference

  • The implementation of the `list_metrics` tool handler.
    async def list_metrics(
        client: PrometheusClient,
        prefix: Optional[str] = None
    ) -> Dict[str, Any]:
        """
        List all available metrics in Prometheus.
        
        Args:
            client: Prometheus client
            prefix: Optional prefix to filter metrics
            
        Returns:
            List of metric names
        """
        try:
            # Query __name__ label to get all metrics
            result = await client.label_values("__name__")
            
            if result.get("status") == "success":
                metrics = result.get("data", [])
                
                # Filter by prefix if provided
                if prefix:
                    metrics = [m for m in metrics if m.startswith(prefix)]
                
                return {
                    "success": True,
                    "count": len(metrics),
                    "metrics": metrics[:1000]  # Limit to prevent huge responses
                }
            else:
                return {
                    "success": False,
                    "error": "Failed to fetch metrics"
                }
        except Exception as e:
            logger.error(f"Error listing metrics: {e}")
            return {
                "success": False,
                "error": str(e)
            }

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/agarwalvivek29/opentelemetry-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server