Skip to content

feat: store structured alert labels in post props#3

Open
mr-karan wants to merge 1 commit into
mainfrom
feat/alert-data-props
Open

feat: store structured alert labels in post props#3
mr-karan wants to merge 1 commit into
mainfrom
feat/alert-data-props

Conversation

@mr-karan

Copy link
Copy Markdown
Owner

Summary

  • Store alert labels, fingerprints, and group metadata in the Mattermost post's props.alert_data field
  • Allows downstream tools (e.g. silencer) to programmatically read alert metadata without parsing rendered Markdown
  • Existing attachment rendering is unchanged — purely additive, no user-visible difference

Props structure

{
  "props": {
    "alert_data": {
      "alerts": [
        {
          "labels": {"alertname": "HostHighCpuLoad", "severity": "warning", ...},
          "status": "firing",
          "fingerprint": "abc123def456"
        }
      ],
      "group_labels": {"alertname": "HostHighCpuLoad"},
      "common_labels": {"alertname": "HostHighCpuLoad", "severity": "warning", ...}
    }
  }
}

Why

The silencer bot needs to read alert labels from a Mattermost post when a user replies with @silencer silence 2h. Without structured props, it would have to parse the **Title_Cased_Key:** value Markdown in attachment fields, which is fragile. With this change, silencer reads props.alert_data.common_labels directly.

Store alert labels, fingerprints, group labels, and common labels in the
Mattermost post's props.alert_data field. This allows downstream tools
(e.g. silencer) to programmatically read alert metadata without parsing
the rendered Markdown attachments.

The existing attachment rendering is unchanged — this is purely additive.
The props structure:

  props.alert_data.alerts[].labels       - per-alert label map
  props.alert_data.alerts[].status       - firing/resolved
  props.alert_data.alerts[].fingerprint  - alert fingerprint
  props.alert_data.group_labels          - group-level labels
  props.alert_data.common_labels         - labels common to all alerts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds structured Alertmanager metadata to outgoing Mattermost webhook payloads by storing alert label data under the post props.alert_data, enabling downstream tooling to read labels/fingerprints without parsing attachment Markdown.

Changes:

  • Introduces AlertProps / AlertPropEntry types to represent structured alert metadata.
  • Extends MattermostMessage with an optional Props field.
  • Populates props.alert_data in prepareMessage() with per-alert entries plus group_labels and common_labels.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants