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
            }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses the query type (instant) and return semantics (metric values at a point in time), which is useful. However, it lacks details on error handling, rate limits, authentication needs, or response format, which are important for a query tool with potential complexity.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two concise sentences with zero waste. The first sentence states the action and resource, and the second clarifies the return value and temporal scope. Every word earns its place, making it highly efficient and front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a query tool with no annotations and no output schema, the description is minimally adequate. It covers the core purpose and distinguishes from siblings, but lacks details on behavioral traits (e.g., error cases, performance implications) and output structure, which could hinder an agent's ability to use it correctly in complex scenarios.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents both parameters. The description doesn't add any parameter-specific details beyond what the schema provides (e.g., no examples of valid 'time' formats beyond what's in the schema). Baseline 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Execute raw PromQL instant query') and resource ('against Prometheus'), distinguishing it from siblings like 'query_prometheus_range' (instant vs range queries) and 'query_loki' (Prometheus vs Loki). It explicitly defines the return value ('metric values at a specific point in time'), making the purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context by specifying this is for 'instant query' and 'at a specific point in time', which implicitly distinguishes it from 'query_prometheus_range' for range queries. However, it doesn't explicitly state when NOT to use this tool or mention alternatives like 'list_metrics' for discovery, leaving some guidance gaps.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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