0

我正在尝试在 slack 中使用消息格式。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"
4

1 回答 1

0

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

事实上,警报已经被格式化为附件,这就是为什么您可以设置标题和标题 URL。并且还定义了额外的“字段”。您只能使用 Slack 中的附件来执行的操作。

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

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

于 2019-03-28T20:53:43.247 回答