prometheus / prometheus/alertmanager

AlertManager/Opsgenie - I can't template only by the responder type field

Open
#2,887 0 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component/notify kind/enhancement kind/support stale
Dominant language
Go
Stars
8.6k
Forks
2.5k
Avg merge
2d 6h
Merged PRs (30d)
61

Description

What did you do?
I was setting the built-in alert-manager integration with opsgenie.

What did you expect to see?
I want to template responder type field like all other fields that is templatable.

What did you see instead? Under which circumstances?
When I put a template string at the responder type field I got this error:

ts=2022-04-11T18:35:35.669Z caller=coordinator.go:118 level=error component=configuration msg="Loading configuration file failed" file=/etc/alertmanager/config.yaml err="OpsGenieConfig responder { {{ .CommonLabels.responder_name }}  {{ .commonlabels.responder_type }}} type does not match valid options ^(team|teams|user|escalation|schedule)$"

I think it is a bug because I'm able to template all other fields of opsgenie_configs, such as responder name.

Environment

  • System information: quay.io/prometheus/alertmanager:v0.24.0 (conteiner image)
  • Alertmanager version: 0.24.0 (branch=HEAD, revision=f484b17fa3c583ed1b2c8bbcec20ba1db2aa5f11)
  • Prometheus version: 2.34.0 (prom/prometheus:2.34.0 conteiner image)
  • Alertmanager configuration file:
templates:
- '/etc/alertmanager/template/*.tmpl'
global:
  opsgenie_api_key: xxx

receivers:
- name: 'opsgenie'
  opsgenie_configs:
  - send_resolved: true
    message: '{{ .CommonAnnotations.summary }}'
    description: '{{ .CommonAnnotations.description }}'
    source: '{{ .CommonLabels.source }}'
    details:
    responders: 
    - name: '{{ .CommonLabels.responder_name }}'
      # it doesn't work because of this code: 
      # https://github.com/prometheus/alertmanager/blob/a6d10bd5bc3f651e0ca04d47b981ed66e85a09a6/config/notifiers.go#L504
      type: '{{ .CommonLabels.responder_type }}'
    tags: '{{ .CommonLabels.tags }}'
    note: '{{ .CommonLabels.note }}'
    priority: '{{ .CommonLabels.priority }}'
    entity: '{{ .CommonLabels.app }}'
    actions: '{{ .CommonLabels.actions }}'
  

route:
  receiver: 'opsgenie'
  group_by: [ 'app', 'tenant', 'category' ]

  • Prometheus - Alert Rules:
groups:
- name: my_alerting_rules
  rules:
  - alert: my_alert
    expr: sample_metric >= 3
    for: 5s
    labels:
      responder_name: 'my-team'
      responder_type: 'team'
      priority: 'P1'
    annotations:
      summary: "[SampleOverflow.Error]: Tenant {{ $labels.tenant }}"
      description: "{{ $value }} samples found for category {{ $labels.category }} on tenant {{ $labels.tenant }}"

  • Logs:
"OpsGenieConfig responder { {{ .CommonLabels.responder_name }}  {{ .commonlabels.responder_type }}} type does not match valid options ^(team|teams|user|escalation|schedule)$"```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in config/notifiers.go at the referenced Opsgenie responder validation, then trace how responder fields are processed when configuration templates are rendered. Confirm the behavior with the supplied responder_type template and configuration; done means the configuration loads successfully while preserving validation for the allowed responder types.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.