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

> Выполняет Prometheus-запрос по данным из таблицы TimeSeries.

# prometheusQuery

Выполняет Prometheus-запрос по данным из таблицы TimeSeries.

<div id="syntax">
  ## Синтаксис
</div>

```sql theme={null}
prometheusQuery('db_name', 'time_series_table', 'promql_query', evaluation_time)
prometheusQuery(db_name.time_series_table, 'promql_query', evaluation_time)
prometheusQuery('time_series_table', 'promql_query', evaluation_time)
```

<div id="arguments">
  ## Аргументы
</div>

* `db_name` - Имя базы данных, в которой находится таблица TimeSeries.
* `time_series_table` - Имя таблицы TimeSeries.
* `promql_query` - Запрос, написанный в [синтаксисе PromQL](https://prometheus.io/docs/prometheus/latest/querying/basics/).
* `evaluation_time - Временная метка вычисления. Чтобы вычислить запрос на текущий момент, используйте `now()`в качестве`evaluation\_time\`.

<div id="returned_value">
  ## Возвращаемое значение
</div>

Функция может возвращать разные столбцы в зависимости от типа результата запроса, переданного через параметр `promql_query`:

| Тип результата | Столбцы результата                                                                     | Пример                              |
| -------------- | -------------------------------------------------------------------------------------- | ----------------------------------- |
| 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"')   |

<div id="example">
  ## Пример
</div>

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