Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

prometheusQuery

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 - 평가 시각의 타임스탬프입니다. 현재 시각을 기준으로 쿼리를 평가하려면 evaluation_timenow()`를 사용합니다.

반환 값

함수는 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"')

지원되는 PromQL 기능

셀렉터

인스턴트 셀렉터, 범위 셀렉터, 레이블 매처(=, !=, =~, !~), offset 수정자, @ 타임스탬프 수정자, 서브쿼리.

함수

범주 함수
범위 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 예외와 함께 거부됩니다.

연산자

on()/ignoring()group_left()/group_right() 수정자와 함께 사용하는 산술(+, -, *, /, %, ^, atan2) 및 비교(==, !=, <, >, <=, >=, 선택적 bool 포함) 이항 연산자입니다.

on()/ignoring() 수정자와 함께 사용하는 논리 집합 연산자 and, or, unless입니다.

단항 연산자 +-.

집계 연산자

sum, avg, min, max, count, stddev, stdvar, group, quantile, topk, bottomk, limitk — 선택적으로 by() 또는 without() 수정자와 함께 사용할 수 있습니다.

아직 지원되지 않는 기능

  • 집계 연산자 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

예시

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