使用 mustache 对结果进行分组 ElasticSearch Alerting 结果

问题描述

我正致力于在我们的 AWS ElasticSearch 集群上设置触发器,以显示哪些 lambda 表达式产生了错误

现在我有以下触发器代码

Monitor {{ctx.monitor.name}} just entered alert status. Please investigate the issue.
- Trigger: {{ctx.trigger.name}}
- Severity: {{ctx.trigger.severity}}
- Lambda Impacted
{{#ctx.results.0.hits.hits}}
   - {{_source.LambdaName}}
{{/ctx.results.0.hits.hits}}
- Count: {{ctx.results.0.hits.total}}
- Period start: {{ctx.periodStart}}
- Period end: {{ctx.periodEnd}}

现在代码按预期工作(见下文)。

    Monitor errors just entered alert status. Please investigate the issue.
    - Trigger: lambda-alert
    - Severity: 1
    - Lambda Impacted
       - abc-LambdaName1
       - abc-LambdaName1
       - abc-LambdaName1
       - abc-LambdaName1
       - abc-LambdaName1
       - abc-LambdaName1
    - Count: 25194
    - Period start: 2021-04-21T14:55:51.305Z
    - Period end: 2021-04-21T15:00:51.305Z

Mustache 是否可以在输出中将这些 lambda 分组,以便它表示 lambda 名称以及与该 lambda 相关联的错误数量(请参见下面的示例),以防我们有多个 lambda 发出警报并通过警报阈值。

Monitor errors just entered alert status. Please investigate the issue.
    - Trigger: lambda-alert
    - Severity: 1
    - Lambda Impacted
       - abc-LambdaName1 (6)
       - abc-LambdaName2 (5)
    - Count: 11
    - Period start: 2021-04-21T14:55:51.305Z
    - Period end: 2021-04-21T15:00:51.305Z

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)