> ## 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.

# Routing Metrics: Timeseries Examples

> Timeseries query examples for Gateway routing metrics API

## Timeseries queries

Time-bucketed routing 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-routing-metrics#quick-start).

<AccordionGroup>
  <Accordion title="Hourly routing volume by config type">
    Hourly applications per `configType`:

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

  <Accordion title="Hourly average attempts per rule">
    Track loadbalance rule pressure over time:

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

  <Accordion title="Hourly routing volume per requested-to-target pair">
    Useful to confirm a routing change took effect:

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

  <Accordion title="Hourly outcome breakdown">
    Volume per `status` over time:

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

  <Accordion title="5-minute traffic during an incident">
    Fine-grained breakdown to investigate a routing change:

    ```python theme={"dark"}
    json={
        "startTs": "2026-04-21T14:00:00.000Z",
        "endTs": "2026-04-21T16:00:00.000Z",
        "datasource": "configMetrics",
        "type": "timeseries",
        "interval": "5 minute",
        "aggregations": [
            {"type": "sum", "column": "loadbalanceTargetAttemptCount"}
        ],
        "groupBy": ["targetModel"],
        "filters": [
            {"fieldName": "requestedModel", "operator": "IN", "value": ["gpt-4"]}
        ]
    }
    ```
  </Accordion>

  <Accordion title="Daily routings over a week">
    Daily routing 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": "configMetrics",
        "type": "timeseries",
        "interval": "1 day",
        "groupBy": ["configType"]
    }
    ```
  </Accordion>

  <Accordion title="Hourly activity for a specific ratelimit rule">
    Watch a single rule's volume over time:

    ```python theme={"dark"}
    json={
        "startTs": "2026-04-21T00:00:00.000Z",
        "endTs": "2026-04-22T00:00:00.000Z",
        "datasource": "configMetrics",
        "type": "timeseries",
        "interval": "1 hour",
        "groupBy": ["status"],
        "filters": [
            {"fieldName": "ratelimitRuleId", "operator": "IN", "value": ["<rule-id>"]}
        ]
    }
    ```
  </Accordion>
</AccordionGroup>
