跳转到主要内容
使用 TimeSeries 表中的数据计算 Prometheus 查询结果。

语法

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)

参数

  • db_name - TimeSeries 表所在的数据库名称。
  • time_series_table - TimeSeries 表的名称。
  • promql_query - 使用 PromQL 语法 编写的查询。
  • evaluation_time - 求值时间戳。要在当前时间对查询进行求值,请使用 now()作为evaluation_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 prometheusQuery(mytable, 'rate(http_requests{job="prometheus"}[10m])[1h:10m]', now())
最后修改于 2026年6月10日