AWS::ApplicationInsights::Application - AWS CloudFormation
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

AWS::ApplicationInsights::Application

AWS::ApplicationInsights::Application 资源添加从资源组创建的应用程序。

语法

要在 AWS CloudFormation 模板中声明此实体,请使用以下语法:

JSON

{ "Type" : "AWS::ApplicationInsights::Application", "Properties" : { "AutoConfigurationEnabled" : Boolean, "ComponentMonitoringSettings" : [ ComponentMonitoringSetting, ... ], "CustomComponents" : [ CustomComponent, ... ], "CWEMonitorEnabled" : Boolean, "LogPatternSets" : [ LogPatternSet, ... ], "OpsCenterEnabled" : Boolean, "OpsItemSNSTopicArn" : String, "ResourceGroupName" : String, "Tags" : [ Tag, ... ] } }

属性

AutoConfigurationEnabled

如果设置为 true,将使用 Application Insights 建议的监控配置来配置应用程序组件。

必需:否

类型:布尔值

Update requires: No interruption

ComponentMonitoringSettings

组件的监控设置。

必需:否

类型ComponentMonitoringSetting 的列表

Update requires: No interruption

CustomComponents

通过对要监控的类似独立实例进行分组来描述自定义组件。

必需:否

类型CustomComponent 的列表

Update requires: No interruption

CWEMonitorEnabled

指示 Application Insights 是否可以侦听应用程序资源的 CloudWatch 事件(如 instance terminatedfailed deployment 和其他)。

必需:否

类型:布尔值

Update requires: No interruption

LogPatternSets

日志模式集。

必需:否

类型LogPatternSet 的列表

Update requires: No interruption

OpsCenterEnabled

指示 Application Insights 是否将为 Application Insights 针对应用程序检测到的任何问题创建 OpsItem。

必需:否

类型:布尔值

Update requires: No interruption

OpsItemSNSTopicArn

提供给 Application Insights 的 SNS 主题,该主题与已创建的 opsItem 关联,以接收有关 opsItem 更新的 SNS 通知。

必需:否

类型:字符串

最低20

最高300

模式^arn:aws(-\w+)?:[\w\d-]+:([\w\d-]*)?:[\w\d_-]*([:/].+)*$

Update requires: No interruption

ResourceGroupName

用于应用程序的资源组的名称。

必需:是

类型:字符串

最低1

最高256

模式[a-zA-Z0-9\.\-_]*

Update requires: Replacement

Tags

Tags 数组。

必需:否

类型Tag 的列表

Update requires: No interruption

返回值

Ref

在将此资源的逻辑 ID 传递给内部 Ref 函数时,Ref 返回应用程序的 Amazon 资源名称 (ARN),如 arn:aws:applicationinsights:us-east-1:123456789012:application/resource-group/my_resource_group

For more information about using the Ref function, see Ref.

Fn::GetAtt

Fn::GetAtt 内部函数返回此类型的一个指定属性的值。以下为可用属性和示例返回值。

有关使用 Fn::GetAtt 内部函数的更多信息,请参阅 Fn::GetAtt

ApplicationARN

返回应用程序的 Amazon 资源名称 (ARN),如 arn:aws:applicationinsights:us-east-1:123456789012:application/resource-group/my_resource_group

示例

以下示例模板执行以下操作:

  • 创建 Application Insights 应用程序。有关更多信息,请参阅 Amazon CloudWatch Application Insights API 参考 中的 CreateApplication

  • AutoConfigurationEnabled 设置为 true,这会使用 DEFAULT 层的建议监控设置来配置应用程序的所有组件。有关更多信息,请参阅 Amazon CloudWatch Application Insights API 参考 中的 DescribeComponentConfigurationRecommendation

--- Type: AWS::ApplicationInsights::Application Properties: ResourceGroupName: my_resource_group AutoConfigurationEnabled: true
{ "Type": "AWS::ApplicationInsights::Application", "Properties": { "ResourceGroupName": "my_resource_group", "AutoConfigurationEnabled": true } }

以下示例模板创建具有详细设置的 Application Insights 应用程序

以下示例模板执行以下操作:

  • 创建启用了 CloudWatch 事件通知并启用 OpsCenter 的 Application Insights 应用程序。有关更多信息,请参阅 Amazon CloudWatch Application Insights API 参考 中的 CreateApplication

  • 使用两个标签来标记应用程序,其中一个标签没有标签值。有关更多信息,请参阅 Amazon CloudWatch Application Insights API 参考 中的 TagResource

  • 创建两个自定义实例组组件。有关更多信息,请参阅 Amazon CloudWatch Application Insights API 参考 中的 CreateComponent

  • 创建两个日志模式集。有关更多信息,请参阅 Amazon CloudWatch Application Insights API 参考 中的 CreateLogPattern

  • AutoConfigurationEnabled 设置为 true,这会使用 DEFAULT 层的建议监控设置来配置应用程序的所有组件。有关更多信息,请参阅 Amazon CloudWatch Application Insights API 参考 中的 DescribeComponentConfigurationRecommendation

YAML

