松弛集成的Elastalert规则(消息格式和附件)

时间:2019-03-28 19:44:45

标签: slack-api elastalert

我正试图在松弛状态下使用消息格式。 Elastalert Testrule.yaml文件已部分解析。松弛警报仅显示slack_alert_fieldsalert_text字段。我也想在警报中发送附件。 如何使用attachments或创建按钮以加强警报?

es_host: elasticsearch
es_port: 9200
name: Test rule Alert
type: any
index: alerts-*
filter:
- term:
    alertType.keyword: "New alert created"

alert:
- "slack"

slack_alert_fields:
- title: Network Name
  value: networkName
  short: true
- title: Alert Type
  value: alertType
  short: true
slack_actions:
- name: "network url"
  text: "Network URL"
  type: "button"
  value: networkUrl

alert_text: |
            alertData : {0}

alert_text_type: alert_text_only
alert_text_args: ["alertData"]

attachments: [
    {
        "fallback": "Required plain-text summary of the attachment.",
        "color": "#37964f",
        "pretext": "New alert created",

        "title":  alertData.reason ,
        "fields": [
            {
                "title": "Network Name",
                "value": networkName,
                "short" : true
            },
            {
                "title": "Timestamp",
                "value": timestamp,
                "short" : true
            }
            ],
            "actions": [
                {
                    "name": "network url",
                    "text": "Network URL",
                    "type": "button",
                    "value": networkUrl
                },
                {
                    "name": "org_url",
                    "text": "Organization URL",
                    "type": "button",
                    "value":  organizationUrl

                }

                ]

    }
    ]


slack_webhook_url:
- "https://hooks.slack.com/xxxxxxxxxxxxxxxxxxxxxxx"

1 个答案:

答案 0 :(得分:0)

查看官方文档,看来Elastalert不支持为警报添加自定义Slack附件,因为文档中没有它的属性。

实际上,它表明警报已被格式化为附件,这就是为什么您可以设置标题和标题URL的原因。并定义其他“字段”。您只能对Slack中的附件执行操作。

这也意味着您不能为警报指定按钮(这是Slack中的一种特殊附件)。

如果您需要此功能,建议您与Elastalert的开发人员联系。

相关问题