Skip to main content
Glama
agarwalvivek29

OpenTelemetry MCP Server

query_prometheus

Execute PromQL instant queries to retrieve metric values at specific times from Prometheus for monitoring and troubleshooting.

Instructions

Execute raw PromQL instant query against Prometheus. Returns metric values at a specific point in time.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesPromQL query string (e.g., 'up{job="api-server"}' or 'rate(http_requests_total[5m])')
timeNoOptional evaluation timestamp. Can be: 'now', relative like '5m', RFC3339, or Unix timestamp

Implementation Reference

  • The handler function `query_prometheus` implementation which takes a client, a PromQL query, and an optional time argument to execute an instant query against Prometheus.
    async def query_prometheus(
        client: PrometheusClient,
        query: str,
        time: Optional[str] = None
    ) -> Dict[str, Any]:
        """
        Execute raw PromQL instant query.
        
        Args:
            client: Prometheus client
            query: PromQL query string
            time: Optional evaluation timestamp
            
        Returns:
            Query results
        """
        try:
            # Parse time if provided
            time_value = None
            if time:
                parsed_time = parse_time(time)
                if parsed_time:
                    time_value = to_prometheus_time(parsed_time)
            
            result = await client.query(query, time_value)
            
            return {
                "success": True,
                "query": query,
                "result": result
            }
        except Exception as e:
            logger.error(f"Error executing Prometheus query: {e}")
            return {
                "success": False,
                "error": str(e),
                "query": query
            }

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