

# Set up application for monitoring using the AWS Management Console
<a name="appinsights-setting-up"></a>

This section provides steps to set up, configure, and manage your CloudWatch Application Insights application using the console, the AWS CLI, and AWS Tools for Windows PowerShell.

**Topics**
+ [Console steps](appinsights-setting-up-console.md)
+ [Command line steps](appinsights-setting-up-command.md)
+ [Events](appinsights-cloudwatch-events.md)
+ [Notifications](appinsights-problem-notifications.md)

# Set up, configure, and manage your application for monitoring from the CloudWatch console
<a name="appinsights-setting-up-console"></a>

This section provides steps to set up, configure, and manage your application for monitoring from the CloudWatch console.

**Topics**
+ [Add and configure an application](#appinsights-add-configure)
+ [Enable Application Insights for Amazon ECS and Amazon EKS resource monitoring](#appinsights-container-insights)
+ [Disable monitoring for an application component](#appinsights-disable-monitoring)
+ [Delete an application](#appinsights-delete-app)

## Add and configure an application
<a name="appinsights-add-configure"></a>

**Add and configure an application from the CloudWatch console**  
To get started with CloudWatch Application Insights from the CloudWatch console, perform the following steps.

1. **Start.** Open the [CloudWatch console landing page](http://console.aws.amazon.com/cloudwatch). From the left navigation pane, under **Insights**, choose **Application Insights**. The page that opens shows the list of applications that are monitored with CloudWatch Application Insights, along with their monitoring status. 

1. **Add an application.** To set up monitoring for your application, choose **Add an application**. When you choose **Add an application**, you are prompted to **Choose Application Type**. 
   + **Resource group-based application**. When you select this option, you can choose which resource groups in this account to monitor. To use multiple applications on a component, you must use resource group-based monitoring. 
   + **Account-based application**. When you select this option, you can monitor all of the resources in this account. If you want to monitor all of the resources in an account, we recommend this option over the resource group-based option because the application onboarding process is faster.
**Note**  
You can't combine resource group-based monitoring with account-based monitoring using Application Insights. In order to change the application type, you must delete all of the applications that are being monitored, and **Choose Application Type**. 

   When you add your first application for monitoring, CloudWatch Application Insights creates a service-linked role in your account, which gives Application Insights permissions to call other AWS services on your behalf. For more information about the service-linked role created in your account by Application Insights, see [Using service-linked roles for CloudWatch Application Insights](CHAP_using-service-linked-roles-appinsights.md).

1. 

------
#### [ Resource-based application monitoring ]

   1. **Select an application or resource group. **On the **Specify application details** page, select the AWS resource group that contains your application resources from the dropdown list. These resources include front-end servers, load balancers, auto scaling groups, and database servers. 

      If you have not created a resource group for your application, you can create one by choosing **Create new resource group**. For more information about creating resource groups, see the [https://docs.aws.amazon.com/ARG/latest/userguide/welcome.html](https://docs.aws.amazon.com/ARG/latest/userguide/welcome.html). 

   1. **Notifications for problem insights.** To view and get notified when problems are detected for selected applications, choose Amazon SNS notifications or Systems Manager OpsCenter Opsitems.

      1. **Set up Amazon SNS notification (Recommended).** Choose **Select existing topic** or **Create new topic**. 

      1. **Integrate with AWS Systems Manager OpsCenter.** Under **Advanced Settings**, select the **Generate Systems Manager OpsCenter OpsItems for remedial actions** check box. To track the operations that are taken to resolve operational work items (OpsItems) that are related to your AWS resources, provide the Amazon SNS topic ARN.

   1. **Monitor CloudWatch Events**. Select the check box to integrate Application Insights monitoring with CloudWatch Events to get insights from Amazon EBS, Amazon EC2, AWS CodeDeploy, Amazon ECS, AWS Health APIs And Notifications, Amazon RDS, Amazon S3, and AWS Step Functions.

   1. **Tags — optional**. CloudWatch Application Insights supports both tag-based and CloudFormation-based resource groups (with the exception of Auto Scaling groups). For more information, see [Working with Tag Editor](https://docs.aws.amazon.com/ARG/latest/userguide/tag-editor.html).

   1. Choose **Next**.

      An [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) is generated for the application in the following format.

      ```
      arn:partition:applicationinsights:region:account-id:application/resource-group/resource-group-name
      ```

      Example

      ```
      arn:aws:applicationinsights:us-east-1:123456789012:application/resource-group/my-resource-group
      ```

   1. On the **Review detected components** page, under **Review components for monitoring**, the table lists the detected components and their associated detected workloads.
**Note**  
For components that support multiple customized workloads, you can monitor up to five workloads for each component. These workloads will be monitored separately from the component.  
![\[The detected components section of the CloudWatch Application Insights console: overview of detected components and associated workloads.\]](http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/images/appinsights-multiapp-review-component.png)

      Under **Associated workloads**, there are several possible messages that appear if a workload is not listed.
      + **Couldn't detect workloads** – An issue occurred when trying to detect workloads. Make sure that you have completed the [Prerequisites to configure an application for monitoring](appinsights-prereqs.md). If you need to add workloads, choose **Edit component**.
      + **No workloads detected** – We didn't detect any workloads. You may need to add workloads. To do so, choose **Edit component**.
      + **Not applicable** – The component doesn't support customized workloads and will be monitored with default metrics, alarms, and logs. You can't add workloads to these components.

   1. To edit a component, select a component, and then choose **Edit component**. A side panel opens with workloads detected on the component. In this panel, you can edit the component details and add new workloads.  
![\[The review detected components section of the CloudWatch Application Insights console: associated workloads can be edited.\]](http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/images/appinsights-multiapp-edit-component.png)
      + To edit the workload type or name, use the dropdown list.  
![\[The Edit component section of the CloudWatch Application Insights console: dropdown list of workload type.\]](http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/images/appinsights-multiapp-edit-name-type.png)
      + To add a workload to the component, choose **Add new workload**.  
![\[The edit component section of the CloudWatch Application Insights console: lower left button to add a new workload.\]](http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/images/appinsights-multiapp-add-workload.png)
        + If **Add new workload** doesn't appear, this component doesn't support multiple workloads.
        + If the **Associated workloads** heading doesn't appear, this component doesn't support customized workloads.
      + To remove a workload, choose **Remove** next to the workload that you want to remove from monitoring.  
![\[The edit component section of the CloudWatch Application Insights console: remove a workload.\]](http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/images/appinsights-multiapp-remove-workload.png)
      + To disable monitoring for the entire component, clear the **Monitoring** check box.  
![\[The edit component section of the CloudWatch Application Insights check box to disable monitoring.\]](http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/images/appinsights-multiapp-disable-monitoring.png)
      + When you are done editing the component, choose **Save changes** in the lower right corner. Any changes to workloads for a component are visible on the **Review components for monitoring** table under **Associated workloads**.

   1. On the **Review detected components** page, choose **Next**.

   1. The **Specify component details** page includes all components with customizable associated workloads from the previous step.
**Note**  
If a component header has an *optional* tag, additional details for the workloads in that component are optional.

      If a component doesn't appear on this page, the component doesn't have any additional details that can be specified in this step.

   1. Choose **Next**.

   1. On the **Review and submit** page, review all monitored component and workload details.

   1. Choose **Submit**.

------
#### [ Account-based application monitoring ]

   1. **Application name**. Enter a name for your account-based application.

   1. **Automated monitoring of new resources**. By default, Application Insights uses recommended settings to configure monitoring for resource components that are added to your account after you onboard the application. You can exclude monitoring for resources added after onboarding your application by clearing the check box.

   1. **Monitor CloudWatch Events**. Select the check box to integrate Application Insights monitoring with CloudWatch Events to get insights from Amazon EBS, Amazon EC2, AWS CodeDeploy, Amazon ECS, AWS Health APIs And Notifications, Amazon RDS, Amazon S3, and AWS Step Functions.

   1. **Integrate with AWS Systems Manager OpsCenter.** To view and get notified when problems are detected for selected applications, select the **Generate Systems Manager OpsCenter OpsItems for remedial actions** check box. To track the operations that are taken to resolve operational work items (OpsItems) that are related to your AWS resources, provide the SNS topic ARN. 

   1. **Tags — optional**. CloudWatch Application Insights supports both tag-based and CloudFormation-based resource groups (with the exception of Auto Scaling groups). For more information, see [Working with Tag Editor](https://docs.aws.amazon.com/ARG/latest/userguide/tag-editor.html).

   1. **Discovered resources**. All of the resources discovered in your account are added to this list. If Application Insights is unable to discover all of the resources in your account, an error message appears at the top of the page. This message includes a link to the [documentation for how to add the required permissions](appinsights-account-based-onboarding-permissions.md).

   1. Choose **Next**.

      An [ARN](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) is generated for the application in the following format.

      ```
      arn:partition:applicationinsights:region:account-id:application/TBD/application-name
      ```

      Example

      ```
      arn:aws:applicationinsights:us-east-1:123456789012:application/TBD/my-application
      ```

------

1. After you submit your application monitoring configuration, you will be taken to the details page for the application, where you can view the **Application summary**, the list of **Monitored components** and **Unmonitored components**, and, by selecting the tabs next to **Components**, the **Configuration history**, **Log patterns**, and any **Tags** that you have applied.

   To view insights for the application, choose **View Insights**.

   You can update your selections for CloudWatch Events monitoring and integration with AWS Systems Manager OpsCenter by choosing **Edit**.

   Under **Components**, you can select the **Actions** menu to Create, Modify, or Ungroup an instance group.

   You can manage monitoring for components, including application tier, log groups, event logs, metrics, and custom alarms, by selecting the bullet next to a component and choosing **Manage monitoring**.

## Enable Application Insights for Amazon ECS and Amazon EKS resource monitoring
<a name="appinsights-container-insights"></a>

You can enable Application Insights to monitor containerized applications and microservices from the Container Insights console. Application Insights supports monitoring for the following resources:
+ Amazon ECS clusters
+ Amazon ECS services
+ Amazon ECS tasks
+ Amazon EKS clusters

When Application Insights is enabled, it provides recommended metrics and logs, detects potential problems, generates CloudWatch Events, and creates automatic dashboards for your containerized applications and microservices.

You can enable Application Insights for containerized resources from the Container Insights or Application Insights consoles.

**Enable Application Insights from the Container Insights console**  
From the Container Insights console, on the Container Insights **Performance monitoring** dashboard, choose **Auto-configure Application Insights**. When Application Insights is enabled, it displays details about detected problems.

**Enable Application Insights from the Application Insights console**  
When ECS clusters appear in the component list, Application Insights automatically enables additional container monitoring with Container Insights. 

For EKS clusters, you can enable additional monitoring with Container Insights to provide diagnostics information, such as container restart failures, to help you isolate and resolve problems. Additional steps are required to set up Container Insights for EKS. For information, see [Setting up Container Insights on Amazon EKS and Kubernetes](deploy-container-insights-EKS.md) for steps to set up Container Insights on EKS. 

Additional monitoring for EKS with Container Insights is supported on Linux instances with EKS.

For more information about Container Insights support for ECS and EKS clusters, see [Container Insights](ContainerInsights.md).

## Disable monitoring for an application component
<a name="appinsights-disable-monitoring"></a>

To disable monitoring for an application component, from the application details page, select the component for which you want to disable monitoring. Choose **Actions**, and then **Remove from monitoring**. 

## Delete an application
<a name="appinsights-delete-app"></a>

To delete an application, from the CloudWatch dashboard, on the left navigation pane, choose **Application Insights** under **Insights**. Select the application that you want to delete. Under **Actions**, choose **Delete application**. This deletes monitoring and deletes all of the saved monitors for application components. The application resources are not deleted. 

# Set up, configure, and manage your application for monitoring using the command line
<a name="appinsights-setting-up-command"></a>

This section provides steps for setting up, configuring, and managing your application for monitoring using the AWS CLI and AWS Tools for Windows PowerShell.

**Topics**
+ [Add and manage an application](#appinsights-config-app-command)
+ [Manage and update monitoring](#appinsights-monitoring)
+ [Configure monitoring for SQL Always On Availability Groups](#configure-sql)
+ [Configure monitoring for MySQL RDS](#configure-mysql-rds)
+ [Configure monitoring for MySQL EC2](#configure-mysql-ec2)
+ [Configure monitoring for PostgreSQL RDS](#configure-postgresql-rds)
+ [Configure monitoring for PostgreSQL EC2](#configure-postgresql-ec2)
+ [Configure monitoring for Oracle RDS](#configure-oracle-rds)
+ [Configure monitoring for Oracle EC2](#configure-oracle-ec2)

## Add and manage an application
<a name="appinsights-config-app-command"></a>

You can add, get information about, manage, and configure your Application Insights application using the command line. 

**Topics**
+ [Add an application](#appinsights-add-app)
+ [Describe an application](#appinsights-describe-app)
+ [List components in an application](#appinsights-list-components)
+ [Describe a component](#appinsights-describe-components)
+ [Group similar resources into a custom component](#appinsights-group-resources-components)
+ [Ungroup a custom component](#appinsights-ungroup-resources-components)
+ [Update an application](#appinsights-update-app)
+ [Update a custom component](#appinsights-update-component)

### Add an application
<a name="appinsights-add-app"></a>

**Add an application using the AWS CLI**  
To use the AWS CLI to add an application for your resource group called `my-resource-group`, with OpsCenter enabled to deliver the created opsItem to the SNS topic ARN ` arn:aws:sns:us-east-1:123456789012:MyTopic`, use the following command.

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

**Add an application using AWS Tools for Windows PowerShell**  
To use AWS Tools for Windows PowerShell to add an application for your resource group called `my-resource-group` with OpsCenter enabled to deliver the created opsItem to the SNS topic ARN `arn:aws:sns:us-east-1:123456789012:MyTopic`, use the following command.

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

### Describe an application
<a name="appinsights-describe-app"></a>

**Describe an application using the AWS CLI**  
To use the AWS CLI to describe an application created on a resource group called `my-resource-group`, use the following command.

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

**Describe an application using AWS Tools for Windows PowerShell**  
To use the AWS Tools for Windows PowerShell to describe an application created on a resource group called `my-resource-group`, use the following command.

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

### List components in an application
<a name="appinsights-list-components"></a>

**List components in an application using the AWS CLI**  
To use the AWS CLI to list the components created on a resource group called `my-resource-group`, use the following command.

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

**List components in an application using AWS Tools for Windows PowerShell**  
To use the AWS Tools for Windows PowerShell to list the components created on a resource group called `my-resource-group`, use the following command.

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

### Describe a component
<a name="appinsights-describe-components"></a>

**Describe a component using the AWS CLI**  
You can use the following AWS CLI command to describe a component called `my-component` that belongs to an application created on a resource group called `my-resource-group`.

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

**Describe a component using AWS Tools for Windows PowerShell**  
You can use the following AWS Tools for Windows PowerShell command to describe a component called `my-component` that belongs to an application created on a resource group called `my-resource-group`.

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

### Group similar resources into a custom component
<a name="appinsights-group-resources-components"></a>

We recommend grouping similar resources, such as .NET web server instances, into custom components for easier on-boarding and better monitoring and insights. CloudWatch Application Insights supports custom groups for EC2 instances.

**To group resources into a custom component using the AWS CLI**  
To use the AWS CLI to group three instances (`arn:aws:ec2:us-east-1:123456789012:instance/i-11111`, `arn:aws:ec2:us-east-1:123456789012:instance/i-22222`, and `arn:aws:ec2:us-east-1:123456789012:instance/i-33333`) together into a custom component called `my-component` for an application created for the resource group called `my-resource-group`, use the following command. 

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

**To group resources into a custom component using AWS Tools for Windows PowerShell**  
To use AWS Tools for Windows PowerShell to group three instances (`arn:aws:ec2:us-east-1:123456789012:instance/i-11111`, `arn:aws:ec2:us-east-1:123456789012:instance/i-22222`, and `arn:aws:ec2:us-east-1:123456789012:instance/i-33333`) together into a custom component called `my-component`, for an application created for the resource group called `my-resource-group`, use the following command.

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

### Ungroup a custom component
<a name="appinsights-ungroup-resources-components"></a>

**To ungroup a custom component using the AWS CLI**  
To use the AWS CLI to ungroup a custom component named `my-component` in an application created on the resource group, `my-resource-group`, use the following command. 

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

**To ungroup a custom component using AWS Tools for Windows PowerShell**  
To use the AWS Tools for Windows PowerShell to ungroup a custom component named `my-component` in an application created on the resource group, `my-resource-group`, use the following command.

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

### Update an application
<a name="appinsights-update-app"></a>

**Update an application using the AWS CLI**  
You can use the AWS CLI to update an application to generate AWS Systems Manager OpsCenter OpsItems for problems detected with the application, and to associate the created OpsItems to the SNS topic `arn:aws:sns:us-east-1:123456789012:MyTopic`, using the following command.

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

**Update an application using AWS Tools for Windows PowerShell**  
You can use the AWS Tools for Windows PowerShell to update an application to generate AWS SSM OpsCenter OpsItems for problems detected with the application, and to associate the created OpsItems to the SNS topic `arn:aws:sns:us-east-1:123456789012:MyTopic` , using the following command.

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

### Update a custom component
<a name="appinsights-update-component"></a>

**Update a custom component using the AWS CLI**  
You can use the AWS CLI to update a custom component called `my-component` with a new component name, `my-new-component`, and an updated group of instances, by using the following command.

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

**Update a custom component using AWS Tools for Windows PowerShell**  
You can use the AWS Tools for Windows PowerShell to update a custom component called `my-component` with a new component name, `my-new-component`, and an updated group of instances, by using the following command.

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

## Manage and update monitoring
<a name="appinsights-monitoring"></a>

You can manage and update monitoring for your Application Insights application using the command line.

**Topics**
+ [List problems with your application](#appinsights-list-problems-monitoring)
+ [Describe an application problem](#appinsights-describe-app-problem)
+ [Describe the anomalies or errors associated with a problem](#appinsights-describe-anomalies)
+ [Describe an anomaly or error with the application](#appinsights-describe-anomalies)
+ [Describe the monitoring configurations of a component](#appinsights-describe-monitoring)
+ [Describe the recommended monitoring configuration of a component](#appinsights-describe-rec-monitoring)
+ [Update the monitoring configurations for a component](#update-monitoring)
+ [Remove a specified resource group from Application Insights monitoring](#update-monitoring)

### List problems with your application
<a name="appinsights-list-problems-monitoring"></a>

**List problems with your application using the AWS CLI**  
To use the AWS CLI to list problems with your application detected between 1,000 and 10,000 milliseconds since Unix Epoch for an application created on a resource group called `my-resource-group`, use the following command.

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

**List problems with your application using AWS Tools for Windows PowerShell**  
To use the AWS Tools for Windows PowerShell to list problems with your application detected between 1,000 and 10,000 milliseconds since Unix Epoch for an application created on a resource group called `my-resource-group`, use the following command.

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

### Describe an application problem
<a name="appinsights-describe-app-problem"></a>

**Describe an application problem using the AWS CLI**  
To use the AWS CLI to describe a problem with problem id `p-1234567890`, use the following command.

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

**Describe an application problem using AWS Tools for Windows PowerShell**  
To use the AWS Tools for Windows PowerShell to describe a problem with problem id `p-1234567890`, use the following command.

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

### Describe the anomalies or errors associated with a problem
<a name="appinsights-describe-anomalies"></a>

**Describe the anomalies or errors associated with a problem using the AWS CLI**  
To use the AWS CLI to describe the anomalies or errors associated with a problem with problem id `p-1234567890`, use the following command.

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

**Describe the anomalies or errors associated with a problem using AWS Tools for Windows PowerShell**  
To use the AWS Tools for Windows PowerShell to describe the anomalies or errors associated with a problem with problem id `p-1234567890`, use the following command.

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

### Describe an anomaly or error with the application
<a name="appinsights-describe-anomalies"></a>

**Describe an anomaly or error with the application using the AWS CLI**  
To use the AWS CLI to describe an anomaly or error with the application with the observation id `o-1234567890`, use the following command.

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

**Describe an anomaly or error with the application using AWS Tools for Windows PowerShell**  
To use the AWS Tools for Windows PowerShell to describe an anomaly or error with the application with the observation id `o-1234567890`, use the following command.

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

### Describe the monitoring configurations of a component
<a name="appinsights-describe-monitoring"></a>

**Describe the monitoring configurations of a component using the AWS CLI**  
To use the AWS CLI to describe the monitoring configuration of a component called `my-component` in an application created on the resource group `my-resource-group`, use the following command.

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

**Describe the monitoring configurations of a component using AWS Tools for Windows PowerShell**  
To use the AWS Tools for Windows PowerShell to describe the monitoring configuration of a component called `my-component`, in an application created on the resource group `my-resource-group`, use the following command.

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

For more information about component configuration and for example JSON files, see [Work with component configurations](component-config.md).

### Describe the recommended monitoring configuration of a component
<a name="appinsights-describe-rec-monitoring"></a>

**Describe the recommended monitoring configuration of a component using the AWS CLI**  
When the component is part of a .NET Worker application, you can use the AWS CLI to describe the recommended monitoring configuration of a component called `my-component` in an application created on the resource group `my-resource-group`, by using the following command.

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

**Describe the recommended monitoring configuration of a component using AWS Tools for Windows PowerShell**  
When the component is part of a .NET Worker application, you can use the AWS Tools for Windows PowerShell to describe the recommended monitoring configuration of a component called `my-component` in an application created on the resource group `my-resource-group`, by using the following command.

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

For more information about component configuration and for example JSON files, see [Work with component configurations](component-config.md).

### Update the monitoring configurations for a component
<a name="update-monitoring"></a>

**Update the monitoring configurations for a component using the AWS CLI**  
To use the AWS CLI to update the component called `my-component` in an application created on the resource group called `my-resource-group`, use the following command. The command includes these actions:

1. Enable monitoring for the component.

1. Set the tier of the component to `.NET Worker`.

1. Update the JSON configuration of the component to read from the local file `configuration.txt`.

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

**Update the monitoring configurations for a component using the AWS Tools for Windows PowerShell**  
To use the AWS Tools for Windows PowerShell to update the component called `my-component` in an application created on the resource group called `my-resource-group`, use the following command. The command includes these actions:

1. Enable monitoring for the component.

1. Set the tier of the component to `.NET Worker`.

1. Update the JSON configuration of the component to read from the local file `configuration.txt`.

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

For more information about component configuration and for example JSON files, see [Work with component configurations](component-config.md).

### Remove a specified resource group from Application Insights monitoring
<a name="update-monitoring"></a>

**Remove a specified resource group from Application Insights monitoring using the AWS CLI**  
To use the AWS CLI to remove an application created on the resource group called `my-resource-group` from monitoring, use the following command.

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

**Remove a specified resource group from Application Insights monitoring using the AWS Tools for Windows PowerShell**  
To use the AWS Tools for Windows PowerShell to remove an application created on the resource group called `my-resource-group` from monitoring, use the following command.

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

## Configure monitoring for SQL Always On Availability Groups
<a name="configure-sql"></a>

1. Create an application for the resource group with the SQL HA EC2 instances.

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

1. Define the EC2 instances that represent the SQL HA cluster by creating a new application component.

   ```
   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. Configure the SQL HA component.

   ```
   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
       } ]
     } ]
   }'
   ```

**Note**  
Application Insights must ingest Application Event logs (information level) to detect cluster activities such as failover.

## Configure monitoring for MySQL RDS
<a name="configure-mysql-rds"></a>

1. Create an application for the resource group with the RDS MySQL database instance.

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

1. The error log is enabled by default. The slow query log can be enabled using data parameter groups. For more information, see [Accessing the MySQL Slow Query and General Logs](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. Export the logs to be monitored to CloudWatch logs. For more information, see [Publishing MySQL Logs to CloudWatch Logs](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_LogAccess.Concepts.MySQL.html#USER_LogAccess.MySQLDB.PublishtoCloudWatchLogs).

1. Configure the MySQL RDS component.

   ```
   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}]}"
   ```

## Configure monitoring for MySQL EC2
<a name="configure-mysql-ec2"></a>

1. Create an application for the resource group with the SQL HA EC2 instances.

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

1. The error log is enabled by default. The slow query log can be enabled using data parameter groups. For more information, see [Accessing the MySQL Slow Query and General Logs](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. Configure the MySQL EC2 component.

   ```
   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\"}]}"
   ```

## Configure monitoring for PostgreSQL RDS
<a name="configure-postgresql-rds"></a>

1. Create an application for the resource group with the PostgreSQL RDS database instance.

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

1. Publishing PostgreSQL logs to CloudWatch is not enabled by default. To enable monitoring, open the RDS console and select the database to monitor. Choose **Modify** in the upper right corner, and select the check box labeled **PostgreSQL** log. Choose **Continue** to save this setting.

1. Your PostgreSQL logs are exported to CloudWatch.

1. Configure the PostgreSQL RDS component.

   ```
   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
         }
      ]
   }"
   ```

## Configure monitoring for PostgreSQL EC2
<a name="configure-postgresql-ec2"></a>

1. Create an application for the resource group with the PostgreSQL EC2 instance.

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

1. Configure the PostgreSQL EC2 component.

   ```
   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\"
         }
      ]
   }"
   ```

## Configure monitoring for Oracle RDS
<a name="configure-oracle-rds"></a>

1. Create an application for the resource group with the Oracle RDS database instance.

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

1. Publishing Oracle logs to CloudWatch is not enabled by default. To enable monitoring, open the RDS console and select the database to monitor. Choose **Modify** in the upper right corner, and select the check boxes labeled **Alert** log and **Listener** log. Choose **Continue** to save this setting.

1. Your Oracle logs are exported to CloudWatch.

1. Configure the Oracle RDS component.

   ```
   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
         }
      ]
   }"
   ```

## Configure monitoring for Oracle EC2
<a name="configure-oracle-ec2"></a>

1. Create an application for the resource group with the Oracle EC2 instance.

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

1. Configure the Oracle EC2 component.

   ```
   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,
         }
      ]
   }"
   ```

# Application Insights CloudWatch Events for detected problems
<a name="appinsights-cloudwatch-events"></a>

For each application that is added to CloudWatch Application Insights, a CloudWatch event is published for the following events on a best effort basis:
+ **Problem creation.** Emitted when CloudWatch Application Insights detects a new problem.
  + Detail Type: ** "Application Insights Problem Detected"**
  + Detail:
    + `problemId`: The detected problem ID.
    + `region`: The AWS Region where the problem was created.
    + `resourceGroupName`: The Resource Group for the registered application for which the problem was detected.
    + `status`: The status of the problem. Possible status and definitions are as follows:
      + `In progress`: A new problem has been identified. The problem is still receiving observations.
      + `Recovering`: The problem is stabilizing. You can manually resolve the problem when it is in this state. 
      + `Resolved`: The problem is resolved. There are no new observations about this problem.
      + `Recurring`: The problem was resolved within the past 24 hours. It has reopened as a result of additional observations.
    + `severity`: The severity of the problem.
    + `problemUrl`: The console URL for the problem.
+ **Problem update.** Emitted when the problem is updated with a new observation or when an existing observation is updated and the problem is subsequently updated; updates include a resolution or closure of the problem.
  + Detail Type: ** "Application Insights Problem Updated"**
  + Detail:
    + `problemId`: The created problem ID.
    + `region`: The AWS Region where the problem was created.
    + `resourceGroupName`: The Resource Group for the registered application for which the problem was detected.
    + `status`: The status of the problem.
    + `severity`: The severity of the problem.
    + `problemUrl`: The console URL for the problem.

# Receive notifications for detected problems
<a name="appinsights-problem-notifications"></a>

You can use Amazon SNS notifications, Systems Manager OpsCenter, or CloudWatch Events to receive notifications about problems that are detected in your applications. 

**CloudWatch Application Insights Amazon SNS notifications for detected problems**  
You can configure Amazon SNS notifications using the AWS Management Console or the AWS CLI. To set up notifications using the AWS Management Console, you must have the necessary Amazon SNS permissions as shown in the following example. 

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
      {
        "Effect": "Allow",
        "Action": [
          "sns:ListTopics",
          "sns:Subscribe",
          "sns:CreateTopic"
        ],    
        "Resource": [
          "*" 
        ]
      }
    ]    
}
```

------

After you set up Amazon SNS notifications, you receive email notifications when a problem is created or resolved. You also receive notifications when a new observation is added to an existing problem.

The following example shows the content of an email notification.

```
    You are receiving this email because Problem "p-1234567" has been CREATED by Amazon CloudWatch Application Insights
    
    Problem Details: 
    Problem URL: https:////console.aws.amazon.com/cloudwatch/home?region=us-east-1#settings:AppInsightsSettings/problemDetails?problemId=p-1234567
    Problem Summary: Title of the problem
    Severity: HIGH
    Insights: Something specific is broken
    Status : RESOLVED
    AffectedResource: arn:aws:ec2:us-east-1:555555555555:host/testResource
    Region: us-east-1
    RecurringCount: 0
    StartTime: 2019-03-23T10:42:57.777Z
    LastUpdatedTime: 2019-03-23T21:49:37.777Z
    LastRecurrenceTime: 
    StopTime: 2019-03-23T21:49:37.777Z
    
    Recent Issues
    - TelemetryArn:alarm1
      StartTime: 2024-08-15T22:12:46.007Z
      StopTime:
    - TelemetryArn:log-group1
      StartTime: 2024-08-15T22:12:46.007Z
      StopTime: 2024-08-15T22:12:46.007Z
```

**How to receive problem notifications using Systems Manager**  
**Actions through AWS Systems Manager.** CloudWatch Application Insights provides built-in integration with Systems Manager OpsCenter. If you choose to use this integration for your application, an OpsItem is created on the OpsCenter console for every problem detected with the application. From the OpsCenter console, you can view summarized information about the problem detected by CloudWatch Application Insights and pick a Systems Manager Automation runbook to take remedial actions or further identify Windows processes that are causing resource issues in your application. 

**How to receive problem notifications using CloudWatch Events**  
From the CloudWatch console, select **Rules** under **Events** in the left navigation pane. From the **Rules **page, select **Create rule**. Choose **Amazon CloudWatch Application Insights** from the **Service Name** dropdown list and choose the **Event Type**. Then, choose **Add target** and select the target and parameters, for example, an **SNS topic** or **Lambda function**. 