uptrace_search_groups
Search and aggregate spans using GROUP BY operations with functions like count(), avg(), and p99() to analyze trace data in Uptrace.
Instructions
Search and aggregate spans by groups. Supports GROUP BY operations and aggregations like count(), avg(), p99(), etc.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| time_gte | Yes | Start time in ISO format (YYYY-MM-DDTHH:MM:SSZ) | |
| time_lt | Yes | End time in ISO format (YYYY-MM-DDTHH:MM:SSZ) | |
| query | Yes | UQL query with grouping (e.g., 'group by service_name | count()') | |
| limit | No | Maximum number of groups to return (default: 100) |
Implementation Reference
- src/uptrace_mcp/server.py:580-605 (handler)The handler for the uptrace_search_groups tool, which processes the input arguments, calls the Uptrace client, and returns the result.
elif name == "uptrace_search_groups": 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)}")] query = arguments.get("query") limit = arguments.get("limit", 100) if not query: return [TextContent(type="text", text="Error: query is required")] logger.info(f"Querying groups: {query}") result = client.query_spans_groups( time_gte=time_gte, time_lt=time_lt, query=query, limit=limit ) import json return [ TextContent( type="text", text=f"# Groups Query Results\n\n```json\n{json.dumps(result, indent=2)}\n```", ) ] - src/uptrace_mcp/server.py:223-242 (schema)The schema definition for the uptrace_search_groups tool.
Tool( name="uptrace_search_groups", description="Search and aggregate spans by groups. Supports GROUP BY operations and aggregations like count(), avg(), p99(), 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)", }, "query": { "type": "string", "description": "UQL query with grouping (e.g., 'group by service_name | count()')", }, "limit": { "type": "integer",