prometheus / prometheus/alertmanager
Feature Request: Sort Alerts based on startsAt time or arbitrary paramater
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 8.6k
- Forks
- 2.5k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 61
Description
What did you do?
We are using a template to render slack alerts for Alertmanager (using a range .Aletrts). However, when grouping alerts it would be helpful to show the most recent alert first - especially to easily identify if an alert is flapping and/or determine quickly what alert has most recently fired in a particular group.
What did you expect to see?
It would be convenient to have a method to sort alerts based on a particular label or parameter in .Alerts.
Something like a template function (sortAsc or sortDesc, either lexicographically for strings or just in numerical order for numbers.
- Example template:
{{/* The test to display in the alert */}}
{{ define "slack.alerts.text" -}}
{{ range .Alerts }}
{{- if .Annotations.summary }}
*Summary: * {{ .Annotations.summary }}
{{- end }}
{{- if .GeneratorURL }}
:chart_with_upwards_trend: *<{{ .GeneratorURL }}|Graph>*
{{- end }}
{{- if .Annotations.runbook_url }}
:spiral_note_pad: *<{{ .Annotations.runbook_url }}|Runbook URL>*
{{- end }}
{{- if .Annotations.observability_url }}
:eyes: *<{{ .Annotations.observability_url }}|Observability URL>*
{{- end }}
{{- if .Annotations.slack_contact }}
:person_in_tuxedo: *Owner:* <@{{ .Annotations.slack_contact }}>
{{- end }}
{{- if .Annotations.description }}
*Description: * {{ .Annotations.description }}
{{- end }}
{{- end }}
{{- end }}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Alertmanager template handling behind the .Alerts value and review how template functions are exposed. Define the supported sorting behavior for alert fields or parameters, then verify the example Slack template renders alerts in the requested order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100