# Extend 연산자

## 개요

다음으로 새 계산 필드를 추가합니다 `extend`.

```kusto
| extend <dest>=<expression>[, ...]
```

## 예제

{% hint style="info" %}
예제 데이터

```kusto
let aws_alb = datatable [
  {"type": "https", "p_event_time": "2023-09-16 05:59:04.058", "sentBytes": 167},
  {"type": "https", "p_event_time": "2023-09-16 05:45:34.863", "sentBytes": 329},
  {"type": "https", "p_event_time": "2023-09-16 05:36:09.017", "sentBytes": 167},
  {"type": "https", "p_event_time": "2023-09-16 05:27:39.177", "sentBytes": 468992}
];
```

{% endhint %}

### 새 필드 추가

아래 쿼리는 필드 `sentKB`를 추가합니다. 이는 `sentBytes` 값을 `1024`:

```kusto
aws_alb
| extend sentKB = sentBytes / 1024
```

| 이벤트                                                                                                        |
| ---------------------------------------------------------------------------------------------------------- |
| `{ "p_event_time": "2023-09-16 05:59:04.058", "sentBytes": 167, "sentKB": 0.1630859375, "type": "https" }` |
| `{ "p_event_time": "2023-09-16 05:45:34.863", "sentBytes": 329, "sentKB": 0.3212890625, "type": "https" }` |
| `{ "p_event_time": "2023-09-16 05:36:09.017", "sentBytes": 167, "sentKB": 0.1630859375, "type": "https" }` |
| `{ "p_event_time": "2023-09-16 05:27:39.177", "sentBytes": 468992, "sentKB": 458, "type": "https" }`       |

### 여러 새 필드 추가

아래 쿼리는 쉼표로 구분된 여러 필드를 추가합니다:

```kusto
aws_alb
| extend sentKB = sentBytes / 1024, sentMB = sentKB / 1024
```

| 이벤트                                                                                                                                         |
| ------------------------------------------------------------------------------------------------------------------------------------------- |
| `{ "p_event_time": "2023-09-16 05:59:04.058", "sentBytes": 167, "sentKB": 0.1630859375, "sentMB": 0.0001592636108398438, "type": "https" }` |
| `{ "p_event_time": "2023-09-16 05:45:34.863", "sentBytes": 329, "sentKB": 0.3212890625, "sentMB": 0.0003137588500976562, "type": "https" }` |
| `{ "p_event_time": "2023-09-16 05:36:09.017", "sentBytes": 167, "sentKB": 0.1630859375, "sentMB": 0.0001592636108398438, "type": "https" }` |
| `{ "p_event_time": "2023-09-16 05:27:39.177", "sentBytes": 468992, "sentKB": 458, "sentMB": 0.447265625, "type": "https" }`                 |

### 후속 식에서 추가된 필드 참조

추가된 필드는 예를 들어 [`where`](https://docs.panther.com/ko/pantherflow/operators/where) 연산자에서와 같이 후속 쿼리 식에서 참조할 수 있습니다:

```kusto
aws_alb
| extend sentKB = sentBytes / 1024
| where sentKB > 2
```

| 이벤트                                                                                                  |
| ---------------------------------------------------------------------------------------------------- |
| `{ "p_event_time": "2023-09-16 05:27:39.177", "sentBytes": 468992, "sentKB": 458, "type": "https" }` |

### 필드 제거

필드는 또한 다음을 사용하여 제거할 수 있습니다 `extend` 값을 설정하여 `null`:

```kusto
aws_alb
| extend sentBytes = null
```

| 이벤트                                                              |
| ---------------------------------------------------------------- |
| `{ "p_event_time": "2023-09-16 05:59:04.058", "type": "https" }` |
| `{ "p_event_time": "2023-09-16 05:45:34.863", "type": "https" }` |
| `{ "p_event_time": "2023-09-16 05:36:09.017", "type": "https" }` |
| `{ "p_event_time": "2023-09-16 05:27:39.177", "type": "https" }` |