--- Type: AWS::ApplicationInsights::Application Properties: ResourceGroupName: my_resource_group CWEMonitorEnabled: true OpsCenterEnabled: true OpsItemSNSTopicArn: arn:aws:sns:us-east-1:123456789012:my_topic AutoConfigurationEnabled: true Tags: - Key: key1 Value: value1 - Key: key2 Value: '' CustomComponents: - ComponentName: test_component_1 ResourceList: - arn:aws:ec2:us-east-1:123456789012:instance/i-XXXXX - ComponentName: test_component_2 ResourceList: - arn:aws:ec2:us-east-1:123456789012:instance/i-YYYYY - arn:aws:ec2:us-east-1:123456789012:instance/i-ZZZZZ LogPatternSets: - PatternSetName: pattern_set_1 LogPatterns: - PatternName: deadlock_pattern Pattern: ".*\\sDeadlocked\\sSchedulers(([^\\w].*)|($))" Rank: 1 - PatternSetName: pattern_set_2 LogPatterns: - PatternName: error_pattern Pattern: ".*[\\s\\[]ERROR[\\s\\]].*" Rank: 1 - PatternName: warning_pattern Pattern: ".*[\\s\\[]WARN(ING)?[\\s\\]].*" Rank: 10

JSON

{ "Type": "AWS::ApplicationInsights::Application", "Properties": { "ResourceGroupName": "my_resource_group", "CWEMonitorEnabled": true, "OpsCenterEnabled": true, "OpsItemSNSTopicArn": "arn:aws:sns:us-east-1:123456789012:my_topic", "AutoConfigurationEnabled": true, "Tags": [ { "Key": "key1", "Value": "value1" }, { "Key": "key2", "Value": "" } ], "CustomComponents": [ { "ComponentName": "test_component_1", "ResourceList": [ "arn:aws:ec2:us-east-1:123456789012:instance/i-XXXXX" ] }, { "ComponentName": "test_component_2", "ResourceList": [ "arn:aws:ec2:us-east-1:123456789012:instance/i-YYYYY", "arn:aws:ec2:us-east-1:123456789012:instance/i-ZZZZZ" ] } ], "LogPatternSets": [ { "PatternSetName": "pattern_set_1", "LogPatterns": [ { "PatternName": "deadlock_pattern", "Pattern": ".*\\sDeadlocked\\sSchedulers(([^\\w].*)|($))", "Rank": 1 } ] }, { "PatternSetName": "pattern_set_2", "LogPatterns": [ { "PatternName": "error_pattern", "Pattern": ".*[\\s\\[]ERROR[\\s\\]].*", "Rank": 1 }, { "PatternName": "warning_pattern", "Pattern": ".*[\\s\\[]WARN(ING)?[\\s\\]].*", "Rank": 10 } ] } ] } }

以下示例模板使用 CUSTOM 模式组件配置创建 Application Insights 应用程序

以下示例模板执行以下操作:

  • 创建 Application Insights 应用程序。有关更多信息,请参阅 Amazon CloudWatch Application Insights API 参考 中的 CreateApplication

  • 组件 my_componentComponentConfigurationMode 设置为 CUSTOM,这将导致按照 CustomComponentConfiguration 中指定的方式配置此组件。有关更多信息,请参阅 Amazon CloudWatch Application Insights API 参考 中的 UpdateComponentConfiguration

YAML

--- Type: AWS::ApplicationInsights::Application Properties: ResourceGroupName: my_resource_group ComponentMonitoringSettings: - ComponentARN: my_component Tier: SQL_SERVER ComponentConfigurationMode: CUSTOM CustomComponentConfiguration: ConfigurationDetails: AlarmMetrics: - AlarmMetricName: StatusCheckFailed ... Logs: - LogGroupName: my_log_group_1 LogPath: C:\LogFolder_1\* LogType: DOT_NET_CORE Encoding: utf-8 PatternSet: my_pattern_set_1 ... WindowsEvents: - LogGroupName: my_windows_event_log_group_1 EventName: Application EventLevels: - ERROR - WARNING ... Encoding: utf-8 PatternSet: my_pattern_set_2 ... Alarms: - AlarmName: my_alarm_name Severity: HIGH ... SubComponentTypeConfigurations: - SubComponentType: EC2_INSTANCE SubComponentConfigurationDetails: AlarmMetrics: - AlarmMetricName: DiskReadOps ... Logs: - LogGroupName: my_log_group_2 LogPath: C:\LogFolder_2\* LogType: IIS Encoding: utf-8 PatternSet: my_pattern_set_3 ... WindowsEvents: - LogGroupName: my_windows_event_log_group_2 EventName: Application EventLevels: - ERROR - WARNING ... Encoding: utf-8 PatternSet: my_pattern_set_4 ...

JSON

