コマンドラインを使用してモニターリングするアプリケーションをセットアップ、設定、管理する - Amazon CloudWatch

コマンドラインを使用してモニターリングするアプリケーションをセットアップ、設定、管理する

このセクションでは、AWS CLI および AWS Tools for Windows PowerShell を使用して、モニターリング用アプリケーションをセットアップ、設定、管理する手順について説明します。

アプリケーションの追加と管理

コマンドラインを使用して、Application Insights アプリケーションの追加、情報の取得、管理、設定を行うことができます。

アプリケーションを追加する

AWS CLI を使用してアプリケーションを追加する

AWS CLI を使用して、リソースグループ名が my-resource-group のアプリケーションを追加し、作成された opsItem が SNS トピック (ARN arn:aws:sns:us-east-1:123456789012:MyTopic) に対し配信されるように OpsCenter を有効化するには、次のコマンドを使用します。

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
AWS Tools for Windows PowerShell を使用してアプリケーションを追加する

AWS Tools for Windows PowerShell を使用して、リソースグループ名が my-resource-group のアプリケーションを追加し、作成された opsItem が SNS トピック ARN arn:aws:sns:us-east-1:123456789012:MyTopic に配信されるように OpsCenter を有効化するには、次のコマンドを使用します。

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

アプリケーションを記述する

AWS CLI を使用してアプリケーションを記述する

AWS CLI を使用して、my-resource-group というリソースグループに作成されたアプリケーションを記述するには、次のコマンドを使用します。

aws application-insights describe-application --resource-group-name my-resource-group
AWS Tools for Windows PowerShell を使用してアプリケーションを記述する

AWS Tools for Windows PowerShell を使用して、my-resource-group というリソースグループに作成されたアプリケーションを記述するには、次のコマンドを使用します。

Get-CWAIApplication -ResourceGroupName my-resource-group

アプリケーションのコンポーネントをリスト化する

AWS CLI を使用してアプリケーションのコンポーネントを一覧表示する

AWS CLI を使用して、my-resource-group というリソースグループで作成されたコンポーネントを一覧表示するには、次のコマンドを使用します。

aws application-insights list-components --resource-group-name my-resource-group
AWS Tools for Windows PowerShell を使用してアプリケーションのコンポーネントを一覧表示する

AWS Tools for Windows PowerShell を使用して、my-resource-group というリソースグループで作成されたコンポーネントを一覧表示するには、次のコマンドを使用します。

Get-CWAIComponentList -ResourceGroupName my-resource-group

コンポーネントを記述する

AWS CLI を使用してコンポーネントを記述する

次の AWS CLI コマンドを使用して、my-resource-group というリソースグループで作成されたアプリケーションに属する my-component というコンポーネントを記述できます。

aws application-insights describe-component --resource-group-name my-resource-group --component-name my-component
AWS Tools for Windows PowerShell を使用してコンポーネントを記述する

次の AWS Tools for Windows PowerShell コマンドを使用して、my-resource-group というリソースグループで作成されたアプリケーションに属する my-component というコンポーネントを記述できます。

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

類似したリソースをカスタムコンポーネントとしてグループ化する

類似したリソース (.NET ウェブサーバーインスタンスなど) をカスタムコンポーネントとしてグループ化することをお勧めします。これにより、オンボードが容易になり、モニターリングとインサイトが向上します。現在、CloudWatch Application Insights は EC2 インスタンスのカスタムグループをサポートしています。

AWS CLI を使用してリソースをカスタムコンポーネントとしてグループ化するには

AWS CLI を使用して 3 つのインスタンス (arn:aws:ec2:us-east-1:123456789012:instance/i-11111arn:aws:ec2:us-east-1:123456789012:instance/i-22222 および arn:aws:ec2:us-east-1:123456789012:instance/i-33333) をグループ化し、リソースグループ名 my-component で作成されたアプリケーション用としてカスタムコンポーネント my-resource-group に含めるには、次のコマンドを使用します。

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
AWS Tools for Windows PowerShell を使用してリソースをカスタムコンポーネントとしてグループ化するには

AWS Tools for Windows PowerShell を使用して 3 つのインスタンス (arn:aws:ec2:us-east-1:123456789012:instance/i-11111arn:aws:ec2:us-east-1:123456789012:instance/i-22222、および arn:aws:ec2:us-east-1:123456789012:instance/i-33333) をまとめて、my-component というリソースグループ用に作成されたアプリケーションに対して my-resource-group というカスタムコンポーネントとしてグループ化するには、次のコマンドを使用します。

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

