Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.
Erstellen und konfigurieren Sie das CloudWatch Application Insights-Monitoring mithilfe von Vorlagen CloudFormation
Sie können Application Insights-Monitoring, einschließlich wichtiger Kennzahlen und Telemetrie, direkt aus AWS CloudFormation Vorlagen zu Ihrer Anwendung, Datenbank und Ihrem Webserver hinzufügen.
Dieser Abschnitt enthält AWS CloudFormation Beispielvorlagen im JSON- und YAML-Format, die Sie bei der Erstellung und Konfiguration der Application Insights-Überwachung unterstützen.
Die Ressourcen- und Eigenschaftsreferenz zu Application Insights im AWS CloudFormation Benutzerhandbuch finden Sie unter Referenz zum ApplicationInsights Ressourcentyp.
Mustervorlagen
Erstellen Sie eine Application Insights-Anwendung für den gesamten AWS CloudFormation Stack
Erstellen Sie eine Application-Insights-Anwendung mit detaillierten Einstellungen
Erstellen Sie eine Application-Insights-Anwendung mit der CUSTOM-Modus-Komponentenkonfiguration
Erstellen Sie eine Application-Insights-Anwendung mit der DEFAULT-Modus-Komponentenkonfiguration
Erstellen Sie eine Application Insights-Anwendung für den gesamten AWS CloudFormation Stack
Um die folgende Vorlage anzuwenden, müssen Sie AWS Ressourcen und eine oder mehrere Ressourcengruppen erstellen, aus denen Sie Application Insights-Anwendungen zur Überwachung dieser Ressourcen erstellen können. Weitere Informationen finden Sie unter Erste Schritte mit AWS Resource Groups.
Die ersten beiden Teile der folgenden Vorlage geben eine Ressource und eine Ressourcengruppe an. Im letzten Teil der Vorlage wird eine Application-Insights-Anwendung für die Ressourcengruppe erstellt, die Anwendung jedoch nicht konfiguriert oder die Überwachung angewendet. Weitere Informationen finden Sie in den CreateApplicationBefehlsdetails in der Amazon CloudWatch Application Insights API-Referenz.
Vorlage im JSON-Format
{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "Test Resource Group stack", "Resources": { "EC2Instance": { "Type": "AWS::EC2::Instance", "Properties": { "ImageId" : "ami-abcd1234efgh5678i", "SecurityGroupIds" : ["sg-abcd1234"] } }, ... "ResourceGroup": { "Type": "AWS::ResourceGroups::Group", "Properties": { "Name": "my_resource_group" } }, "AppInsightsApp": { "Type": "AWS::ApplicationInsights::Application", "Properties": { "ResourceGroupName": "my_resource_group" }, "DependsOn" : "ResourceGroup" } } }
Vorlage im YAML-Format
--- AWSTemplateFormatVersion: '2010-09-09' Description:Test Resource Group stackResources: EC2Instance: Type: AWS::EC2::Instance Properties: ImageId: ami-abcd1234efgh5678iSecurityGroupIds: - sg-abcd1234... ResourceGroup: Type: AWS::ResourceGroups::Group Properties: Name:my_resource_groupAppInsightsApp: Type: AWS::ApplicationInsights::Application Properties: ResourceGroupName:my_resource_groupDependsOn: ResourceGroup
Im folgenden Vorlagenabschnitt wird die Standardüberwachungskonfiguration auf die Application-Insights-Anwendung angewendet. Weitere Informationen finden Sie in den CreateApplicationBefehlsdetails in der Amazon CloudWatch Application Insights API-Referenz.
Wenn AutoConfigurationEnabled auf true gesetzt ist, werden alle Komponenten der Anwendung mit den empfohlenen Überwachungseinstellungen für die Anwendungsebene DEFAULT konfiguriert. Weitere Informationen zu diesen Einstellungen und Stufen finden Sie unter DescribeComponentConfigurationRecommendationund UpdateComponentConfigurationin der Amazon CloudWatch Application Insights API-Referenz.
Vorlage im JSON-Format
{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "Test Application Insights Application stack", "Resources": { "AppInsightsApp": { "Type": "AWS::ApplicationInsights::Application", "Properties": { "ResourceGroupName": "my_resource_group", "AutoConfigurationEnabled": true } } } }
Vorlage im YAML-Format
--- AWSTemplateFormatVersion: '2010-09-09' Description:Test Application Insights Application stackResources: AppInsightsApp: Type: AWS::ApplicationInsights::Application Properties: ResourceGroupName:my_resource_groupAutoConfigurationEnabled: true
Erstellen Sie eine Application-Insights-Anwendung mit detaillierten Einstellungen
Die folgende Vorlage führt diese Aktionen aus:
-
Erstellt eine Application Insights-Anwendung mit OpsCenter aktivierter CloudWatch Ereignisbenachrichtigung. Weitere Informationen finden Sie in den CreateApplicationBefehlsdetails in der Amazon CloudWatch Application Insights API-Referenz.
-
Markiert die Anwendung mit zwei Tags, von denen eines keine Tag-Werte enthält. Weitere Informationen finden Sie TagResourcein der Amazon CloudWatch Application Insights API-Referenz.
-
Erstellt zwei benutzerdefinierte Instance-Gruppenkomponenten. Weitere Informationen finden Sie CreateComponentin der Amazon CloudWatch Application Insights API-Referenz.
-
Erstellt zwei Protokollmustersätze. Weitere Informationen finden Sie CreateLogPatternin der Amazon CloudWatch Application Insights API-Referenz.
-
Legt
AutoConfigurationEnabledauftruefest, wodurch alle Komponenten der Anwendung mit den empfohlenen Überwachungseinstellungen für dieDEFAULT-Ebene konfiguriert werden. Weitere Informationen finden Sie DescribeComponentConfigurationRecommendationin der Amazon CloudWatch Application Insights API-Referenz.
Vorlage im JSON-Format
{ "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-abcd1234efgh5678i" ] }, { "ComponentName": "test_component_2", "ResourceList": [ "arn:aws:ec2:us-east-1:123456789012:instance/i-abcd1234efgh5678i", "arn:aws:ec2:us-east-1:123456789012:instance/i-abcd1234efgh5678i" ] } ], "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 } ] } ] } }
Vorlage im YAML-Format
--- Type: AWS::ApplicationInsights::Application Properties: ResourceGroupName:my_resource_groupCWEMonitorEnabled: true OpsCenterEnabled: true OpsItemSNSTopicArn: arn:aws:sns:us-east-1:123456789012:my_topicAutoConfigurationEnabled: true Tags: - Key:key1Value:value1- Key:key2Value: '' CustomComponents: - ComponentName:test_component_1ResourceList: - arn:aws:ec2:us-east-1:123456789012:instance/i-abcd1234efgh5678i- ComponentName: test_component_2 ResourceList: - arn:aws:ec2:us-east-1:123456789012:instance/i-abcd1234efgh5678i- arn:aws:ec2:us-east-1:123456789012:instance/i-abcd1234efgh5678iLogPatternSets: - 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
Erstellen Sie eine Application-Insights-Anwendung mit der CUSTOM-Modus-Komponentenkonfiguration
Die folgende Vorlage führt diese Aktionen aus:
-
Erstellt eine Application Insights-Anwendung. Weitere Informationen finden Sie CreateApplicationin der Amazon CloudWatch Application Insights API-Referenz.
-
Mit Komponente
my_componentwirdComponentConfigurationModeaufCUSTOMfestgelegt, wodurch diese Komponente wie inCustomComponentConfigurationangegeben mit der Konfiguration konfiguriert wird. Weitere Informationen finden Sie UpdateComponentConfigurationin der Amazon CloudWatch Application Insights API-Referenz.
Vorlage im JSON-Format
{ "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" }, ... ], "processes" : [ { "processName" : "my_process", "alarmMetrics" : [ { "alarmMetricName" : "procstat cpu_usage", "monitor" : true }, { "alarmMetricName" : "procstat memory_rss", "monitor" : true } ] } ], "WindowsEvents": [ { "LogGroupName": "my_windows_event_log_group_2", "EventName": "Application", "EventLevels": [ "ERROR", "WARNING", ... ], "Encoding": "utf-8", "PatternSet": "my_pattern_set_4" }, ... ] } } ] } } ] } }
Vorlage im YAML-Format
--- 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 ... Processes: - ProcessName: my_process AlarmMetrics: - AlarmMetricName: procstat cpu_usage ... ... WindowsEvents: - LogGroupName: my_windows_event_log_group_2 EventName: Application EventLevels: - ERROR - WARNING ... Encoding: utf-8 PatternSet: my_pattern_set_4 ...
Erstellen Sie eine Application-Insights-Anwendung mit der DEFAULT-Modus-Komponentenkonfiguration
Die folgende Vorlage führt diese Aktionen aus:
-
Erstellt eine Application Insights-Anwendung. Weitere Informationen finden Sie CreateApplicationin der Amazon CloudWatch Application Insights API-Referenz.
-
Mit Komponente
my_componentwirdComponentConfigurationModeaufDEFAULTundTieraufSQL_SERVERfestgelegt, wodurch diese Komponente mit den Konfigurationseinstellungen konfiguriert wird, die Application Insights für EbeneSQL_Serverempfiehlt. Weitere Informationen finden Sie unter DescribeComponentConfigurationund UpdateComponentConfigurationin der Amazon CloudWatch Application Insights API-Referenz.
Vorlage im JSON-Format
{ "Type": "AWS::ApplicationInsights::Application", "Properties": { "ResourceGroupName": "my_resource_group", "ComponentMonitoringSettings": [ { "ComponentARN": "my_component", "Tier": "SQL_SERVER", "ComponentConfigurationMode": "DEFAULT" } ] } }
Vorlage im YAML-Format
--- Type: AWS::ApplicationInsights::Application Properties: ResourceGroupName:my_resource_groupComponentMonitoringSettings: - ComponentARN:my_componentTier: SQL_SERVER ComponentConfigurationMode: DEFAULT
Erstellen Sie eine Application-Insights-Anwendung mit der DEFAULT_WITH_OVERWRITE-Modus-Komponentenkonfiguration
Die folgende Vorlage führt diese Aktionen aus:
-
Erstellt eine Application Insights-Anwendung. Weitere Informationen finden Sie CreateApplicationin der Amazon CloudWatch Application Insights API-Referenz.
-
Mit Komponente
my_componentwirdComponentConfigurationModeaufDEFAULT_WITH_OVERWRITEundtieraufDOT_NET_COREfestgelegt, wodurch diese Komponente mit den Konfigurationseinstellungen konfiguriert wird, die Application Insights für EbeneDOT_NET_COREempfiehlt. Außer Kraft gesetzte Konfigurationseinstellungen werden inDefaultOverwriteComponentConfigurationangegeben:-
Auf Komponentenebene werden
AlarmMetrics-Einstellungen außer Kraft gesetzt. -
Auf der Unterkomponentenebene werden die
Logs-Einstellungen für die Unterkomponenten desEC2_Instance-Typs außer Kraft gesetzt.
Weitere Informationen finden Sie UpdateComponentConfigurationin der Amazon CloudWatch Application Insights API-Referenz.
-
Vorlage im JSON-Format
{ "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" } ] } } ] } } ] } }
Vorlage im YAML-Format
--- Type: AWS::ApplicationInsights::Application Properties: ResourceGroupName:my_resource_groupComponentMonitoringSettings: - ComponentName:my_componentTier: DOT_NET_CORE ComponentConfigurationMode: DEFAULT_WITH_OVERWRITE DefaultOverwriteComponentConfiguration: ConfigurationDetails: AlarmMetrics: - AlarmMetricName: StatusCheckFailed SubComponentTypeConfigurations: - SubComponentType: EC2_INSTANCE SubComponentConfigurationDetails: Logs: - LogGroupName:my_log_groupLogPath: C:\LogFolder\* LogType: IIS Encoding: utf-8 PatternSet:my_pattern_set