{ "Type": "AWS::ApplicationInsights::Application", "Properties": { "ResourceGroupName": "my_resource_group", "ComponentMonitoringSettings": [ { "ComponentARN": "my_component", "Tier": "SQL_SERVER", "ComponentConfigurationMode": "CUSTOM", "CustomComponentConfiguration": { "ConfigurationDetails": { "AlarmMetrics": [ { "AlarmMetricName": "StatusCheckFailed" }, ... ], "Logs": [ { "LogGroupName": "my_log_group_1", "LogPath": "C:\\LogFolder_1\\*", "LogType": "DOT_NET_CORE", "Encoding": "utf-8", "PatternSet": "my_pattern_set_1" }, ... ], "WindowsEvents": [ { "LogGroupName": "my_windows_event_log_group_1", "EventName": "Application", "EventLevels": [ "ERROR", "WARNING", ... ], "Encoding": "utf-8", "PatternSet": "my_pattern_set_2" }, ... ], "Alarms": [ { "AlarmName": "my_alarm_name", "Severity": "HIGH" }, ... ] }, "SubComponentTypeConfigurations": [ { "SubComponentType": "EC2_INSTANCE", "SubComponentConfigurationDetails": { "AlarmMetrics": [ { "AlarmMetricName": "DiskReadOps" }, ... ], "Logs": [ { "LogGroupName": "my_log_group_2", "LogPath": "C:\\LogFolder_2\\*", "LogType": "IIS", "Encoding": "utf-8", "PatternSet": "my_pattern_set_3" }, ... ], "WindowsEvents": [ { "LogGroupName": "my_windows_event_log_group_2", "EventName": "Application", "EventLevels": [ "ERROR", "WARNING", ... ], "Encoding": "utf-8", "PatternSet": "my_pattern_set_4" }, ... ] } } ] } } ] } }

以下示例模板使用 DEFAULT 模式组件配置创建 Application Insights 应用程序

以下示例模板执行以下操作:

  • 创建 Application Insights 应用程序。有关更多信息,请参阅 Amazon CloudWatch Application Insights API 参考 中的 CreateApplication

  • 组件 my_componentComponentConfigurationMode 设置为 DEFAULT,并将 Tier 设置为 SQL_SERVER,这将导致使用 Application Insights 为 SQL_Server 层推荐的配置设置来配置此组件。有关更多信息,请参阅 Amazon CloudWatch Application Insights API 参考 中的 DescribeComponentConfigurationUpdateComponentConfiguration

YAML

--- Type: AWS::ApplicationInsights::Application Properties: ResourceGroupName: my_resource_group ComponentMonitoringSettings: - ComponentARN: my_component Tier: SQL_SERVER ComponentConfigurationMode: DEFAULT

JSON

{ "Type": "AWS::ApplicationInsights::Application", "Properties": { "ResourceGroupName": "my_resource_group", "ComponentMonitoringSettings": [ { "ComponentARN": "my_component", "Tier": "SQL_SERVER", "ComponentConfigurationMode": "DEFAULT" } ] } }

以下示例模板使用 DEFAULT_WITH_OVERWRITE 模式组件配置创建 Application Insights 应用程序

以下示例模板执行以下操作:

  • 创建 Application Insights 应用程序。有关更多信息,请参阅 Amazon CloudWatch Application Insights API 参考 中的 CreateApplication

  • 组件 my_componentComponentConfigurationMode 设置为 DEFAULT_WITH_OVERWRITE,并将 tier 设置为 DOT_NET_CORE,这将导致使用 Application Insights 为 DOT_NET_CORE 层推荐的配置设置来配置此组件。覆盖的配置设置在 DefaultOverwriteComponentConfiguration 中指定:

    • 在组件级别,AlarmMetrics 设置将被覆盖。

    • 在子组件级别,对于 EC2_Instance 类型的子组件,将覆盖 Logs 设置。

    有关更多信息,请参阅 Amazon CloudWatch Application Insights API 参考 中的 UpdateComponentConfiguration

YAML

--- Type: AWS::ApplicationInsights::Application Properties: ResourceGroupName: my_resource_group ComponentMonitoringSettings: - ComponentName: my_component Tier: DOT_NET_CORE ComponentConfigurationMode: DEFAULT_WITH_OVERWRITE DefaultOverwriteComponentConfiguration: ConfigurationDetails: AlarmMetrics: - AlarmMetricName: StatusCheckFailed SubComponentTypeConfigurations: - SubComponentType: EC2_INSTANCE SubComponentConfigurationDetails: Logs: - LogGroupName: my_log_group LogPath: C:\LogFolder\* LogType: IIS Encoding: utf-8 PatternSet: my_pattern_set

JSON

{ "Type": "AWS::ApplicationInsights::Application", "Properties": { "ResourceGroupName": "my_resource_group", "ComponentMonitoringSettings": [ { "ComponentName": "my_component", "Tier": "DOT_NET_CORE", "ComponentConfigurationMode": "DEFAULT_WITH_OVERWRITE", "DefaultOverwriteComponentConfiguration": { "ConfigurationDetails": { "AlarmMetrics": [ { "AlarmMetricName": "StatusCheckFailed" } ] }, "SubComponentTypeConfigurations": [ { "SubComponentType": "EC2_INSTANCE", "SubComponentConfigurationDetails": { "Logs": [ { "LogGroupName": "my_log_group", "LogPath": "C:\\LogFolder\\*", "LogType": "IIS", "Encoding": "utf-8", "PatternSet": "my_pattern_set" } ] } } ] } } ] } }