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

# Guardrail Metrics: Timeseries Examples

> Timeseries query examples for Gateway guardrail metrics API

## Timeseries queries

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

<AccordionGroup>
  <Accordion title="Hourly evaluation volume">
    Total guardrail evaluations per hour:

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

  <Accordion title="Hourly p99 latency by scope">
    Track p99 evaluation latency per scope (input / output) bucket-by-bucket:

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

  <Accordion title="Hourly failures per guardrail">
    Track per-guardrail failure rate over time:

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

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

    ```python theme={"dark"}
    json={
        "startTs": "2026-04-21T14:00:00.000Z",
        "endTs": "2026-04-21T16:00:00.000Z",
        "datasource": "guardrailMetrics",
        "type": "timeseries",
        "interval": "5 minute",
        "aggregations": [
            {"type": "p99", "column": "latencyMs"}
        ],
        "groupBy": ["guardrailName"]
    }
    ```
  </Accordion>

  <Accordion title="Daily evaluations over a week">
    Daily evaluation volume per guardrail across a 7-day window:

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

  <Accordion title="Hourly p99 latency for specific guardrails">
    Focus on a few guardrails of interest:

    ```python theme={"dark"}
    json={
        "startTs": "2026-04-21T00:00:00.000Z",
        "endTs": "2026-04-22T00:00:00.000Z",
        "datasource": "guardrailMetrics",
        "type": "timeseries",
        "interval": "1 hour",
        "aggregations": [
            {"type": "p99", "column": "latencyMs"}
        ],
        "groupBy": ["guardrailName"],
        "filters": [
            {"fieldName": "guardrailName", "operator": "IN", "value": ["pii-detector", "toxicity-filter"]}
        ]
    }
    ```
  </Accordion>

  <Accordion title="Hourly volume by team">
    Per-team guardrail activity over time:

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