Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
herberton opened this issue Apr 11, 2022 · 0 comments
Open

Comments

@herberton
Copy link

herberton commented Apr 11, 2022

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)$"```
@herberton herberton changed the title AlertManager/Opsgenie - I only can't template the responder type field AlertManager/Opsgenie - I can't template only by the responder type field Apr 12, 2022
erkiesken added a commit to erkiesken/forked-alertmanager that referenced this issue Sep 6, 2022
Solves prometheus#2887, where Opsgenie responder type can be templated according
to docs, but configuration logic checked for specific list of values only.
erkiesken added a commit to erkiesken/forked-alertmanager that referenced this issue Sep 6, 2022
Solves prometheus#2887, where Opsgenie responder type can be templated according
to docs, but configuration logic checked for specific list of values only.

Signed-off-by: Erki Esken <erki@esken.net>
simonpasquier added a commit that referenced this issue Dec 7, 2022
* Add check for templated Opsgenie receiver config

Solves #2887, where Opsgenie responder type can be templated according
to docs, but configuration logic checked for specific list of values only.

Signed-off-by: Erki Esken <erki@esken.net>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
qinxx108 pushed a commit to qinxx108/alertmanager that referenced this issue Dec 13, 2022
* Add check for templated Opsgenie receiver config

Solves prometheus#2887, where Opsgenie responder type can be templated according
to docs, but configuration logic checked for specific list of values only.

Signed-off-by: Erki Esken <erki@esken.net>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Yijie Qin <qinyijie@amazon.com>
hoperays pushed a commit to hoperays/alertmanager that referenced this issue Apr 23, 2023
* Add check for templated Opsgenie receiver config

Solves prometheus#2887, where Opsgenie responder type can be templated according
to docs, but configuration logic checked for specific list of values only.

Signed-off-by: Erki Esken <erki@esken.net>
Co-authored-by: Simon Pasquier <spasquie@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants