> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-3a82795f.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Evaluates a prometheus query using data from a TimeSeries table.

# prometheusQueryRange

Evaluates a prometheus query using data from a TimeSeries table over a range of evaluation times.

<h2 id="syntax">
  Syntax
</h2>

```sql theme={null}
prometheusQueryRange('db_name', 'time_series_table', 'promql_query', start_time, end_time, step)
prometheusQueryRange(db_name.time_series_table, 'promql_query', start_time, end_time, step)
prometheusQueryRange('time_series_table', 'promql_query', start_time, end_time, step)
```

<h2 id="arguments">
  Arguments
</h2>

* `db_name` - The name of the database where a TimeSeries table is located.
* `time_series_table` - The name of a TimeSeries table.
* `promql_query` - A query written in [PromQL syntax](https://prometheus.io/docs/prometheus/latest/querying/basics/).
* `start_time` - The start time of the evaluation range.
* `end_time` - The end time of the evaluation range.
* `step` - The step used to iterate the evaluation time from `start_time` to `end_time` (inclusively).

<h2 id="returned_value">
  Returned value
</h2>

The function can returns different columns depending on the result type of the query passed to parameter `promql_query`:

| Result Type | Result Columns                                                                         | Example                             |
| ----------- | -------------------------------------------------------------------------------------- | ----------------------------------- |
| vector      | tags Array(Tuple(String, String)), timestamp TimestampType, value ValueType            | prometheusQuery(mytable, 'up')      |
| matrix      | tags Array(Tuple(String, String)), time\_series Array(Tuple(TimestampType, ValueType)) | prometheusQuery(mytable, 'up\[1m]') |
| scalar      | scalar ValueType                                                                       | prometheusQuery(mytable, '1h30m')   |
| string      | string String                                                                          | prometheusQuery(mytable, '"abc"')   |

<h2 id="example">
  Example
</h2>

```sql theme={null}
SELECT * FROM prometheusQueryRange(mytable, 'rate(http_requests{job="prometheus"}[10m])[1h:10m]', now() - INTERVAL 10 MINUTES, now(), INTERVAL 1 MINUTE)
```
