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

> 지정된 그리드에서 시계열 데이터의 PromQL 방식 재설정 횟수를 시간에 따라 계산하는 집계 함수입니다.

# timeSeriesResetsToGrid

<div id="timeSeriesResetsToGrid">
  ## timeSeriesResetsToGrid
</div>

도입 버전: v25.6.0

타임스탬프와 값의 쌍으로 이루어진 시계열 데이터를 입력으로 받아, 시작 타임스탬프, 종료 타임스탬프, 간격으로 정의된 일정한 시간 그리드에서 이 데이터의 [PromQL 방식 재설정](https://prometheus.io/docs/prometheus/latest/querying/functions/#resets)를 계산하는 집계 함수입니다. 그리드의 각 지점에서는 지정된 시간 윈도우 내의 샘플을 사용해 `resets`를 계산합니다.

<Note>
  이 함수는 실험적 기능이므로 `allow_experimental_ts_to_grid_aggregate_function=true`를 설정하여 활성화하십시오.
</Note>

**구문**

```sql theme={null}
timeSeriesResetsToGrid(start_timestamp, end_timestamp, grid_step, staleness)(timestamp, value)
```

**매개변수**

* `start_timestamp` — 그리드의 시작 시점을 지정합니다. - `end_timestamp` — 그리드의 끝 시점을 지정합니다. - `grid_step` — 그리드의 간격을 초 단위로 지정합니다. - `staleness` — 고려 대상 샘플의 최대 "staleness"를 초 단위로 지정합니다.

**인수**

* `timestamp` — 샘플의 타임스탬프입니다. 개별 값 또는 배열일 수 있습니다. - `value` — `timestamp`에 해당하는 시계열 값입니다. 개별 값 또는 배열일 수 있습니다.

**반환 값**

지정된 그리드의 `resets` 값을 `Array(Nullable(Float64))`로 반환합니다. 반환된 배열에는 각 시간 그리드 지점마다 값이 하나씩 포함됩니다. 특정 그리드 지점의 `resets` 값을 계산할 윈도우 내에 샘플이 없으면 값은 NULL입니다.

**예시**

**그리드 \[90, 105, 120, 135, 150, 165, 180, 195, 210, 225]에서 `resets` 값을 계산합니다**

```sql title=Query theme={null}
WITH
    -- 참고: 130과 190 사이의 간격은 window 매개변수에 따라 ts = 180의 값이 어떻게 채워지는지 보여주기 위한 것입니다
    [110, 120, 130, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps,
    [1, 3, 2, 6, 6, 4, 2, 0]::Array(Float32) AS values, -- 위 타임스탬프에 대응하는 값의 배열
    90 AS start_ts,       -- 타임스탬프 그리드의 시작
    90 + 135 AS end_ts,   -- 타임스탬프 그리드의 끝
    15 AS step_seconds,   -- 타임스탬프 그리드의 간격
    45 AS window_seconds  -- "staleness" 윈도우
SELECT timeSeriesResetsToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value)
FROM
(
    -- 이 서브쿼리는 타임스탬프와 값의 배열을 `timestamp`, `value` 행으로 변환합니다
    SELECT
        arrayJoin(arrayZip(timestamps, values)) AS ts_and_val,
        ts_and_val.1 AS timestamp,
        ts_and_val.2 AS value
);
```

```response title=Response theme={null}
┌─timeSeriesResetsToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value)─┐
│ [NULL,NULL,0,1,1,1,NULL,0,1,2]                                                           │
└──────────────────────────────────────────────────────────────────────────────────────────┘
```

**배열 인수를 사용한 동일한 쿼리**

```sql title=Query theme={null}
WITH
    [110, 120, 130, 190, 200, 210, 220, 230]::Array(DateTime) AS timestamps,
    [1, 3, 2, 6, 6, 4, 2, 0]::Array(Float32) AS values,
    90 AS start_ts,
    90 + 135 AS end_ts,
    15 AS step_seconds,
    45 AS window_seconds
SELECT timeSeriesResetsToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamps, values);
```

```response title=Response theme={null}
┌─timeSeriesResetsToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value)─┐
│ [NULL,NULL,0,1,1,0,NULL,0,1,2]                                                           │
└──────────────────────────────────────────────────────────────────────────────────────────┘
```
