Skip to content

Instantly share code, notes, and snippets.

@liamkinne
Last active April 21, 2022 19:46
Show Gist options
  • Save liamkinne/18f5f1abb2ac38bc3dd71a3e7e650d85 to your computer and use it in GitHub Desktop.
Save liamkinne/18f5f1abb2ac38bc3dd71a3e7e650d85 to your computer and use it in GitHub Desktop.
Map Alertmanager priorities to Opsgenie
receiver:
- name: OpsgenieTeam
opsgenie_configs:
- api_url: 'https://api.opsgenie.com/'
api_key: '<api-key-here>'
priority: |
{{ if eq .GroupLabels.severity "critical" }}P2{{ else if eq .GroupLabels.severity "warning" }}P3{{ else if eq .GroupLabels.severity "info" }}P4{{ else }}P5{{ end }}

The above is a standard receiver definition apart from the priority field.

Using Go string templating, we're able to add simple if/else logic that matches Alertmanager priorities (either critical, warning, info or none) and assign them to corresponding P1 through P5 Opsgenie priorities.

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