> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-trino-dialect.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="supported-promql-features">
  ## PromQL でサポートされている機能
</div>

<div id="selectors">
  ### セレクタ
</div>

インスタントセレクタ、レンジセレクタ、ラベルマッチャー (`=`、`!=`、`=~`、`!~`) 、OFFSET修飾子、`@`タイムスタンプ修飾子、サブクエリ。

<div id="functions">
  ### 関数
</div>

| カテゴリ     | 関数                                                                                                                            |
| -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| 範囲       | `rate`, `irate`, `delta`, `idelta`, `increase`, `last_over_time`, `deriv`, `changes`, `resets`                                |
| 数学       | `abs`, `sgn`, `floor`, `ceil`, `sqrt`, `exp`, `ln`, `log2`, `log10`, `rad`, `deg`, `round`, `clamp`, `clamp_min`, `clamp_max` |
| 三角関数     | `sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `sinh`, `cosh`, `tanh`, `asinh`, `acosh`, `atanh`                                |
| DateTime | `day_of_week`, `day_of_month`, `days_in_month`, `day_of_year`, `minute`, `hour`, `month`, `year`                              |
| ラベル      | `label_replace`, `label_join`                                                                                                 |
| 型        | `scalar`, `vector`                                                                                                            |
| ヒストグラム   | `histogram_quantile`                                                                                                          |
| その他      | `time`, `pi`                                                                                                                  |

**注記**: `histogram_quantile` は、従来のヒストグラムのバケット (`le` ラベルで識別) に対して線形補間を使用します。ネイティブヒストグラムはサポートされていません。`phi` (分位点レベル) 引数は定数スカラーである必要があります。`histogram_quantile(time() / 1000, ...)` のようにステップごとに変化する式は、`NOT_IMPLEMENTED` 例外で拒否されます。

<div id="operators">
  ### 演算子
</div>

`on()`/`ignoring()` および `group_left()`/`group_right()` 修飾子を含む、算術 (`+`, `-`, `*`, `/`, `%`, `^`, `atan2`) および比較 (省略可能な `bool` を伴う `==`, `!=`, `<`, `>`, `<=`, `>=`) 二項演算子。

`on()`/`ignoring()` 修飾子を含む、論理 Set 演算子 `and`、`or`、`unless`。

単項演算子 `+` と `-`。

<div id="aggregation-operators">
  ### 集計演算子
</div>

`sum`, `avg`, `min`, `max`, `count`, `stddev`, `stdvar`, `group`, `quantile`, `topk`, `bottomk`, `limitk` — オプションで `by()` または `without()` 修飾子を使用できます。

<div id="not-yet-supported">
  ### 未サポート
</div>

* 集計演算子 `count_values`
* 範囲関数 `predict_linear`, `avg_over_time`, `min_over_time`, `max_over_time`, `sum_over_time`, `count_over_time`, `quantile_over_time`, `stddev_over_time`, `stdvar_over_time`, `present_over_time`, `absent_over_time`, `mad_over_time`, `first_over_time`, `ts_of_min_over_time`, `ts_of_max_over_time`, `ts_of_last_over_time`, `ts_of_first_over_time`
* 関数 `absent`

<div id="example">
  ## 例
</div>

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