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

> TimeSeries 테이블의 데이터를 사용해 prometheus 쿼리를 평가합니다.

# prometheusQuery

TimeSeries 테이블의 데이터를 사용해 prometheus 쿼리를 평가합니다.

## 구문

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

## 인수

* `db_name` - TimeSeries 테이블이 있는 데이터베이스 이름입니다.
* `time_series_table` - TimeSeries 테이블 이름입니다.
* `promql_query` - [PromQL 구문](https://prometheus.io/docs/prometheus/latest/querying/basics/)으로 작성한 쿼리입니다.
* `evaluation_time - 평가 시각의 타임스탬프입니다. 현재 시각을 기준으로 쿼리를 평가하려면 `evaluation\_time`에 `now()\`를 사용합니다.

## 반환 값

함수는 `promql_query` 매개변수에 전달된 쿼리의 결과 유형에 따라 반환하는 컬럼이 달라질 수 있습니다:

| 결과 유형 | 결과 컬럼 | 예시 |
| - | - | - |
| vector | tags Array(Tuple(String, String)), timestamp TimestampType, value ValueType | prometheusQuery(mytable, 'up') |
| matrix | tags Array(Tuple(String, String)), samples Array(Tuple(TimestampType, ValueType)) | prometheusQuery(mytable, 'up\[1m]') |
| scalar | scalar ValueType | prometheusQuery(mytable, '1h30m') |
| string | string String | prometheusQuery(mytable, '"abc"') |

`TimeSeries` 테이블의 [version](/ko/reference/engines/table-engines/integrations/time-series#schema-versioning)이 2 이하인 경우 `samples` 컬럼의 이름은 `time_series`가 됩니다.

## 지원되는 PromQL 기능

### 셀렉터

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

### 함수

| 범주 | 함수 |
| - | - |
| 범위 | `rate`, `irate`, `delta`, `idelta`, `increase`, `last_over_time`, `sum_over_time`, `avg_over_time`, `count_over_time`, `max_over_time`, `min_over_time`, `ts_of_max_over_time`, `ts_of_min_over_time`, `deriv`, `changes`, `resets`, `present_over_time`, `absent_over_time`, `quantile_over_time`, `predict_linear` |
| 수학 | `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`, `absent` |

**참고**: `histogram_quantile`은 클래식 히스토그램 버킷(`le` 레이블로 식별됨)에 선형 보간을 사용합니다. 네이티브 히스토그램은 지원되지 않습니다. `phi`(분위수 수준) 인수는 상수 스칼라여야 합니다. `histogram_quantile(time() / 1000, ...)`처럼 각 간격마다 달라지는 표현식은 `NOT_IMPLEMENTED` 예외와 함께 거부됩니다.

**참고**: `ts_of_min_over_time` 및 `ts_of_max_over_time`은 Prometheus의 실험적 함수입니다(Prometheus에서는 `--enable-feature=promql-experimental-functions` 플래그로 활성화됨). ClickHouse는 이 플래그 없이도 이를 평가합니다.

### 연산자

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

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

단항 연산자 `+` 및 `-`.

### 집계 연산자

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

### 아직 지원되지 않는 기능

* 범위 함수 `stddev_over_time`, `stdvar_over_time`, `mad_over_time`, `first_over_time`, `ts_of_last_over_time`, `ts_of_first_over_time`

## 예시

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