Skip to main content

Distribution queries

Aggregated snapshots of MCP metrics over a time window. Every example below posts JSON to:
POST https://{your_control_plane_url}/api/svc/v1/llm-gateway/metrics/query
with Authorization: Bearer <your_api_key> and Content-Type: application/json. To keep the snippets short, only the JSON body is shown; the wrapper is identical to the Overview Quick Start.
MCP metrics include all JSON-RPC methods by default. Many of the examples below pin the tool-call subset with {"fieldName": "method", "operator": "IN", "value": ["tools/call"]} so toolName is populated.
Count requests per server, alongside p99 latency:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "mcpMetrics",
    "type": "distribution",
    "aggregations": [
        {"type": "count", "column": "mcpServerName"},
        {"type": "p99", "column": "latencyMs"}
    ],
    "groupBy": ["mcpServerName"]
}
Restrict to tools/call and group by toolName:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "mcpMetrics",
    "type": "distribution",
    "aggregations": [
        {"type": "count", "column": "toolName"}
    ],
    "groupBy": ["toolName"],
    "filters": [
        {"fieldName": "method", "operator": "IN", "value": ["tools/call"]}
    ]
}
Traffic mix per server (initialize / tools/list / tools/call / …):
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "mcpMetrics",
    "type": "distribution",
    "aggregations": [
        {"type": "count", "column": "method"}
    ],
    "groupBy": ["mcpServerName", "method"]
}
p50, p90, and p99 latency per tool:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "mcpMetrics",
    "type": "distribution",
    "aggregations": [
        {"type": "p50", "column": "latencyMs"},
        {"type": "p90", "column": "latencyMs"},
        {"type": "p99", "column": "latencyMs"}
    ],
    "groupBy": ["toolName"],
    "filters": [
        {"fieldName": "method", "operator": "IN", "value": ["tools/call"]}
    ]
}
How many unique tools each server exposed:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "mcpMetrics",
    "type": "distribution",
    "aggregations": [
        {"type": "countDistinct", "column": "toolName"}
    ],
    "groupBy": ["mcpServerName"],
    "filters": [
        {"fieldName": "method", "operator": "IN", "value": ["tools/call"]}
    ]
}
Count tool calls excluding internal/debug tools using NOT_IN:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "mcpMetrics",
    "type": "distribution",
    "aggregations": [
        {"type": "count", "column": "toolName"}
    ],
    "groupBy": ["toolName"],
    "filters": [
        {"fieldName": "method", "operator": "IN", "value": ["tools/call"]},
        {"fieldName": "toolName", "operator": "NOT_IN", "value": ["internal-debug", "healthcheck", "echo"]}
    ]
}
Find slow tool calls (above 5 seconds):
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "mcpMetrics",
    "type": "distribution",
    "aggregations": [
        {"type": "count", "column": "toolName"}
    ],
    "groupBy": ["mcpServerName", "toolName"],
    "filters": [
        {"fieldName": "method", "operator": "IN", "value": ["tools/call"]},
        {"fieldName": "latencyMs", "operator": "GREATER_THAN", "value": 5000}
    ]
}
Tool-call counts per metadata key:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "mcpMetrics",
    "type": "distribution",
    "aggregations": [
        {"type": "count", "column": "toolName"}
    ],
    "groupBy": ["toolName", "metadata.environment"],
    "filters": [
        {"fieldName": "method", "operator": "IN", "value": ["tools/call"]}
    ]
}
Tool-call activity scoped to a team:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "mcpMetrics",
    "type": "distribution",
    "aggregations": [
        {"type": "count", "column": "toolName"}
    ],
    "groupBy": ["mcpServerName"],
    "filters": [
        {"fieldName": "method", "operator": "IN", "value": ["tools/call"]},
        {"fieldName": "team", "operator": "ARRAY_HAS_ANY", "value": ["team-alpha"]}
    ]
}
Tool-call traffic on a known list of servers, latency window, scoped to a team:
json={
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "mcpMetrics",
    "type": "distribution",
    "aggregations": [
        {"type": "count", "column": "toolName"},
        {"type": "p99", "column": "latencyMs"}
    ],
    "groupBy": ["mcpServerName", "toolName"],
    "filters": [
        {"fieldName": "method", "operator": "IN", "value": ["tools/call"]},
        {"fieldName": "mcpServerName", "operator": "IN", "value": ["github-mcp", "atlassian-mcp"]},
        {"fieldName": "latencyMs", "operator": "BETWEEN", "value": [100, 10000]},
        {"fieldName": "team", "operator": "ARRAY_HAS_ANY", "value": ["team-alpha"]}
    ]
}