メインコンテンツまでスキップ
メインコンテンツまでスキップ

prometheusQuery テーブル関数

TimeSeries テーブルからのデータを使用して、評価時間の範囲で prometheus クエリを評価します。

構文

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)

引数

  • db_name - TimeSeries テーブルが存在するデータベースの名前。
  • time_series_table - TimeSeries テーブルの名前。
  • promql_query - PromQL 構文で書かれたクエリ。
  • start_time - 評価範囲の開始時間。
  • end_time - 評価範囲の終了時間。
  • step - start_time から end_time まで(含む)評価時間を反復するために使用されるステップ。

戻り値

この関数は、パラメータ promql_query に渡されたクエリの結果タイプに応じて異なるカラムを返すことができます。

結果タイプ結果カラム
vectortags Array(Tuple(String, String)), timestamp TimestampType, value ValueTypeprometheusQuery(mytable, 'up')
matrixtags Array(Tuple(String, String)), time_series Array(Tuple(TimestampType, ValueType))prometheusQuery(mytable, 'up[1m]')
scalarscalar ValueTypeprometheusQuery(mytable, '1h30m')
stringstring StringprometheusQuery(mytable, '"abc"')

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