

Amazon Timestream for LiveAnalytics와 유사한 기능을 원하는 경우 Amazon Timestream for InfluxDB를 고려해 보세요. 간소화된 데이터 수집과 실시간 분석을 위한 10밀리초 미만의 쿼리 응답 시간을 제공합니다. [여기](https://docs.aws.amazon.com//timestream/latest/developerguide/timestream-for-influxdb.html)에서 자세히 알아보세요.

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 보간 함수
<a name="timeseries-specific-constructs.functions.interpolation"></a>

특정 시점의 이벤트에 대한 시계열 데이터가 누락된 경우 보간을 사용하여 누락된 이벤트의 값을 추정할 수 있습니다. Amazon Timestream은 선형 보간, 3차 스플라인 보간, 마지막 관측값 전달(locf) 보간, 상수 보간의 네 가지 보간 변형을 지원합니다. 이 섹션에서는 Timestream for LiveAnalytics 보간 함수의 사용 정보와 샘플 쿼리를 제공합니다.



## 사용 정보
<a name="w2aab7c59c13c13c11b7"></a>


| 함수 | 출력 데이터 유형 | 설명 | 
| --- | --- | --- | 
|  `interpolate_linear(timeseries, array[timestamp])`  |  timeseries  |  [선형 보간](https://wikipedia.org/wiki/Linear_interpolation)을 사용하여 누락된 데이터를 채웁니다.  | 
|  `interpolate_linear(timeseries, timestamp)`  |  double  |  [선형 보간](https://wikipedia.org/wiki/Linear_interpolation)을 사용하여 누락된 데이터를 채웁니다.  | 
|  `interpolate_spline_cubic(timeseries, array[timestamp])`  |  timeseries  |  [3차 스플라인 보간](https://wikiversity.org/wiki/Cubic_Spline_Interpolation#:~:text=Cubic%20spline%20interpolation%20is%20a,Lagrange%20polynomial%20and%20Newton%20polynomial.)을 사용하여 누락된 데이터를 채웁니다.  | 
|  `interpolate_spline_cubic(timeseries, timestamp)`  |  double  |  [3차 스플라인 보간](https://wikiversity.org/wiki/Cubic_Spline_Interpolation#:~:text=Cubic%20spline%20interpolation%20is%20a,Lagrange%20polynomial%20and%20Newton%20polynomial.)을 사용하여 누락된 데이터를 채웁니다.  | 
|  `interpolate_locf(timeseries, array[timestamp])`  |  timeseries  |  마지막 샘플링된 값을 사용하여 누락된 데이터를 채웁니다.  | 
|  `interpolate_locf(timeseries, timestamp)`  |  double  |  마지막 샘플링된 값을 사용하여 누락된 데이터를 채웁니다.  | 
|  `interpolate_fill(timeseries, array[timestamp], double)`  |  timeseries  |  상수 값을 사용하여 누락된 데이터를 채웁니다.  | 
|  `interpolate_fill(timeseries, timestamp, double)`  |  double  |  상수 값을 사용하여 누락된 데이터를 채웁니다.  | 

## 쿼리 예제
<a name="w2aab7c59c13c13c11b9"></a>

**Example**  
지난 2시간 동안 특정 EC2 호스트에 대해 30초 간격으로 비닝된 평균 CPU 사용률을 찾아 선형 보간을 사용하여 누락된 값을 채웁니다.  

```
WITH binned_timeseries AS (
SELECT hostname, BIN(time, 30s) AS binned_timestamp, ROUND(AVG(measure_value::double), 2) AS avg_cpu_utilization
FROM "sampleDB".DevOps
WHERE measure_name = 'cpu_utilization'
    AND hostname = 'host-Hovjv'
    AND time > ago(2h)
GROUP BY hostname, BIN(time, 30s)
), interpolated_timeseries AS (
SELECT hostname,
    INTERPOLATE_LINEAR(
        CREATE_TIME_SERIES(binned_timestamp, avg_cpu_utilization),
            SEQUENCE(min(binned_timestamp), max(binned_timestamp), 15s)) AS interpolated_avg_cpu_utilization
FROM binned_timeseries
GROUP BY hostname
)
SELECT time, ROUND(value, 2) AS interpolated_cpu
FROM interpolated_timeseries
CROSS JOIN UNNEST(interpolated_avg_cpu_utilization)
```

**Example**  
지난 2시간 동안 특정 EC2 호스트에 대해 30초 간격으로 비닝된 평균 CPU 사용률을 찾아 마지막 관측치를 기준으로 보간을 사용하여 누락된 값을 채웁니다.  

```
WITH binned_timeseries AS (
SELECT hostname, BIN(time, 30s) AS binned_timestamp, ROUND(AVG(measure_value::double), 2) AS avg_cpu_utilization
FROM "sampleDB".DevOps
WHERE measure_name = 'cpu_utilization'
    AND hostname = 'host-Hovjv'
    AND time > ago(2h)
GROUP BY hostname, BIN(time, 30s)
), interpolated_timeseries AS (
SELECT hostname,
    INTERPOLATE_LOCF(
        CREATE_TIME_SERIES(binned_timestamp, avg_cpu_utilization),
            SEQUENCE(min(binned_timestamp), max(binned_timestamp), 15s)) AS interpolated_avg_cpu_utilization
FROM binned_timeseries
GROUP BY hostname
)
SELECT time, ROUND(value, 2) AS interpolated_cpu
FROM interpolated_timeseries
CROSS JOIN UNNEST(interpolated_avg_cpu_utilization)
```