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

> TimeSeriesテーブルのデータを使用して Prometheus クエリを評価します。

# prometheusQuery

TimeSeriesテーブルのデータを使用して Prometheus クエリを評価します。

<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 - 評価時刻のタイムスタンプ。現在時刻でクエリを評価するには、`evaluation\_time`として`now()\` を使用します。

<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())
```
