elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.99k stars 8.24k forks source link

[ResponseOps][Slack Blockkit] support YAML and Hjson as input as well as JSON for blockkit body #198528

Open pmuellr opened 1 month ago

pmuellr commented 1 month ago

A while back for the Slack connector, we started supporting using Blockkit to create messages, rather than just the usual single Mrkdown formatted string.

Here's an example in JSON, that might be used for a recovered alert:

{
    "blocks": [
        {
            "type": "header",
            "text": {
                "type": "plain_text",
                "text": "🎉 {{rule.name}} Recovered 🎉",
                "emoji": true
            }
        },
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "View rule: <{{rule.url}}|{{rule.name}}>"
            }
        },
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "<{{context.alertDetailsUrl}}|View alert>"
            }
        },
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "Alert UUID: `{{alert.uuid}}`"
            }
        }
    ]
}

Kinda wordy / noisy as all JSON tends to be. We could make this a little easier by supporting YAML and/or Hjson:

yaml:

blocks:
- type: header
  text:
    type: plain_text
    text: "🎉 {{rule.name}} Recovered 🎉"
    emoji: true
- type: section
  text:
    type: mrkdwn
    text: 'View rule: <{{rule.url}}|{{rule.name}}>'
- type: section
  text:
    type: mrkdwn
    text: "<{{context.alertDetailsUrl}}|View alert>"
- type: section
  text:
    type: mrkdwn
    text: 'Alert UUID: `{{alert.uuid}}`'

Hjson:

{
  blocks: [
    {
      type: header
      text: {
        type: plain_text
        text: 🎉 {{rule.name}} Recovered 🎉
        emoji: true
      }
    }
    {
      type: section
      text: {
        type: mrkdwn
        text: View rule: <{{rule.url}}|{{rule.name}}>
      }
    }
    {
      type: section
      text: {
        type: mrkdwn
        text: <{{context.alertDetailsUrl}}|View alert>
      }
    }
    {
      type: section
      text: {
        type: mrkdwn
        text: Alert UUID: `{{alert.uuid}}`
      }
    }
  ]
}
elasticmachine commented 1 month ago

Pinging @elastic/response-ops (Team:ResponseOps)

pmuellr commented 1 month ago

Not sure if there are other connectors, or perhaps rules, that would also benefit from this sort of ease-of-use, but I'd think anything expecting a non-trivial amount of JSON might be a candidate.