> ## Documentation Index
> Fetch the complete documentation index at: https://www.truefoundry.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Metrics: Timeseries Examples

> Timeseries query examples for Gateway MCP metrics API

## Timeseries queries

Time-bucketed MCP metrics over a window. Every timeseries query must include `interval` (or the deprecated `intervalInSeconds`). Each 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](/docs/ai-gateway/fetch-mcp-metrics#quick-start).

<Note>
  MCP metrics include all JSON-RPC methods by default. Pin the tool-call subset with `{"fieldName": "method", "operator": "IN", "value": ["tools/call"]}` when you want `toolName` populated.
</Note>

<AccordionGroup>
  <Accordion title="Hourly request volume">
    Total MCP requests per hour:

    ```python theme={"dark"}
    json={
        "startTs": "2026-04-21T00:00:00.000Z",
        "endTs": "2026-04-22T00:00:00.000Z",
        "datasource": "mcpMetrics",
        "type": "timeseries",
        "interval": "1 hour",
        "aggregations": [
            {"type": "count", "column": "mcpServerName"}
        ]
    }
    ```
  </Accordion>

  <Accordion title="Hourly tool-call counts">
    Hourly tool calls grouped by tool:

    ```python theme={"dark"}
    json={
        "startTs": "2026-04-21T00:00:00.000Z",
        "endTs": "2026-04-22T00:00:00.000Z",
        "datasource": "mcpMetrics",
        "type": "timeseries",
        "interval": "1 hour",
        "aggregations": [
            {"type": "count", "column": "toolName"}
        ],
        "groupBy": ["toolName"],
        "filters": [
            {"fieldName": "method", "operator": "IN", "value": ["tools/call"]}
        ]
    }
    ```
  </Accordion>

  <Accordion title="Hourly p99 latency by server">
    Track regressions per server, bucket-by-bucket:

    ```python theme={"dark"}
    json={
        "startTs": "2026-04-21T00:00:00.000Z",
        "endTs": "2026-04-22T00:00:00.000Z",
        "datasource": "mcpMetrics",
        "type": "timeseries",
        "interval": "1 hour",
        "aggregations": [
            {"type": "p99", "column": "latencyMs"}
        ],
        "groupBy": ["mcpServerName"]
    }
    ```
  </Accordion>

  <Accordion title="Hourly method mix">
    Volume per JSON-RPC method over time:

    ```python theme={"dark"}
    json={
        "startTs": "2026-04-21T00:00:00.000Z",
        "endTs": "2026-04-22T00:00:00.000Z",
        "datasource": "mcpMetrics",
        "type": "timeseries",
        "interval": "1 hour",
        "aggregations": [
            {"type": "count", "column": "method"}
        ],
        "groupBy": ["method"]
    }
    ```
  </Accordion>

  <Accordion title="5-minute traffic on a specific server">
    Fine-grained tool-call traffic on one server:

    ```python theme={"dark"}
    json={
        "startTs": "2026-04-21T00:00:00.000Z",
        "endTs": "2026-04-21T06:00:00.000Z",
        "datasource": "mcpMetrics",
        "type": "timeseries",
        "interval": "5 minute",
        "aggregations": [
            {"type": "count", "column": "toolName"},
            {"type": "p99", "column": "latencyMs"}
        ],
        "groupBy": ["toolName"],
        "filters": [
            {"fieldName": "method", "operator": "IN", "value": ["tools/call"]},
            {"fieldName": "mcpServerName", "operator": "IN", "value": ["github-mcp"]}
        ]
    }
    ```
  </Accordion>

  <Accordion title="Daily traffic over a week">
    Daily tool-call volume across a 7-day window:

    ```python theme={"dark"}
    json={
        "startTs": "2026-04-14T00:00:00.000Z",
        "endTs": "2026-04-21T00:00:00.000Z",
        "datasource": "mcpMetrics",
        "type": "timeseries",
        "interval": "1 day",
        "aggregations": [
            {"type": "count", "column": "toolName"}
        ],
        "filters": [
            {"fieldName": "method", "operator": "IN", "value": ["tools/call"]}
        ]
    }
    ```
  </Accordion>

  <Accordion title="Hourly counts by team">
    Per-team tool-call usage over time:

    ```python theme={"dark"}
    json={
        "startTs": "2026-04-21T00:00:00.000Z",
        "endTs": "2026-04-22T00:00:00.000Z",
        "datasource": "mcpMetrics",
        "type": "timeseries",
        "interval": "1 hour",
        "aggregations": [
            {"type": "count", "column": "toolName"}
        ],
        "groupBy": ["team"],
        "filters": [
            {"fieldName": "method", "operator": "IN", "value": ["tools/call"]},
            {"fieldName": "team", "operator": "ARRAY_HAS_ANY", "value": ["team-alpha", "team-beta"]}
        ]
    }
    ```
  </Accordion>

  <Accordion title="Complex timeseries query">
    Multiple filters and grouping together:

    ```python theme={"dark"}
    json={
        "startTs": "2026-04-21T00:00:00.000Z",
        "endTs": "2026-04-22T00:00:00.000Z",
        "datasource": "mcpMetrics",
        "type": "timeseries",
        "interval": "1 hour",
        "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"]},
            {"metadataKey": "environment", "operator": "IN", "value": ["production"]}
        ]
    }
    ```
  </Accordion>
</AccordionGroup>
