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

Bug rocketchat channel not templated #4219

Open
rekup opened this issue Jan 23, 2025 · 1 comment · May be fixed by #4220
Open

Bug rocketchat channel not templated #4219

rekup opened this issue Jan 23, 2025 · 1 comment · May be fixed by #4220

Comments

@rekup
Copy link

rekup commented Jan 23, 2025

Alertmanager version:

alertmanager, version 0.28.0 (branch: HEAD, revision: 4ce04fb010bd626fca35928dcfe82f6f2da52ced)
  build user:       root@40be7f318ba7
  build date:       20250115-14:22:34
  go version:       go1.23.4
  platform:         linux/amd64
  tags:             netgo

Configuration:

receivers:
- name: dummy
- name: rocketchat
  rocketchat_configs:
    - api_url: https://chat.example.org
      channel: '{{ .CommonLabels.rocketchat_channel }}'
      token: redacted
      token_id: redacted
      text: |
        {{- if (index .Alerts 0).Annotations.summary }}
        {{- "\n" -}}
        *Summary:* {{ (index .Alerts 0).Annotations.summary }}
        {{- end }}

        {{ range .Alerts }}
    
            {{- if .Annotations.description }}
            {{- "\n" -}}
            {{ .Annotations.description }}
            {{- "\n" -}}
            {{- end }}
            {{- if .Annotations.message }}
            {{- "\n" -}}
            {{ .Annotations.message }}
            {{- "\n" -}}
            {{- end }}
    
        {{- end }}

      actions:
      - type: button
        text: 'Runbook'
        url: '{{ (index .Alerts 0).Labels.runbook_url }}'
      - type: button
        text: 'Query'
        url: '{{ (index .Alerts 0).GeneratorURL }}'
      - type: button
        text: 'Dashboard'
        url: '{{ (index .Alerts 0).Annotations.dashboard }}'

route:
  group_by:
  - alertname
  group_interval: 5s
  group_wait: 30s
  receiver: dummy
  repeat_interval: 24h
  routes:
  - matchers:
    - rocketchat_channel =~ ".+"
    receiver: rocketchat

According to the documentation, the Rocket.Chat channel name can be a template:

[ channel: <tmpl_string> | default = global.rocketchat_api_url ]

But if I understand the current implementation correctly, the channel is not passed to tmplText().

Using the configuration above results in the following error:

Jan 23 11:30:18 prometheus01.example.org alertmanager[537352]: time=2025-01-23T10:30:18.509Z level=ERROR source=dispatch.go:360 msg="Notify for alerts failed" component=dispatcher num_alerts=1 err="test/rocketchat[0]: notify retry canceled due to unrecoverable error after 1 attempts: channel \"{{ .CommonLabels.rocketchat_channel }}\": unexpected status code 400: {\"success\":false,\"error\":\"[invalid-channel]\",\"errorType\":\"invalid-channel\"}"

I'm not sure what the intended behavior is, but I think templating the channel could be useful.

@rekup rekup linked a pull request Jan 23, 2025 that will close this issue
@TheMeier
Copy link
Contributor

The motivation was to make it as close as possible to the slack support. Looking at https://github.com/prometheus/alertmanager/blob/main/notify/slack/slack.go#L180 ... yeah you are probably right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants