Skip to main content
Glama
agarwalvivek29

OpenTelemetry MCP Server

query_prometheus_range

Retrieve Prometheus metrics over specified time ranges using PromQL queries to analyze historical performance data and identify trends.

Instructions

Execute PromQL query over a time range. Returns time series data. Use this for getting metrics over time.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesPromQL query string
startNoStart time. Can be: relative like '1h' (last hour), '30m', '7d', or absolute RFC3339/Unix timestamp. Default: 1h ago
endNoEnd time. Can be: 'now', relative, or absolute. Default: now
stepNoQuery resolution step (e.g., '15s', '1m', '5m'). Default: 15s

Implementation Reference

  • The implementation of the `query_prometheus_range` function in `prometheus_tools.py`. It handles range query execution, time parsing, and error reporting.
    async def query_prometheus_range(
        client: PrometheusClient,
        query: str,
        start: Optional[str] = None,
        end: Optional[str] = None,
        step: str = "15s"
    ) -> Dict[str, Any]:
        """
        Execute PromQL range query.
        
        Args:
            client: Prometheus client
            query: PromQL query string
            start: Start time (relative like '1h' or absolute)
            end: End time (relative like 'now' or absolute)
            step: Query resolution step
            
        Returns:
            Query results with time series data
        """
        try:
            # Parse time range
            start_dt, end_dt = parse_time_range(start, end)
            start_ts = to_prometheus_time(start_dt)
            end_ts = to_prometheus_time(end_dt)
            
            result = await client.query_range(query, start_ts, end_ts, step)
            
            return {
                "success": True,
                "query": query,
                "start": start or "auto",
                "end": end or "now",
                "step": step,
                "result": result
            }
        except Exception as e:
            logger.error(f"Error executing Prometheus range query: {e}")
            return {
                "success": False,
                "error": str(e),
                "query": query
            }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool returns time series data, which is useful, but doesn't cover critical aspects like authentication requirements, rate limits, error handling, or performance implications. For a query tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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 extremely concise and front-loaded: two sentences that directly state the tool's function and usage. Every word earns its place with zero waste, making it easy for an AI agent to parse quickly.

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

Completeness2/5

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

Given the complexity of a PromQL query tool with no annotations and no output schema, the description is incomplete. It lacks details on return format (e.g., structure of time series data), error cases, or prerequisites. While concise, it doesn't provide enough context for safe and effective use without additional assumptions.

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%, meaning the input schema fully documents all parameters. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain query syntax or step resolution trade-offs). With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but also doesn't detract.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Execute PromQL query over a time range. Returns time series data.' It specifies the verb (execute), resource (PromQL query), and scope (time range). However, it doesn't explicitly differentiate from sibling tools like 'query_prometheus' (which likely handles instant queries), so it misses the highest score.

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

Usage Guidelines3/5

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

The description provides implied usage guidance: 'Use this for getting metrics over time.' This suggests when to use it (for time-series metrics) but doesn't explicitly state when not to use it or name alternatives like 'query_prometheus' for instant queries. It offers basic context but lacks explicit exclusions or sibling comparisons.

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