Skip to main content
Glama
dimonb

Uptrace MCP Server

by dimonb

uptrace_query_metrics

Retrieve and analyze system metrics like CPU usage and request rates using UQL/PromQL queries with time range filtering and aggregation options.

Instructions

Query metrics using UQL/PromQL-compatible syntax. Use this to retrieve metric values like CPU usage, request rates, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
time_gteYesStart time in ISO format (YYYY-MM-DDTHH:MM:SSZ)
time_ltYesEnd time in ISO format (YYYY-MM-DDTHH:MM:SSZ)
metricsYesList of metric definitions with aliases (e.g., ['system_cpu_utilization as $cpu'])
queryYesList of query expressions (e.g., ['avg($cpu) as cpu_avg'])
group_byNoOptional list of attributes to group by
limitNoMaximum number of results (default: 100)

Implementation Reference

  • The handler logic for 'uptrace_query_metrics' that processes arguments, calls the Uptrace client, and returns formatted text content.
    elif name == "uptrace_query_metrics":
        try:
            time_gte = parse_datetime(arguments["time_gte"])
            time_lt = parse_datetime(arguments["time_lt"])
        except (KeyError, ValueError) as e:
            return [TextContent(type="text", text=f"Error: {str(e)}")]
    
        metrics = arguments.get("metrics")
        query = arguments.get("query")
        group_by = arguments.get("group_by")
        limit = arguments.get("limit", 100)
    
        logger.info(f"Querying metrics: {metrics}")
    
        if group_by:
            result = client.query_metrics_groups(
                time_gte=time_gte,
                time_lt=time_lt,
                metrics=metrics,
                query=query,
                group_by=group_by,
                limit=limit,
            )
        else:
            result = client.query_metrics(
                time_gte=time_gte, time_lt=time_lt, metrics=metrics, query=query, limit=limit
            )
    
        import json
    
        return [
            TextContent(
                type="text",
                text=f"# Metrics Query Results\n\n```json\n{json.dumps(result, indent=2)}\n```",
            )
        ]
    
    else:
        return [TextContent(type="text", text=f"Unknown tool: {name}")]
  • Tool registration and input schema definition for 'uptrace_query_metrics'.
    Tool(
        name="uptrace_query_metrics",
        description="Query metrics using UQL/PromQL-compatible syntax. Use this to retrieve metric values like CPU usage, request rates, etc.",
        inputSchema={
            "type": "object",
            "properties": {
                "time_gte": {
                    "type": "string",
                    "description": "Start time in ISO format (YYYY-MM-DDTHH:MM:SSZ)",
                },
                "time_lt": {
                    "type": "string",
                    "description": "End time in ISO format (YYYY-MM-DDTHH:MM:SSZ)",
                },
                "metrics": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "List of metric definitions with aliases (e.g., ['system_cpu_utilization as $cpu'])",
                },
                "query": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "List of query expressions (e.g., ['avg($cpu) as cpu_avg'])",
                },
                "group_by": {
Behavior3/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. It discloses the query language compatibility (UQL/PromQL) which is valuable behavioral context, and 'Query'/'retrieve' imply read-only access. However, it lacks details on rate limits, pagination behavior beyond the limit parameter, or authentication requirements.

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?

Two sentences with zero waste. The first establishes capability and syntax; the second provides concrete examples. Every word earns its place and critical information is front-loaded.

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

Completeness4/5

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

Given the moderate complexity (6 parameters, query language), 100% schema coverage, and lack of annotations/output schema, the description adequately covers the tool's domain and syntax. It could be improved by mentioning the read-only nature or result format, but it is sufficient for correct invocation.

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

Parameters4/5

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

With 100% schema description coverage, the baseline is 3. The description adds meaningful context by specifying the UQL/PromQL syntax applies to the query parameter and providing concrete metric examples ('CPU usage') that illuminate the metrics parameter's purpose.

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?

Description specifies the exact action (Query), resource (metrics), and query language (UQL/PromQL). It clearly distinguishes from siblings like uptrace_search_logs or uptrace_get_trace by explicitly targeting 'metrics' rather than logs, traces, or alerts.

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?

Provides concrete usage examples ('CPU usage, request rates') that clarify when to use this tool for metric retrieval. However, it does not explicitly state when NOT to use it or contrast with the sibling uptrace_get_query_syntax tool.

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/dimonb/uptrace-mcp'

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