カスタムコンポーネントをグループ解除する

AWS CLI を使用してカスタムコンポーネントのグループ化を解除するには

AWS CLI を使用して、リソースグループ my-resource-group で作成したアプリケーションの my-component という名前のカスタムコンポーネントのグループを解除するには、次のコマンドを使用します。

aws application-insights delete-component --resource-group-name my-resource-group --component-name my-new-component
AWS Tools for Windows PowerShell を使用してカスタムコンポーネントのグループ化を解除するには

AWS Tools for Windows PowerShell を使用して、リソースグループ my-resource-group で作成したアプリケーションの my-component という名前のカスタムコンポーネントのグループを解除するには、次のコマンドを使用します。

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

アプリケーションを更新する

AWS CLI を使用してアプリケーションを更新する

AWS CLI を使用してアプリケーションを更新し、そのアプリケーションで検出された問題について AWS Systems Manager OpsCenter の OpsItems を生成し、作成された OpsItems を SNS トピック arn:aws:sns:us-east-1:123456789012:MyTopic に関連付けるには、次のコマンドを使用します。

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
AWS Tools for Windows PowerShell を使用してアプリケーションを更新する

AWS Tools for Windows PowerShell を使用してアプリケーションを更新し、そのアプリケーションで検出された問題について AWS SSM OpsCenter の OpsItems を生成し、作成された OpsItems を SNS トピック arn:aws:sns:us-east-1:123456789012:MyTopic に関連付けるには、次のコマンドを使用します。

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

カスタムコンポーネントを更新する

AWS CLI を使用してカスタムコンポーネントを更新する

AWS CLI を使用して、my-component という名前のカスタムコンポーネントを、新しいコンポーネント名 my-new-component およびインスタンスの更新されたグループで更新するには、次のコマンドを使用します。

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
AWS Tools for Windows PowerShell を使用したカスタムコンポーネントを更新する

AWS Tools for Windows PowerShell を使用して、my-component という名前のカスタムコンポーネントを、新しいコンポーネント名 my-new-component およびインスタンスの更新されたグループで更新するには、次のコマンドを使用します。

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

モニターリングの管理と更新

コマンドラインを使用して Application Insights アプリケーションのモニターリングを管理および更新できます。

アプリケーションの問題をリスト化する

AWS CLI を使用してアプリケーションに関する問題を一覧表示する

AWS CLI を使用して、my-resource-group というリソースグループで作成されたアプリケーションの Unix エポックから 1,000~10,000 ミリ秒の間で検出されたアプリケーションの問題をリストするには、次のコマンドを使用します。

aws application-insights list-problems --resource-group-name my-resource-group --start-time 1000 --end-time 10000
AWS Tools for Windows PowerShell を使用してアプリケーションに関する問題をリストする

AWS Tools for Windows PowerShell を使用して、my-resource-group というリソースグループで作成されたアプリケーションの Unix エポックから 1,000~10,000 ミリ秒の間で検出されたアプリケーションの問題をリストするには、次のコマンドを使用します。

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

アプリケーションの問題を記述する

AWS CLI を使用してアプリケーションの問題を説明する

AWS CLI を使用して問題 ID p-1234567890 の問題を記述するには、次のコマンドを使用します。

aws application-insights describe-problem —problem-id p-1234567890
AWS Tools for Windows PowerShell を使用してアプリケーションの問題を説明する

AWS Tools for Windows PowerShell を使用して問題 ID p-1234567890 の問題を記述するには、次のコマンドを使用します。

Get-CWAIProblem -ProblemId p-1234567890

問題に関連する異常やエラーを記述する

AWS CLI を使用して問題に関連する異常またはエラーを記述する

AWS CLI を使用して、問題 ID p-1234567890 を持つ問題に関連する異常またはエラーを記述するには、次のコマンドを使用します。

aws application-insights describe-problem-observations --problem-id -1234567890
AWS Tools for Windows PowerShell を使用して、問題に関連する異常またはエラーを記述する

AWS Tools for Windows PowerShell を使用して、問題 ID p-1234567890 を持つ問題に関連する異常またはエラーを記述するには、次のコマンドを使用します。

