从警报 SNS 链接到 AWS Cloudwatch Logs

发布于 2025-01-16 21:31:54 字数 1307 浏览 2 评论 0原文

我让 CloudWatch 警报发送回带有错误信息的 SNS 消息,并且我将其与 slackWebhook 一起使用以将警报消息发送到我们的 Slack 通道。我希望能够包含相关日志的链接,但现在我看到的可能有用的只是警报 Arn。我可以以某种方式使用它,或者有没有办法抓取该 Arn 的 aws 错误日志并以某种方式链接到该日志?

以下是 SNS 消息中的 JSON:

{
  "AlarmName": "EmailErrorsFF58B22B-HFUJGANB6BDD",
  "AlarmDescription": "Some Description",
  "AWSAccountId": "<REMOVED>",
  "AlarmConfigurationUpdatedTimestamp": "2022-03-24T12:20:22.195+0000",
  "NewStateValue": "ALARM",
  "NewStateReason": "Threshold Crossed: 1 datapoint [1.0 (25/03/22 15:39:00)] was greater than the threshold (0.0).",
  "StateChangeTime": "2022-03-25T15:44:45.495+0000",
  "Region": "US East (N. Virginia)",
  "AlarmArn": "arn:aws:cloudwatch:<REMOVED>",
  "OldStateValue": "OK",
  "OKActions": [],
  "AlarmActions": [
    "arn:aws:sns:<REMOVED>"
  ],
  "InsufficientDataActions": [],
  "Trigger": {
    "MetricName": "Errors",
    "Namespace": "AWS/Lambda",
    "StatisticType": "Statistic",
    "Statistic": "SUM",
    "Unit": null,
    "Dimensions": [
      {
        "value": "Email-production",
        "name": "FunctionName"
      }
    ],
    "Period": 300,
    "EvaluationPeriods": 1,
    "ComparisonOperator": "GreaterThanThreshold",
    "Threshold": 0,
    "TreatMissingData": "",
    "EvaluateLowSampleCountPercentile": ""
  }
}

I have CloudWatch alarms sending SNS messages back with error information, and I'm using that along with the slackWebhook to send alarm messages to our Slack channel. I'd like to be able to include a link to the relevant logs, but right now all I'm seeing that may be useful is the alarm Arn. Can I use this somehow, or is there a way to scrape the aws error logs for that Arn and link to that somehow?

Here's the JSON from the SNS message:

{
  "AlarmName": "EmailErrorsFF58B22B-HFUJGANB6BDD",
  "AlarmDescription": "Some Description",
  "AWSAccountId": "<REMOVED>",
  "AlarmConfigurationUpdatedTimestamp": "2022-03-24T12:20:22.195+0000",
  "NewStateValue": "ALARM",
  "NewStateReason": "Threshold Crossed: 1 datapoint [1.0 (25/03/22 15:39:00)] was greater than the threshold (0.0).",
  "StateChangeTime": "2022-03-25T15:44:45.495+0000",
  "Region": "US East (N. Virginia)",
  "AlarmArn": "arn:aws:cloudwatch:<REMOVED>",
  "OldStateValue": "OK",
  "OKActions": [],
  "AlarmActions": [
    "arn:aws:sns:<REMOVED>"
  ],
  "InsufficientDataActions": [],
  "Trigger": {
    "MetricName": "Errors",
    "Namespace": "AWS/Lambda",
    "StatisticType": "Statistic",
    "Statistic": "SUM",
    "Unit": null,
    "Dimensions": [
      {
        "value": "Email-production",
        "name": "FunctionName"
      }
    ],
    "Period": 300,
    "EvaluationPeriods": 1,
    "ComparisonOperator": "GreaterThanThreshold",
    "Threshold": 0,
    "TreatMissingData": "",
    "EvaluateLowSampleCountPercentile": ""
  }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文