feat: store structured alert labels in post props#3
Open
mr-karan wants to merge 1 commit into
Open
Conversation
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
There was a problem hiding this comment.
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/AlertPropEntrytypes to represent structured alert metadata. - Extends
MattermostMessagewith an optionalPropsfield. - Populates
props.alert_datainprepareMessage()with per-alert entries plusgroup_labelsandcommon_labels.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
props.alert_datafieldProps 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:** valueMarkdown in attachment fields, which is fragile. With this change, silencer readsprops.alert_data.common_labelsdirectly.