

# 명령줄을 사용하여 모니터링할 애플리케이션 설정, 구성, 관리
<a name="appinsights-setting-up-command"></a>

이 섹션에서는 AWS CLI 및 AWS Tools for Windows PowerShell을 사용하여 모니터링할 애플리케이션을 설정하고, 구성하고, 관리하는 방법을 단계별로 안내합니다.

**Topics**
+ [애플리케이션 추가 및 관리](#appinsights-config-app-command)
+ [모니터링 관리 및 업데이트](#appinsights-monitoring)
+ [SQL Always On 가용성 그룹에 대한 모니터링 구성](#configure-sql)
+ [MySQL RDS에 대한 모니터링 구성](#configure-mysql-rds)
+ [MySQL EC2에 대한 모니터링 구성](#configure-mysql-ec2)
+ [PostgreSQL RDS에 대한 모니터링 구성](#configure-postgresql-rds)
+ [PostgreSQL EC2에 대한 모니터링 구성](#configure-postgresql-ec2)
+ [Oracle RDS에 대한 모니터링 구성](#configure-oracle-rds)
+ [Oracle EC2에 대한 모니터링 구성](#configure-oracle-ec2)

## 애플리케이션 추가 및 관리
<a name="appinsights-config-app-command"></a>

명령줄을 사용해 Application Insights 애플리케이션에 대한 정보를 얻고 이 애플리케이션을 추가, 관리 및 구성할 수 있습니다.

**Topics**
+ [애플리케이션 추가](#appinsights-add-app)
+ [애플리케이션 설명](#appinsights-describe-app)
+ [애플리케이션의 구성 요소 나열](#appinsights-list-components)
+ [구성 요소 설명](#appinsights-describe-components)
+ [유사한 리소스를 사용자 지정 구성 요소로 그룹화](#appinsights-group-resources-components)
+ [사용자 지정 구성 요소 그룹화 해제](#appinsights-ungroup-resources-components)
+ [애플리케이션 업데이트](#appinsights-update-app)
+ [사용자 지정 구성 요소 업데이트](#appinsights-update-component)

### 애플리케이션 추가
<a name="appinsights-add-app"></a>

**AWS CLI를 사용하여 애플리케이션 추가**  
AWS CLI를 사용하여 `my-resource-group`이라는 리소스 그룹(생성된 OpsItem을 SNS 주제 ARN인 ` arn:aws:sns:us-east-1:123456789012:MyTopic`에 전달할 수 있도록 OpsCenter가 사용 설정된)의 애플리케이션을 추가하려면 다음 명령을 사용합니다.

```
aws application-insights create-application --resource-group-name my-resource-group --ops-center-enabled --ops-item-sns-topic-arn arn:aws:sns:us-east-1:123456789012:MyTopic
```

**AWS Tools for Windows PowerShell을 사용하여 애플리케이션 추가**  
AWS Tools for Windows PowerShell을 사용하여 `my-resource-group`이라는 리소스 그룹(생성된 OpsItem을 SNS 주제 ARN인 `arn:aws:sns:us-east-1:123456789012:MyTopic`에 전달할 수 있도록 OpsCenter가 사용 설정된)의 애플리케이션을 추가하려면 다음 명령을 사용합니다.

```
New-CWAIApplication -ResourceGroupName my-resource-group -OpsCenterEnabled true -OpsItemSNSTopicArn arn:aws:sns:us-east-1:123456789012:MyTopic
```

### 애플리케이션 설명
<a name="appinsights-describe-app"></a>

**AWS CLI를 사용하여 애플리케이션 설명**  
AWS CLI에서 다음 명령을 사용하면 `my-resource-group`이라는 리소스 그룹에 생성된 애플리케이션을 설명할 수 있습니다.

```
aws application-insights describe-application --resource-group-name my-resource-group
```

**AWS Tools for Windows PowerShell을 사용하여 애플리케이션 설명**  
AWS Tools for Windows PowerShell에서 다음 명령을 사용하면 `my-resource-group`이라는 리소스 그룹에 생성된 애플리케이션을 설명할 수 있습니다.

```
Get-CWAIApplication -ResourceGroupName my-resource-group
```

### 애플리케이션의 구성 요소 나열
<a name="appinsights-list-components"></a>

**AWS CLI를 사용하여 애플리케이션의 구성 요소 나열**  
AWS CLI에서 다음 명령을 사용하면 `my-resource-group`이라는 리소스 그룹에 생성된 구성 요소를 나열할 수 있습니다.

```
aws application-insights list-components --resource-group-name my-resource-group
```

**AWS Tools for Windows PowerShell을 사용하여 애플리케이션의 구성 요소 나열**  
AWS Tools for Windows PowerShell에서 다음 명령을 사용하면 `my-resource-group`이라는 리소스 그룹에 생성된 구성 요소를 나열할 수 있습니다.

```
Get-CWAIComponentList -ResourceGroupName my-resource-group
```

### 구성 요소 설명
<a name="appinsights-describe-components"></a>

**AWS CLI를 사용하여 구성 요소 설명**  
다음 AWS CLI 명령을 사용하면 `my-resource-group`이라는 리소스 그룹에 생성된 애플리케이션에 속해 있는 `my-component`라는 구성 요소를 설명할 수 있습니다.

```
aws application-insights describe-component --resource-group-name my-resource-group --component-name my-component
```

**AWS Tools for Windows PowerShell을 사용하여 구성 요소 설명**  
다음 AWS Tools for Windows PowerShell 명령을 사용하면 `my-resource-group`이라는 리소스 그룹에 생성된 애플리케이션에 속해 있는 `my-component`라는 구성 요소를 설명할 수 있습니다.

```
Get-CWAIComponent -ComponentName my-component -ResourceGroupName my-resource-group
```

### 유사한 리소스를 사용자 지정 구성 요소로 그룹화
<a name="appinsights-group-resources-components"></a>

.NET 웹 서버 인스턴스 등 유사한 리소스를 사용자 지정 구성 요소로 그룹화하여 보다 쉽게 온보딩을 수행하고 모니터링 및 통찰력을 향상시킬 수 있습니다. CloudWatch Application Insights는 EC2 인스턴스의 사용자 지정 그룹을 지원합니다.

**AWS CLI를 사용하여 리소스를 사용자 지정 구성 요소로 그룹화하려면**  
AWS CLI를 사용하여 세 개의 인스턴스(`arn:aws:ec2:us-east-1:123456789012:instance/i-11111`, `arn:aws:ec2:us-east-1:123456789012:instance/i-22222`, `arn:aws:ec2:us-east-1:123456789012:instance/i-33333`)를 `my-resource-group`이라는 리소스 그룹에 생성된 애플리케이션의 `my-component`라는 사용자 지정 구성 요소로 함께 그룹화하려면 다음 명령을 사용합니다.

```
aws application-insights create-component --resource-group-name my-resource-group --component-name my-component --resource-list arn:aws:ec2:us-east-1:123456789012:instance/i-11111 arn:aws:ec2:us-east-1:123456789012:instance/i-22222 arn:aws:ec2:us-east-1:123456789012:instance/i-33333
```

**AWS Tools for Windows PowerShell을 사용하여 리소스를 사용자 지정 구성 요소로 그룹화하려면**  
AWS Tools for Windows PowerShell을 사용하여 세 개의 인스턴스(`arn:aws:ec2:us-east-1:123456789012:instance/i-11111`, `arn:aws:ec2:us-east-1:123456789012:instance/i-22222`, `arn:aws:ec2:us-east-1:123456789012:instance/i-33333`)를 `my-resource-group`이라는 리소스 그룹에 생성된 애플리케이션의 `my-component`라는 사용자 지정 구성 요소로 함께 그룹화하려면 다음 명령을 사용합니다.

```
New-CWAIComponent -ResourceGroupName my-resource-group -ComponentName my-component -ResourceList arn:aws:ec2:us-east-1:123456789012:instance/i-11111,arn:aws:ec2:us-east-1:123456789012:instance/i-22222,arn:aws:ec2:us-east-1:123456789012:instance/i-33333 
```

### 사용자 지정 구성 요소 그룹화 해제
<a name="appinsights-ungroup-resources-components"></a>

**AWS CLI를 사용하여 사용자 지정 구성 요소의 그룹화를 해제하려면**  
AWS CLI에서 다음 명령을 사용하면 리소스 그룹 `my-resource-group`에 생성된 애플리케이션의 `my-component`라는 사용자 지정 구성 요소의 그룹화를 해제할 수 있습니다.

```
aws application-insights delete-component --resource-group-name my-resource-group --component-name my-new-component
```

**AWS Tools for Windows PowerShell을 사용하여 사용자 지정 구성 요소의 그룹화를 해제하려면**  
AWS Tools for Windows PowerShell에서 다음 명령을 사용하면 리소스 그룹 `my-resource-group`에 생성된 애플리케이션의 `my-component`라는 사용자 지정 구성 요소의 그룹화를 해제할 수 있습니다.

```
Remove-CWAIComponent -ComponentName my-component -ResourceGroupName my-resource-group
```

### 애플리케이션 업데이트
<a name="appinsights-update-app"></a>

**AWS CLI를 사용하여 애플리케이션 업데이트**  
AWS CLI에서 다음 명령을 사용하면 애플리케이션을 업데이트하여 애플리케이션과 관련하여 감지된 문제의 AWS Systems Manager OpsCenter OpsItem을 생성하고 생성된 OpsItem을 SNS 주제인 `arn:aws:sns:us-east-1:123456789012:MyTopic`에 연결할 수 있습니다.

```
aws application-insights update-application --resource-group-name my-resource-group --ops-center-enabled --ops-item-sns-topic-arn arn:aws:sns:us-east-1:123456789012:MyTopic
```

**AWS Tools for Windows PowerShell을 사용하여 애플리케이션 업데이트**  
AWS Tools for Windows PowerShell에서 다음 명령을 사용하면 애플리케이션을 업데이트하여 애플리케이션과 관련하여 감지된 문제의 AWS SSM OpsCenter OpsItem을 생성하고 생성된 OpsItem을 SNS 주제인 `arn:aws:sns:us-east-1:123456789012:MyTopic` 에 연결할 수 있습니다.

```
Update-CWAIApplication -ResourceGroupName my-resource-group -OpsCenterEnabled true -OpsItemSNSTopicArn arn:aws:sns:us-east-1:123456789012:MyTopic
```

### 사용자 지정 구성 요소 업데이트
<a name="appinsights-update-component"></a>

**AWS CLI를 사용하여 사용자 지정 구성 요소 업데이트**  
AWS CLI에서 다음 명령을 사용하면 `my-component`라는 사용자 지정 구성 요소를 새로운 구성 요소 이름인 `my-new-component` 및 업데이트된 인스턴스 그룹으로 업데이트할 수 있습니다.

```
aws application-insights update-component --resource-group-name my-resource-group --component-name my-component --new-component-name my-new-component --resource-list arn:aws:ec2:us-east-1:123456789012:instance/i-44444 arn:aws:ec2:us-east-1:123456789012:instance/i-55555
```

**AWS Tools for Windows PowerShell을 사용하여 사용자 지정 구성 요소 업데이트**  
AWS Tools for Windows PowerShell에서 다음 명령을 사용하면 `my-component`라는 사용자 지정 구성 요소를 새로운 구성 요소 이름인 `my-new-component` 및 업데이트된 인스턴스 그룹으로 업데이트할 수 있습니다.

```
Update-CWAIComponent -ComponentName my-component -NewComponentName my-new-component -ResourceGroupName my-resource-group -ResourceList arn:aws:ec2:us-east-1:123456789012:instance/i-44444,arn:aws:ec2:us-east-1:123456789012:instance/i-55555
```

## 모니터링 관리 및 업데이트
<a name="appinsights-monitoring"></a>

명령줄을 사용하여 Application Insights 애플리케이션에 대한 모니터링을 관리하고 업데이트할 수 있습니다.

**Topics**
+ [애플리케이션에서 발생하는 문제 나열](#appinsights-list-problems-monitoring)
+ [애플리케이션 문제 설명](#appinsights-describe-app-problem)
+ [문제와 관련된 이상 또는 오류 설명](#appinsights-describe-anomalies)
+ [애플리케이션의 이상 또는 오류 설명](#appinsights-describe-anomalies)
+ [구성 요소의 모니터링 구성 설명](#appinsights-describe-monitoring)
+ [구성 요소의 권장 모니터링 구성 설명](#appinsights-describe-rec-monitoring)
+ [구성 요소의 모니터링 구성 업데이트](#update-monitoring)
+ [Application Insights 모니터링에서 지정된 리소스 그룹 제거](#update-monitoring)

### 애플리케이션에서 발생하는 문제 나열
<a name="appinsights-list-problems-monitoring"></a>

**AWS CLI를 사용하여 애플리케이션 관련 문제 나열**  
AWS CLI에서 다음 명령을 사용하면 `my-resource-group`이라는 리소스 그룹에 생성된 애플리케이션의 Unix Epoch 이후 1,000\~10,000밀리초 사이에 감지된 애플리케이션 관련 문제를 나열할 수 있습니다.

```
aws application-insights list-problems --resource-group-name my-resource-group --start-time 1000 --end-time 10000
```

**AWS Tools for Windows PowerShell을 사용하여 애플리케이션 관련 문제 나열**  
AWS Tools for Windows PowerShell에서 다음 명령을 사용하면 `my-resource-group`이라는 리소스 그룹에 생성된 애플리케이션의 Unix Epoch 이후 1,000\~10,000밀리초 사이에 감지된 애플리케이션 관련 문제를 나열할 수 있습니다.

```
$startDate = "8/6/2019 3:33:00"
$endDate = "8/6/2019 3:34:00"
Get-CWAIProblemList -ResourceGroupName my-resource-group -StartTime $startDate -EndTime $endDate
```

### 애플리케이션 문제 설명
<a name="appinsights-describe-app-problem"></a>

**AWS CLI를 사용하여 애플리케이션 문제 설명**  
AWS CLI에서 다음 명령을 사용하면 문제 ID가 `p-1234567890`인 문제를 설명할 수 있습니다.

```
aws application-insights describe-problem —problem-id p-1234567890
```

**AWS Tools for Windows PowerShell을 사용하여 애플리케이션 문제 설명**  
AWS Tools for Windows PowerShell에서 다음 명령을 사용하면 문제 ID가 `p-1234567890`인 문제를 설명할 수 있습니다.

```
Get-CWAIProblem -ProblemId p-1234567890
```

### 문제와 관련된 이상 또는 오류 설명
<a name="appinsights-describe-anomalies"></a>

**AWS CLI를 사용하여 문제와 연결된 이상 또는 오류 설명**  
AWS CLI에서 다음 명령을 사용하면 문제 ID가 `p-1234567890`인 문제와 연결된 이상 또는 오류를 설명할 수 있습니다.

```
aws application-insights describe-problem-observations --problem-id -1234567890
```

**AWS Tools for Windows PowerShell을 사용하여 문제와 연결된 이상 또는 오류 설명**  
AWS Tools for Windows PowerShell에서 다음 명령을 사용하면 문제 ID가 `p-1234567890`인 문제와 연결된 이상 또는 오류를 설명할 수 있습니다.

```
Get-CWAIProblemObservation -ProblemId p-1234567890
```

### 애플리케이션의 이상 또는 오류 설명
<a name="appinsights-describe-anomalies"></a>

**AWS CLI를 사용하여 애플리케이션의 이상 또는 오류 설명**  
AWS CLI에서 다음 명령을 사용하면 관찰 ID가 `o-1234567890`인 애플리케이션의 이상 또는 오류를 설명할 수 있습니다.

```
aws application-insights describe-observation —observation-id o-1234567890
```

**AWS Tools for Windows PowerShell을 사용하여 애플리케이션의 이상 또는 오류 설명**  
AWS Tools for Windows PowerShell에서 다음 명령을 사용하면 관찰 ID가 `o-1234567890`인 애플리케이션의 이상 또는 오류를 설명할 수 있습니다.

```
Get-CWAIObservation -ObservationId o-1234567890
```

### 구성 요소의 모니터링 구성 설명
<a name="appinsights-describe-monitoring"></a>

**AWS CLI를 사용하여 구성 요소의 모니터링 구성 설명**  
AWS CLI에서 다음 명령을 사용하면 리소스 그룹 `my-resource-group`에 생성된 애플리케이션에 있는 `my-component`라는 구성 요소의 모니터링 구성을 설명할 수 있습니다.

```
aws application-insights describe-component-configuration —resource-group-name my-resource-group —component-name my-component
```

**AWS Tools for Windows PowerShell을 사용하여 구성 요소의 모니터링 구성 설명**  
AWS Tools for Windows PowerShell에서 다음 명령을 사용하면 리소스 그룹 `my-resource-group`에 생성된 애플리케이션에 있는 `my-component`라는 구성 요소의 모니터링 구성을 설명할 수 있습니다.

```
Get-CWAIComponentConfiguration -ComponentName my-component -ResourceGroupName my-resource-group
```

구성 요소 구성에 관한 자세한 내용과 예시 JSON 파일은 [구성 요소 구성 작업](component-config.md) 단원을 참조하세요.

### 구성 요소의 권장 모니터링 구성 설명
<a name="appinsights-describe-rec-monitoring"></a>

**AWS CLI를 사용하여 구성 요소의 권장 모니터링 구성 설명**  
구성 요소가 .NET Worker 애플리케이션의 일부인 경우 AWS CLI에서 다음 명령을 사용하면 리소스 그룹 `my-resource-group`에 생성된 애플리케이션에 있는 `my-component`라는 구성 요소의 권장 모니터링 구성을 설명할 수 있습니다.

```
aws application-insights describe-component-configuration-recommendation --resource-group-name my-resource-group --component-name my-component --tier DOT_NET_WORKER
```

**AWS Tools for Windows PowerShell을 사용하여 구성 요소의 권장 모니터링 구성 설명**  
구성 요소가 .NET Worker 애플리케이션의 일부인 경우 AWS Tools for Windows PowerShell에서 다음 명령을 사용하면 리소스 그룹 `my-resource-group`에 생성된 애플리케이션에 있는 `my-component`라는 구성 요소의 권장 모니터링 구성을 설명할 수 있습니다.

```
Get-CWAIComponentConfigurationRecommendation -ComponentName my-component -ResourceGroupName my-resource-group -Tier DOT_NET_WORKER
```

구성 요소 구성에 관한 자세한 내용과 예시 JSON 파일은 [구성 요소 구성 작업](component-config.md) 단원을 참조하세요.

### 구성 요소의 모니터링 구성 업데이트
<a name="update-monitoring"></a>

**AWS CLI를 사용하여 구성 요소의 모니터링 구성 업데이트**  
AWS CLI에서 다음 명령을 사용하면 `my-resource-group`이라는 리소스 그룹에 생성된 애플리케이션의 `my-component`라는 구성 요소를 업데이트할 수 있습니다. 이 명령은 다음과 같은 작업을 포함합니다.

1. 구성 요소에 대한 모니터링을 활성화합니다.

1. 구성 요소의 티어를 `.NET Worker`로 설정합니다.

1. `configuration.txt`라는 로컬 파일을 읽도록 구성 요소의 JSON 구성을 업데이트합니다.

```
aws application-insights update-component-configuration --resource-group-name my-resource-group --component-name my-component --tier DOT_NET_WORKER --monitor --component-configuration "file://configuration.txt"
```

**AWS Tools for Windows PowerShell을 사용하여 구성 요소의 모니터링 구성 업데이트**  
AWS Tools for Windows PowerShell에서 다음 명령을 사용하면 `my-resource-group`이라는 리소스 그룹에 생성된 애플리케이션의 `my-component`라는 구성 요소를 업데이트할 수 있습니다. 이 명령은 다음과 같은 작업을 포함합니다.

1. 구성 요소에 대한 모니터링을 활성화합니다.

1. 구성 요소의 티어를 `.NET Worker`로 설정합니다.

1. `configuration.txt`라는 로컬 파일을 읽도록 구성 요소의 JSON 구성을 업데이트합니다.

```
[string]$config = Get-Content -Path configuration.txt
Update-CWAIComponentConfiguration -ComponentName my-component -ResourceGroupName my-resource-group -Tier DOT_NET_WORKER -Monitor 1 -ComponentConfiguration $config
```

구성 요소 구성에 관한 자세한 내용과 예시 JSON 파일은 [구성 요소 구성 작업](component-config.md) 단원을 참조하세요.

### Application Insights 모니터링에서 지정된 리소스 그룹 제거
<a name="update-monitoring"></a>

**AWS CLI를 사용하여 Application Insights 모니터링에서 지정된 리소스 그룹 제거**  
AWS CLI에서 다음 명령을 사용하면 `my-resource-group`이라는 리소스 그룹에 생성된 애플리케이션을 모니터링에서 제거할 수 있습니다.

```
aws application-insights delete-application --resource-group-name my-resource-group
```

**AWS Tools for Windows PowerShell을 사용하여 Application Insights 모니터링에서 지정된 리소스 그룹 제거**  
AWS Tools for Windows PowerShell에서 다음 명령을 사용하면 `my-resource-group`이라는 리소스 그룹에 생성된 애플리케이션을 모니터링에서 제거할 수 있습니다.

```
Remove-CWAIApplication -ResourceGroupName my-resource-group
```

## SQL Always On 가용성 그룹에 대한 모니터링 구성
<a name="configure-sql"></a>

1. SQL HA EC2 인스턴스를 사용하여 리소스 그룹에 대한 애플리케이션을 생성합니다.

   ```
   aws application-insights create-application ‐-region <REGION> ‐-resource-group-name  <RESOURCE_GROUP_NAME>
   ```

1. 새 애플리케이션 구성 요소를 생성하여 SQL HA 클러스터를 나타내는 EC2 인스턴스를 정의합니다.

   ```
   aws application-insights create-component ‐-resource-group-name  "<RESOURCE_GROUP_NAME>" ‐-component-name SQL_HA_CLUSTER ‐-resource-list  "arn:aws:ec2:<REGION>:<ACCOUNT_ID>:instance/<CLUSTER_INSTANCE_1_ID>" "arn:aws:ec2:<REGION>:<ACCOUNT_ID>:instance/<CLUSTER_INSTANCE_2_ID>
   ```

1. SQL HA 구성 요소를 구성합니다.

   ```
   aws application-insights  update-component-configuration ‐-resource-group-name "<RESOURCE_GROUP_NAME>" ‐-region <REGION> ‐-component-name "SQL_HA_CLUSTER" ‐-monitor ‐-tier SQL_SERVER_ALWAYSON_AVAILABILITY_GROUP ‐-monitor  ‐-component-configuration '{
     "subComponents" : [ {
       "subComponentType" : "AWS::EC2::Instance",
       "alarmMetrics" : [ {
         "alarmMetricName" : "CPUUtilization",
         "monitor" : true
       }, {
         "alarmMetricName" : "StatusCheckFailed",
         "monitor" : true
       }, {
         "alarmMetricName" : "Processor % Processor Time",
         "monitor" : true
       }, {
         "alarmMetricName" : "Memory % Committed Bytes In Use",
         "monitor" : true
       }, {
         "alarmMetricName" : "Memory Available Mbytes",
         "monitor" : true
       }, {
         "alarmMetricName" : "Paging File % Usage",
         "monitor" : true
       }, {
         "alarmMetricName" : "System Processor Queue Length",
         "monitor" : true
       }, {
         "alarmMetricName" : "Network Interface Bytes Total/sec",
         "monitor" : true
       }, {
         "alarmMetricName" : "PhysicalDisk % Disk Time",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:Buffer Manager Buffer cache hit ratio",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:Buffer Manager Page life expectancy",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:General Statistics Processes blocked",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:General Statistics User Connections",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:Locks Number of Deadlocks/sec",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:SQL Statistics Batch Requests/sec",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:Database Replica File Bytes Received/sec",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:Database Replica Log Bytes Received/sec",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:Database Replica Log remaining for undo",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:Database Replica Log Send Queue",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:Database Replica Mirrored Write Transaction/sec",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:Database Replica Recovery Queue",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:Database Replica Redo Bytes Remaining",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:Database Replica Redone Bytes/sec",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:Database Replica Total Log requiring undo",
         "monitor" : true
       }, {
         "alarmMetricName" : "SQLServer:Database Replica Transaction Delay",
         "monitor" : true
       } ],
       "windowsEvents" : [ {
         "logGroupName" : "WINDOWS_EVENTS-Application-<RESOURCE_GROUP_NAME>",
         "eventName" : "Application",
         "eventLevels" : [ "WARNING", "ERROR", "CRITICAL", "INFORMATION" ],
         "monitor" : true
       }, {
         "logGroupName" : "WINDOWS_EVENTS-System-<RESOURCE_GROUP_NAME>",
         "eventName" : "System",
         "eventLevels" : [ "WARNING", "ERROR", "CRITICAL" ],
         "monitor" : true
       }, {
         "logGroupName" : "WINDOWS_EVENTS-Security-<RESOURCE_GROUP_NAME>",
         "eventName" : "Security",
         "eventLevels" : [ "WARNING", "ERROR", "CRITICAL" ],
         "monitor" : true
       } ],
       "logs" : [ {
         "logGroupName" : "SQL_SERVER_ALWAYSON_AVAILABILITY_GROUP-<RESOURCE_GROUP_NAME>",
         "logPath" : "C:\\Program Files\\Microsoft SQL Server\\MSSQL**.MSSQLSERVER\\MSSQL\\Log\\ERRORLOG",
         "logType" : "SQL_SERVER",
         "monitor" : true,
         "encoding" : "utf-8"
       } ]
     }, {
       "subComponentType" : "AWS::EC2::Volume",
       "alarmMetrics" : [ {
         "alarmMetricName" : "VolumeReadBytes",
         "monitor" : true
       }, {
       "alarmMetricName" : "VolumeWriteBytes",
         "monitor" : true
       }, {
       "alarmMetricName" : "VolumeReadOps",
         "monitor" : true
       }, {
       "alarmMetricName" : "VolumeWriteOps",
         "monitor" : true
       }, {
       "alarmMetricName" : "VolumeQueueLength",
         "monitor" : true
       }, {
       "alarmMetricName" : "VolumeThroughputPercentage",
         "monitor" : true
       }, {
       "alarmMetricName" : "BurstBalance",
         "monitor" : true
       } ]
     } ]
   }'
   ```

**참고**  
Application Insights는 장애 조치와 같은 클러스터 활동을 감지하기 위해 애플리케이션 이벤트 로그(정보 수준)를 수집해야 합니다.

## MySQL RDS에 대한 모니터링 구성
<a name="configure-mysql-rds"></a>

1. RDS MySQL 데이터베이스 인스턴스를 사용하여 리소스 그룹에 대한 애플리케이션을 생성합니다.

   ```
   aws application-insights create-application ‐-region <REGION> ‐-resource-group-name  <RESOURCE_GROUP_NAME>
   ```

1. 오류 로그는 기본적으로 활성화됩니다. 느린 쿼리 로그는 데이터 파라미터 그룹을 사용하여 활성화할 수 있습니다. 자세한 내용은 [MySQL 느린 쿼리 및 일반 로그 액세스](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_LogAccess.Concepts.MySQL.html#USER_LogAccess.MySQL.Generallog)를 참조하세요.
   + `set slow_query_log = 1`
   + `set log_output = FILE`

1. 모니터링할 로그를 CloudWatch Logs로 내보냅니다. 자세한 내용은 [CloudWatch Logs에 MySQL Logs 게시](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_LogAccess.Concepts.MySQL.html#USER_LogAccess.MySQLDB.PublishtoCloudWatchLogs)를 참조하세요.

1. MySQL RDS 구성 요소를 구성합니다.

   ```
   aws application-insights  update-component-configuration ‐-resource-group-name "<RESOURCE_GROUP_NAME>" ‐-region <REGION> ‐-component-name "<DB_COMPONENT_NAME>" ‐-monitor ‐-tier DEFAULT ‐-monitor  ‐-component-configuration "{\"alarmMetrics\":[{\"alarmMetricName\":\"CPUUtilization\",\"monitor\":true}],\"logs\":[{\"logType\":\"MYSQL\",\"monitor\":true},{\"logType\": \"MYSQL_SLOW_QUERY\",\"monitor\":false}]}"
   ```

## MySQL EC2에 대한 모니터링 구성
<a name="configure-mysql-ec2"></a>

1. SQL HA EC2 인스턴스를 사용하여 리소스 그룹에 대한 애플리케이션을 생성합니다.

   ```
   aws application-insights create-application ‐-region <REGION> ‐-resource-group-name  <RESOURCE_GROUP_NAME>
   ```

1. 오류 로그는 기본적으로 활성화됩니다. 느린 쿼리 로그는 데이터 파라미터 그룹을 사용하여 활성화할 수 있습니다. 자세한 내용은 [MySQL 느린 쿼리 및 일반 로그 액세스](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_LogAccess.Concepts.MySQL.html#USER_LogAccess.MySQL.Generallog)를 참조하세요.
   + `set slow_query_log = 1`
   + `set log_output = FILE`

1. MySQL EC2 구성 요소를 구성합니다.

   ```
   aws application-insights  update-component-configuration ‐-resource-group-name "<RESOURCE_GROUP_NAME>" ‐-region <REGION> ‐-component-name "<DB_COMPONENT_NAME>" ‐-monitor ‐-tier MYSQL ‐-monitor  ‐-component-configuration "{\"alarmMetrics\":[{\"alarmMetricName\":\"CPUUtilization\",\"monitor\":true}],\"logs\":[{\"logGroupName\":\"<UNIQUE_LOG_GROUP_NAME>\",\"logPath\":\"C:\\\\ProgramData\\\\MySQL\\\\MySQL Server **\\\\Data\\\\<FILE_NAME>.err\",\"logType\":\"MYSQL\",\"monitor\":true,\"encoding\":\"utf-8\"}]}"
   ```

## PostgreSQL RDS에 대한 모니터링 구성
<a name="configure-postgresql-rds"></a>

1. PostgreSQL RDS 데이터베이스 인스턴스를 사용하여 리소스 그룹의 애플리케이션을 생성합니다.

   ```
   aws application-insights create-application ‐-region <REGION> ‐-resource-group-name  <RESOURCE_GROUP_NAME>
   ```

1. CloudWatch에 PostgreSQL 로그를 게시하는 기능은 기본적으로 사용 설정되어 있지 않습니다. 모니터링을 사용 설정하려면 RDS 콘솔을 열고 모니터링할 데이터베이스를 선택합니다. 오른쪽 상단 모서리에서 **수정(Modify)**을 선택하고 **PostgreSQL** 로그로 레이블이 지정된 확인란을 선택합니다. [**계속(Continue)**]을 선택하여 이 설정을 저장합니다.

1. PostgreSQL 로그를 CloudWatch로 내보냅니다.

1. PostgreSQL RDS 구성 요소를 구성합니다.

   ```
   aws application-insights update-component-configuration --region <REGION> --resource-group-name <RESOURCE_GROUP_NAME> --component-name <DB_COMPONENT_NAME> --monitor --tier DEFAULT --component-configuration 
   "{
      \"alarmMetrics\":[
         {
            \"alarmMetricName\": \"CPUUtilization\",
            \"monitor\": true
         }
      ],
      \"logs\":[
         {
            \"logType\": \"POSTGRESQL\",
            \"monitor\": true
         }
      ]
   }"
   ```

## PostgreSQL EC2에 대한 모니터링 구성
<a name="configure-postgresql-ec2"></a>

1. PostgreSQL EC2 인스턴스를 사용하여 리소스 그룹의 애플리케이션을 생성합니다.

   ```
   aws application-insights create-application ‐-region <REGION> ‐-resource-group-name  <RESOURCE_GROUP_NAME>
   ```

1. PostgreSQL EC2 구성 요소를 구성합니다.

   ```
   aws application-insights update-component-configuration ‐-region <REGION> ‐-resource-group-name <RESOURCE_GROUP_NAME> ‐-component-name <DB_COMPONENT_NAME> ‐-monitor ‐-tier POSTGRESQL ‐-component-configuration 
   "{
      \"alarmMetrics\":[
         {
            \"alarmMetricName\":\"CPUUtilization\",
            \"monitor\":true
         }
      ],
      \"logs\":[
         {
            \"logGroupName\":\"<UNIQUE_LOG_GROUP_NAME>\",
            \"logPath\":\"/var/lib/pgsql/data/log/\",
            \"logType\":\"POSTGRESQL\",
            \"monitor\":true,
            \"encoding\":\"utf-8\"
         }
      ]
   }"
   ```

## Oracle RDS에 대한 모니터링 구성
<a name="configure-oracle-rds"></a>

1. Oracle RDS 데이터베이스 인스턴스를 사용하여 리소스 그룹의 애플리케이션을 생성합니다.

   ```
   aws application-insights create-application ‐-region <REGION> ‐-resource-group-name  <RESOURCE_GROUP_NAME>
   ```

1. CloudWatch에 Oracle 로그를 게시하는 기능은 기본적으로 사용 설정되어 있지 않습니다. 모니터링을 사용 설정하려면 RDS 콘솔을 열고 모니터링할 데이터베이스를 선택합니다. 오른쪽 상단 모서리에서 **수정(Modify)**을 선택하고 **알림(Alert)** 로그 및 **리스너(Listener)** 로그로 레이블이 지정된 확인란을 선택합니다. [**계속(Continue)**]을 선택하여 이 설정을 저장합니다.

1. Oracle 로그를 CloudWatch로 내보냅니다.

1. Oracle RDS 구성 요소를 구성합니다.

   ```
   aws application-insights update-component-configuration --region <REGION> --resource-group-name <RESOURCE_GROUP_NAME> --component-name <DB_COMPONENT_NAME> --monitor --tier DEFAULT --component-configuration 
   "{
      \"alarmMetrics\":[
         {
            \"alarmMetricName\": \"CPUUtilization\",
            \"monitor\": true
         }
      ],
      \"logs\":[
         {
            \"logType\": \"ORACLE_ALERT\",
            \"monitor\": true
         },
         {
            \"logType\": \"ORACLE_LISTENER\",
            \"monitor\": true
         }
      ]
   }"
   ```

## Oracle EC2에 대한 모니터링 구성
<a name="configure-oracle-ec2"></a>

1. Oracle EC2 인스턴스를 사용하여 리소스 그룹의 애플리케이션을 생성합니다.

   ```
   aws application-insights create-application ‐-region <REGION> ‐-resource-group-name  <RESOURCE_GROUP_NAME>
   ```

1. Oracle EC2 구성 요소를 구성합니다.

   ```
   aws application-insights update-component-configuration ‐-region <REGION> ‐-resource-group-name <RESOURCE_GROUP_NAME> ‐-component-name <DB_COMPONENT_NAME> ‐-monitor ‐-tier ORACLE ‐-component-configuration 
   "{
      \"alarmMetrics\":[
         {
            \"alarmMetricName\":\"CPUUtilization\",
            \"monitor\":true
         }
      ],
      \"logs\":[
         {
            \"logGroupName\":\"<UNIQUE_LOG_GROUP_NAME>\",
            \"logPath\":\"/opt/oracle/diag/rdbms/*/*/trace\",
            \"logType\":\"ORACLE_ALERT\",
            \"monitor\":true,
         },
         {
            \"logGroupName\":\"<UNIQUE_LOG_GROUP_NAME>\",
            \"logPath\":\"/opt/oracle/diag/tnslsnr/$HOSTNAME/listener/trace/\",
            \"logType\":\"ORACLE_ALERT\",
            \"monitor\":true,
         }
      ]
   }"
   ```