

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
<a name="appinsights-cloudformation"></a>

Sie können die Application Insights-Überwachung, einschließlich wichtiger Kennzahlen und Telemetrie, direkt aus AWS CloudFormation Vorlagen zu Ihrer Anwendung, Datenbank und Ihrem Webserver hinzufügen.

Dieser Abschnitt enthält 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 *CloudFormation Benutzerhandbuch* finden Sie unter Referenz zum [ApplicationInsights Ressourcentyp.](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_ApplicationInsights.html) 

**Topics**
+ [Erstellen Sie eine Application Insights-Anwendung für den gesamten CloudFormation Stack](#appinsights-cloudformation-apply-to-stack)
+ [Erstellen Sie eine Application-Insights-Anwendung mit detaillierten Einstellungen](#appinsights-cloudformation-apply-detailed)
+ [Erstellen Sie eine Application-Insights-Anwendung mit der `CUSTOM`-Modus-Komponentenkonfiguration](#appinsights-cloudformation-custom)
+ [Erstellen Sie eine Application-Insights-Anwendung mit der `DEFAULT`-Modus-Komponentenkonfiguration](#appinsights-cloudformation-default)
+ [Erstellen Sie eine Application-Insights-Anwendung mit der `DEFAULT_WITH_OVERWRITE`-Modus-Komponentenkonfiguration](#appinsights-cloudformation-default-with-overwrite)

## Erstellen Sie eine Application Insights-Anwendung für den gesamten CloudFormation Stack
<a name="appinsights-cloudformation-apply-to-stack"></a>

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](https://docs.aws.amazon.com/ARG/latest/userguide/gettingstarted.html).

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 [CreateApplication](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_CreateApplication.html)Befehlsdetails 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 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
```

Im folgenden Vorlagenabschnitt wird die Standardüberwachungskonfiguration auf die Application-Insights-Anwendung angewendet. Weitere Informationen finden Sie in den [CreateApplication](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_CreateApplication.html)Befehlsdetails 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 [DescribeComponentConfigurationRecommendation](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_DescribeComponentConfigurationRecommendation.html)und [UpdateComponentConfiguration](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_UpdateComponentConfiguration.html)in 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 stack
Resources:
  AppInsightsApp:
    Type: AWS::ApplicationInsights::Application
    Properties:
      ResourceGroupName: my_resource_group
      AutoConfigurationEnabled: true
```

## Erstellen Sie eine Application-Insights-Anwendung mit detaillierten Einstellungen
<a name="appinsights-cloudformation-apply-detailed"></a>

Die folgende Vorlage führt diese Aktionen aus:
+ Erstellt eine Application Insights-Anwendung mit OpsCenter aktivierter CloudWatch Ereignisbenachrichtigung. Weitere Informationen finden Sie in den [CreateApplication](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_CreateApplication.html)Befehlsdetails 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 [TagResource](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_TagResource.html)in der *Amazon CloudWatch Application Insights API-Referenz*.
+ Erstellt zwei benutzerdefinierte Instance-Gruppenkomponenten. Weitere Informationen finden Sie [CreateComponent](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_CreateComponent.html)in der *Amazon CloudWatch Application Insights API-Referenz*.
+ Erstellt zwei Protokollmustersätze. Weitere Informationen finden Sie [CreateLogPattern](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_CreateLogPattern.html)in der *Amazon CloudWatch Application Insights API-Referenz*.
+ Legt `AutoConfigurationEnabled` auf `true` fest, wodurch alle Komponenten der Anwendung mit den empfohlenen Überwachungseinstellungen für die `DEFAULT`-Ebene konfiguriert werden. Weitere Informationen finden Sie [DescribeComponentConfigurationRecommendation](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_DescribeComponentConfigurationRecommendation.html)in 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_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
```

## Erstellen Sie eine Application-Insights-Anwendung mit der `CUSTOM`-Modus-Komponentenkonfiguration
<a name="appinsights-cloudformation-custom"></a>

Die folgende Vorlage führt diese Aktionen aus:
+ Erstellt eine Application Insights-Anwendung. Weitere Informationen finden Sie [CreateApplication](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_CreateApplication.html)in der *Amazon CloudWatch Application Insights API-Referenz*.
+ Mit Komponente `my_component` wird `ComponentConfigurationMode` auf `CUSTOM` festgelegt, wodurch diese Komponente wie in `CustomComponentConfiguration` angegeben mit der Konfiguration konfiguriert wird. Weitere Informationen finden Sie [UpdateComponentConfiguration](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_UpdateComponentConfiguration.html)in 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
<a name="appinsights-cloudformation-default"></a>

Die folgende Vorlage führt diese Aktionen aus:
+ Erstellt eine Application Insights-Anwendung. Weitere Informationen finden Sie [CreateApplication](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_CreateApplication.html)in der *Amazon CloudWatch Application Insights API-Referenz*.
+ Mit Komponente `my_component` wird `ComponentConfigurationMode` auf `DEFAULT` und `Tier` auf `SQL_SERVER` festgelegt, wodurch diese Komponente mit den Konfigurationseinstellungen konfiguriert wird, die Application Insights für Ebene `SQL_Server` empfiehlt. Weitere Informationen finden Sie unter [DescribeComponentConfiguration](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_DescribeComponentConfiguration.html)und [UpdateComponentConfiguration](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_UpdateComponentConfiguration.html)in 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_group
  ComponentMonitoringSettings:
  - ComponentARN: my_component
    Tier: SQL_SERVER
    ComponentConfigurationMode: DEFAULT
```

## Erstellen Sie eine Application-Insights-Anwendung mit der `DEFAULT_WITH_OVERWRITE`-Modus-Komponentenkonfiguration
<a name="appinsights-cloudformation-default-with-overwrite"></a>

Die folgende Vorlage führt diese Aktionen aus:
+ Erstellt eine Application Insights-Anwendung. Weitere Informationen finden Sie [CreateApplication](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_CreateApplication.html)in der *Amazon CloudWatch Application Insights API-Referenz*.
+ Mit Komponente `my_component` wird `ComponentConfigurationMode` auf `DEFAULT_WITH_OVERWRITE` und `tier` auf `DOT_NET_CORE` festgelegt, wodurch diese Komponente mit den Konfigurationseinstellungen konfiguriert wird, die Application Insights für Ebene `DOT_NET_CORE` empfiehlt. Außer Kraft gesetzte Konfigurationseinstellungen werden in `DefaultOverwriteComponentConfiguration` angegeben: 
  + Auf Komponentenebene werden `AlarmMetrics`-Einstellungen außer Kraft gesetzt.
  + Auf der Unterkomponentenebene werden die `Logs`-Einstellungen für die Unterkomponenten des `EC2_Instance`-Typs außer Kraft gesetzt.

  Weitere Informationen finden Sie [UpdateComponentConfiguration](https://docs.aws.amazon.com/cloudwatch/latest/APIReference/API_UpdateComponentConfiguration.html)in 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_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
```