Get-CWAIProblemObservation -ProblemId p-1234567890

アプリケーションの異常やエラーを記述する

AWS CLI を使用してアプリケーションの異常またはエラーを記述する

AWS CLI を使用して、監視 ID o-1234567890 を持つアプリケーションの異常またはエラーを記述するには、次のコマンドを使用します。

aws application-insights describe-observation —observation-id o-1234567890
AWS Tools for Windows PowerShell を使用して、アプリケーションの異常またはエラーを記述する

AWS Tools for Windows PowerShell を使用して、監視 ID o-1234567890 を持つアプリケーションの異常またはエラーを記述するには、次のコマンドを使用します。

Get-CWAIObservation -ObservationId o-1234567890

コンポーネントのモニターリング設定を記述する

AWS CLI を使用してコンポーネントのモニターリング設定を記述する

AWS CLI を使用して、リソースグループ my-resource-group で作成されたアプリケーションの my-component というコンポーネントのモニターリング設定を記述するには、次のコマンドを使用します。

aws application-insights describe-component-configuration —resource-group-name my-resource-group —component-name my-component
AWS Tools for Windows PowerShell を使用して、コンポーネントのモニターリング設定を記述する

AWS Tools for Windows PowerShell を使用して、リソースグループ my-resource-group で作成されたアプリケーションの my-component というコンポーネントのモニターリング設定を記述するには、次のコマンドを使用します。

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

コンポーネント設定の詳細と JSON ファイルの例についての詳細は、「コンポーネント設定の作業」を参照してください。

コンポーネントの推奨されるモニターリング設定を記述する

AWS CLI を使用して、コンポーネントの推奨モニターリング設定について記述する

コンポーネントが .NET ワーカーアプリケーションの一部である場合、AWS CLI を使用して、リソースグループ my-resource-group で作成されたアプリケーションの my-component というコンポーネントの推奨モニターリング設定を記述するには、次のコマンドを使用します。

aws application-insights describe-component-configuration-recommendation --resource-group-name my-resource-group --component-name my-component --tier DOT_NET_WORKER
AWS Tools for Windows PowerShell を使用してコンポーネントの推奨モニターリング設定について記述する

コンポーネントが .NET ワーカーアプリケーションの一部である場合、AWS Tools for Windows PowerShell を使用して、リソースグループ my-resource-group で作成されたアプリケーションの my-component というコンポーネントの推奨モニターリング設定を記述するには、次のコマンドを使用します。

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

コンポーネント設定の詳細と JSON ファイルの例についての詳細は、「コンポーネント設定の作業」を参照してください。

コンポーネントのモニターリング設定を更新する

AWS CLI を使用してコンポーネントのモニターリング設定を更新する

AWS CLI を使用して、my-component というリソースグループで作成されたアプリケーションの my-resource-group というコンポーネントを更新するには、次のコマンドを使用します。コマンドには、以下のアクションが含まれます。

  1. コンポーネントのモニターリングを有効にします。

  2. コンポーネントの階層を .NET Worker に設定します。

  3. コンポーネントの JSON 設定を更新して、ローカルファイル 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"
AWS Tools for Windows PowerShell を使用してコンポーネントのモニターリング設定を更新する

AWS Tools for Windows PowerShell を使用して、my-component というリソースグループで作成されたアプリケーションの my-resource-group というコンポーネントを更新するには、次のコマンドを使用します。コマンドには、以下のアクションが含まれます。

  1. コンポーネントのモニターリングを有効にします。

  2. コンポーネントの階層を .NET Worker に設定します。

  3. コンポーネントの JSON 設定を更新して、ローカルファイル 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

コンポーネント設定の詳細と JSON ファイルの例についての詳細は、「コンポーネント設定の作業」を参照してください。

指定したリソースグループを Application Insights のモニターリングから削除する

AWS CLI を使用して指定されたリソースグループを Application Insights のモニターリングから削除する

AWS CLI を使用して、my-resource-group というリソースグループで作成されたアプリケーションをモニターリングから削除するには、次のコマンドを使用します。

aws application-insights delete-application --resource-group-name my-resource-group
AWS Tools for Windows PowerShell を使用して指定されたリソースグループを Application Insights のモニターリングから削除する

AWS Tools for Windows PowerShell を使用して、my-resource-group というリソースグループで作成されたアプリケーションをモニターリングから削除するには、次のコマンドを使用します。

