

# 配置应用程序进行监控的先决条件
<a name="appinsights-prereqs"></a>

您必须完成以下必需任务才能使用 CloudWatch Application Insights 配置应用程序：
+ **AWS Systems Manager 启用** – 在 Amazon EC2 实例上安装 Systems Manager Agent（SSM Agent），并启用 SSM 实例。有关如何安装 SSM Agent 的信息，请参阅《AWS Systems Manager 用户指南》中的[设置 AWS Systems Manager](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-setting-up.html)**。
+ **EC2 实例角色** – 您必须附加以下 Amazon EC2 实例角色，才能启用 Systems Manager
  + 要启用 Systems Manager，您必须附加 `AmazonSSMManagedInstanceCore` 角色。有关更多信息，请参阅 [AWS Systems Manager 基于身份的策略示例](https://docs.aws.amazon.com/systems-manager/latest/userguide/auth-and-access-control-iam-identity-based-access-control.html)。
  + 要使实例指标和日志通过 CloudWatch 发出，您必须附加 `CloudWatchAgentServerPolicy` 策略。有关更多信息，请参阅[创建用于 CloudWatch 代理的 IAM 角色和用户](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-iam-roles-for-cloudwatch-agent.html)
+ **AWS Resource Groups** – 要将应用程序添加到 CloudWatch Application Insights，请创建一个包含应用程序堆栈所用的所有相关 AWS 资源的资源组。这包括应用程序负载均衡器、运行 IIS 和 Web 前端的 Amazon EC2 实例、.NET 工作线程层和 SQL Server 数据库。有关 Application Insights 支持的应用程序组件和技术堆栈的更多信息，请参阅 [支持的应用程序组件](appinsights-what-is.md#appinsights-components)。CloudWatch Application Insights 自动包含使用与资源组相同的标签或 CloudFormation 堆栈的自动扩缩组，因为 CloudFormation 资源组不支持自动扩缩组。有关更多信息，请参阅 [AWS Resource Groups 入门](https://docs.aws.amazon.com/ARG/latest/userguide/gettingstarted.html)。
+ **IAM 权限** – 对于没有管理访问权限的用户，必须创建允许 Application Insights 创建服务相关角色的 AWS Identity and Access Management（IAM）policy，并将其附加到用户身份。有关如何创建 IAM policy 的更多信息，请参阅 [CloudWatch Application Insights 的 IAM 策略](appinsights-iam.md)。
+ **服务相关角色** – Application Insights 使用 AWS Identity and Access Management（IAM）服务相关角色。当您在 Application Insights 控制台中创建首个 Application Insights 应用程序时，将会为您创建服务相关角色。有关更多信息，请参阅 [在 CloudWatch Application Insights 中使用服务相关角色](CHAP_using-service-linked-roles-appinsights.md)。
+ **EC2 Windows 实例对性能计数器指标的支持** – 要在 Amazon EC2 Windows 实例上监控性能计数器指标，必须在实例上安装性能计数器。有关性能计数器指标和相应的性能计数器集名称，请参阅[性能计数器指标](application-insights-performance-counter.md)。有关性能计数器的更多信息，请参阅[性能计数器](https://docs.microsoft.com/en-us/windows/win32/perfctrs/performance-counters-portal)。
+ **Amazon CloudWatch 代理** – Application Insights 安装和配置 CloudWatch 代理。如果您安装了 CloudWatch 代理，则 Application Insights 会保留您的配置。为避免合并冲突，请从现有 CloudWatch 代理配置文件中删除您想在 Application Insights 中使用的资源的配置。有关更多信息，请参阅 [手动创建或编辑 CloudWatch 代理配置文件](CloudWatch-Agent-Configuration-File-Details.md)。