本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
AWSSupport-TroubleshootCloudWatchAlarm
Description
AWSSupport-TroubleshootCloudWatchAlarm
Runbook 有助於識別和疑難排解設定錯誤或有問題的 Amazon CloudWatch (CloudWatch) 警示的問題。它利用 AWS APIs 和已知警示評估邏輯來偵測受監控指標中的延遲或遺失資料點,這可能會導致遺漏或延遲警示動作。此 Runbook 提供結構化方法來調查和解決 Amazon CloudWatch (CloudWatch) 警示相關問題。
如何運作?
Runbook 會AWSSupport-TroubleshootCloudWatchAlarm
執行下列步驟:
-
驗證 Amazon CloudWatch (CloudWatch) 警示詳細資訊和
AlarmTriggerTimestamp
參數的值,以檢查是否在 2,592,000 秒 (30 天) 內。 -
檢查警示是以指標或指標數學為基礎,還是異常偵測器警示。
-
檢查警示是否處於資料不足的狀態。
-
檢查 (警示) 中使用的 metric 是否與
ListMetrics
值相符。 -
驗證指標是否在指定的時間戳記遺失資料點 (s)。
-
取得指定時間戳記的最新歷史記錄。
-
檢查 (警示) 是否因 指標延遲或遺漏而未觸發。
-
檢查警示已啟用的動作 (是否) 是否已交付。
-
產生結合所有診斷結果的故障診斷報告。
文件類型
自動化
擁有者
Amazon
平台
Linux、macOS、 Windows
參數
必要的 IAM 許可
AutomationAssumeRole
參數需要下列動作才能成功使用 Runbook。
cloudwatch:DescribeAlarms
cloudwatch:DescribeAlarmHistory
cloudwatch:DescribeAnomalyDetectors
cloudwatch:GetMetricData
cloudwatch:GetMetricStatistics
cloudwatch:ListMetrics
{ "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Action": [ "cloudwatch:DescribeAlarms", "cloudwatch:DescribeAlarmHistory", "cloudwatch:DescribeAnomalyDetectors", "cloudwatch:GetMetricData", "cloudwatch:GetMetricStatistics", "cloudwatch:ListMetrics" ], "Resource": "*" } ] }
指示
請依照下列步驟設定自動化:
-
在文件下的 Systems Manager
AWSSupport-TroubleshootCloudWatchAlarm
中導覽至 。 -
選擇 Execute automation (執行自動化)。
-
針對輸入參數,輸入下列內容:
-
AutomationAssumeRole (選用):
類型:
String
描述:(選用) (IAM) 角色的 Amazon Resource Name AWS AWS Identity and Access Management (ARN),允許 Systems Manager Automation 代表您執行動作。如果未指定角色,Systems Manager Automation 會使用啟動此 Runbook 之使用者的許可。
-
CloudWatchMetricAlarmName (必要):
類型:
String
描述:(必要) 要疑難排解的 Amazon CloudWatch (CloudWatch) 指標警示名稱。
允許模式:
^[a-zA-Z0-9.:;,\\-_&() ]{1,255}$
-
AlarmTriggerTimestamp (必要):
類型:
String
描述:(必要) 發生警示問題的 UTC 時間戳記。此資訊對於對問題進行故障診斷和了解發生的情況至關重要。時間戳記值應為從今天起算過去 30 天內的時間,格式為
YYYY-MM-DDTHH:mm:ssZ
。範例:2024-10-29T09:04:00Z
允許模式:
^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})Z$
-
-
選取執行。
-
自動化會啟動。
-
文件會執行下列步驟:
-
VerifyRunbookInputs
驗證 Amazon CloudWatch (CloudWatch) 警示詳細資訊和
AlarmTriggerTimestamp
參數的值,以檢查是否在 2,592,000 秒 (30 天) 內。 -
UpdateSSMDocumentInputChecksVariable
SSMDocumentInputChecks
使用VerifyRunbookInputs
步驟SSMDocumentInputChecks
中的值更新變數。 -
BranchOnAlarmIsVerified
Runbook 輸入驗證
AlarmTriggerTimestamp
和 上的分支CloudWatchAlarmName
。 -
CheckMetricAlarmType
檢查警示是以指標或指標數學為基礎,還是異常偵測器警示。
-
CheckAlarmInInsufficientDataState
檢查警示是否處於資料不足的狀態。
-
UpdateInsufficientDataChecksVariable
InsufficientDataChecks
使用CheckAlarmInInsufficientDataState
步驟InsufficientDataChecks
中的值更新變數。 -
BranchOnAlarmHasInsufficientData
CheckAlarmInInsufficientDataState
步驟中AlarmHasInsufficientData
值的分支,預設步驟為CheckMetricMismatch
。 -
CheckMetricMismatch
檢查 (警示) 中使用的 metric 是否與
ListMetrics
值相符。 -
UpdateMetricMismatchChecksVariable
MetricMismatchChecks
使用CheckMetricMismatch
步驟MetricMismatchChecks
中的值更新變數。 -
BranchOnMetricsMatched
CheckMetricMismatch
步驟中MetricsMatched
值的分支,預設步驟為CheckMissingDatapoint
。 -
CheckMissingDatapoint
驗證指標是否在指定的時間戳記遺失資料點 (s)。
-
UpdateMetricMissingDatapointsChecksVariable
MetricMissingDatapointsChecks
使用CheckMissingDatapoint
步驟MetricMissingDatapointsChecks
中的值更新變數。 -
BranchOnMetricMissingDatapoint
CheckMissingDatapoint
步驟中MetricMissingDatapoint
值的分支,預設步驟為GetAlarmHistoryDetails
。 -
GetAlarmHistoryDetails
取得指定時間戳記的最新歷史記錄。
-
UpdateAlarmHistoryChecksVariable
AlarmHistoryChecks
使用GetAlarmHistoryDetails
步驟AlarmHistoryChecks
中的值更新變數。 -
BranchOnAlarmHistoryFound
GetAlarmHistoryDetails
步驟中AlarmHistoryFound
值的分支,預設步驟為CheckDelayedMetric
。 -
CheckDelayedMetric
檢查 (警示) 是否因 指標延遲或遺漏而未觸發。
-
UpdateDelayedMetricChecksVariable
DelayedMetricChecks
使用CheckDelayedMetric
步驟DelayedMetricChecks
中的值更新變數。 -
BranchOnMetricDelayedAndDatapointsMeetThreshold
步驟中的
MetricDelayed
和DatapointsMeetThreshold
值分支CheckDelayedMetric
,預設步驟為GenerateReport
。 -
CheckActionDelivered
檢查警示已啟用的動作 (是否) 是否已交付。
-
UpdateActionDeliveredChecksVariable
ActionDeliveredChecks
使用CheckActionDelivered
步驟ActionDeliveredChecks
的輸出更新變數。 -
GenerateReport
編譯先前步驟的輸出並輸出報告。
-
-
執行完成後,請檢閱輸出區段以取得執行的詳細結果:
-
GenerateReport.Report
提供的 Amazon CloudWatch (CloudWatch) 指標警示的報告。
------------------------------------------------------------------------------------------ | AWS CloudWatch Alarm Troubleshooting Results | ------------------------------------------------------------------------------------------ | Alarm Name - Demo-Alarm | | Timestamp - 2025-03-04T06:31:00Z | ------------------------------------------------------------------------------------------ | ✅ No Issue(s) Found | ------------------------------------------------------------------------------------------ ========================================================================================== 1. Validating SSM Document input parameters: ========================================================================================== ✅ [PASSED]: Found a metric alarm with name Demo-Alarm ========================================================================================== 2. Checking alarm's data state: ========================================================================================== ✅ [PASSED]: The alarm is not in INSUFFICIENT_DATA state, alarm's state is: ALARM ========================================================================================== 3. Checking if the alarm experienced metric mismatches: ========================================================================================== ✅ [PASSED]: Metric matches with the configured metric for Alarm. ========================================================================================== 4. Checking if the alarm's metric(s) experienced missing datapoint(s): ========================================================================================== ✅ [PASSED]: Metric has datapoints ========================================================================================== 5. Retrieving alarm's history for timestamp 2025-03-04T06:31:00Z: ========================================================================================== ✅ [PASSED]: Found most recent alarm history item for the provided timestamp: '2025-03-04T06:31:00Z' ========================================================================================== 6. Checking if the alarm experienced metric delays or the alarm's datapoint(s) did not meet the configured threshold: ========================================================================================== ✅ [PASSED]: CloudWatch alarm did not experience any delayed metric ========================================================================================== 7. Checking if the alarm has actions enabled and if action(s) were delivered: ========================================================================================== ✅ [PASSED]: Successfully executed action arn:aws:sns:us-east-1:12345678910:Demo_Alarms_Topic ------------------------------------------------------------------------------------------ ✅ All the checks have passed for CloudWatch alarm, Demo-Alarm, the alarm's configuration is correct.
-
參考
Systems Manager Automation