Remove-CWAIApplication -ResourceGroupName my-resource-group

SQL Always On 可用性グループのモニターリングを設定する

  1. SQL HA EC2 インスタンスを使用して、リソースグループのアプリケーションを作成します。

    aws application-insights create-application ‐-region <REGION> ‐-resource-group-name <RESOURCE_GROUP_NAME>
  2. 新しいアプリケーションコンポーネントを作成して、SQL HA クラスターを表す EC2 インスタンスを定義します。

    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>
  3. SQL HA コンポーネントを設定します。

    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 } ] } ] }'
注記

Application Insights は、フェイルオーバーなどのクラスターアクティビティを検出するために、アプリケーションイベントログ (情報レベル) を取り込む必要があります。

MySQL RDS のモニターリングを設定する

  1. RDS MySQL データベースインスタンスを使用して、リソースグループのアプリケーションを作成します。

    aws application-insights create-application ‐-region <REGION> ‐-resource-group-name <RESOURCE_GROUP_NAME>
  2. エラーログはデフォルトで有効になります。スロークエリログは、データパラメータグループを使用して有効にできます。詳細については、「MySQL スロークエリと一般ログにアクセスする」を参照してください。

    • set slow_query_log = 1

    • set log_output = FILE

  3. モニターリングするログを CloudWatch Logs にエクスポートします。詳細については、「CloudWatch Logs への MySQL ログの発行」を参照してください。

  4. MySQL RDS コンポーネントを設定します。

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

MySQL EC2 のモニターリングを設定する

  1. SQL HA EC2 インスタンスを使用して、リソースグループのアプリケーションを作成します。

    aws application-insights create-application ‐-region <REGION> ‐-resource-group-name <RESOURCE_GROUP_NAME>
  2. エラーログはデフォルトで有効になります。スロークエリログは、データパラメータグループを使用して有効にできます。詳細については、「MySQL スロークエリと一般ログにアクセスする」を参照してください。

    • set slow_query_log = 1

    • set log_output = FILE

  3. MySQL EC2 コンポーネントを設定します。

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

PostgreSQL RDS のモニターリングを設定する

  1. PostgreSQL RDS データベースインスタンスを使用して、リソースグループのアプリケーションを作成します。

    aws application-insights create-application ‐-region <REGION> ‐-resource-group-name <RESOURCE_GROUP_NAME>
  2. CloudWatch への PostgreSQL ログの公開は、デフォルトでは有効になっていません。モニターリングを有効にするには、RDS コンソールを開き、モニターリングするデータベースを選択します。右上隅にある [Modify] (変更) を選択し、[PostgreSQL] ログというラベルの付いたチェックボックスをオンにします。[Continue (続行)] を選択してこの設定を保存します。

  3. PostgreSQL のログが CloudWatch にエクスポートされます。

  4. PostgreSQL RDS コンポーネントを設定します。

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

PostgreSQL EC2 のモニターリングを設定する

  1. PostgreSQL EC2 インスタンスを使用して、リソースグループのアプリケーションを作成します。

    aws application-insights create-application ‐-region <REGION> ‐-resource-group-name <RESOURCE_GROUP_NAME>
  2. PostgreSQL EC2 コンポーネントを設定します。

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

Oracle RDS のモニターリングを設定する

  1. Oracle RDS データベースインスタンスを使用して、リソースグループのアプリケーションを作成します。

    aws application-insights create-application ‐-region <REGION> ‐-resource-group-name <RESOURCE_GROUP_NAME>
  2. CloudWatch への Oracle ログの発行は、デフォルトでは有効になっていません。モニターリングを有効にするには、RDS コンソールを開き、モニターリングするデータベースを選択します。右上隅にある [Modify] (変更) を選択し、[Alert] (アラート) ログと [Listener] (リスナー) ログというラベルの付いたチェックボックスをオンにします。[Continue (続行)] を選択してこの設定を保存します。

  3. Oracle ログは CloudWatch にエクスポートされます。

  4. Oracle RDS コンポーネントを設定します。

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

Oracle EC2 のモニターリングを設定する

  1. Oracle EC2 インスタンスを使用して、リソースグループのアプリケーションを作成します。

    aws application-insights create-application ‐-region <REGION> ‐-resource-group-name <RESOURCE_GROUP_NAME>
  2. Oracle EC2 コンポーネントを設定します。

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