Uploaded image for project: 'OpenShift Bugs'
  1. OpenShift Bugs
  2. OCPBUGS-11713

Alertmanager will not accept text-based email templates when alertmanagerMain: enableUserAlertmanagerConfig: true

XMLWordPrintable

    • Low
    • No
    • MON Sprint 238, MON Sprint 242
    • 2
    • False
    • Hide

      None

      Show
      None
    • Hide
      * Previously, it was not possible to use text-only email templates in an Alertmanager configuration to send text-only email alerts. With this update, you can configure Alertmanager to send text-only email alerts by setting the `html` field of the email receiver to an empty string. (link:https://issues.redhat.com/browse/OCPBUGS-11713[*OCPBUGS-11713*])
      Show
      * Previously, it was not possible to use text-only email templates in an Alertmanager configuration to send text-only email alerts. With this update, you can configure Alertmanager to send text-only email alerts by setting the `html` field of the email receiver to an empty string. (link: https://issues.redhat.com/browse/OCPBUGS-11713 [* OCPBUGS-11713 *])
    • Bug Fix
    • Done

      Description of problem:

      When trying to send the alerting emails with a text template instead of html, the alertmanager would not use the text template and send html emails. once we set alertmanagerMain:
            enableUserAlertmanagerConfig: false
      then the emails were showing up with the text template we specified. 

      Version-Release number of selected component (if applicable):

      openshift cluster: 4.10.25

      How reproducible:

      very reproducible. reproduced this error on an openshift-demo 4.10 cluster

      Steps to Reproduce:

      1. following this documentation to set up openshift alert manager: https://docs.openshift.com/container-platform/4.10/monitoring/managing-alerts.html
      2. confirm that alertmanager receiver email configuration looks like:
      email_configs:
            - to: 'someone@email.com'
              from: something@email.com
              smarthost: 'email:25'
              require_tls: false
              send_resolved: true
              html: ''
              text: |-
                {{ range .Alerts }}
                *Alert:* {{ .Annotations.summary }} - `{{ .Labels.severity }}`
                *Description:* {{ .Annotations.description }}
                *Details:*
                {{ range .Labels.SortedPairs }} * *{{ .Name }}:* `{{ .Value }}`
                {{ end }}
                {{ end }}
      3. cluster-monitoring-config Configmap in the openshift-monitoring has the following at the top:
      data:
        config.yaml: |
          enableUserWorkload: true
          alertmanagerMain:
            enableUserAlertmanagerConfig: true
            nodeSelector:
              node-role.kubernetes.io/infra: ""
            tolerations:
            - key: node-role.kubernetes.io/infra
              operator: Exists
              effect: NoSchedule
            volumeClaimTemplate:
              spec:
                storageClassName: ocs-storagecluster-ceph-rbd
                resources:
                  requests:
                    storage: 40Gi
        4. trigger an email alert: 
      oc exec alertmanager-main-0 -- amtool alert add --alertmanager.url http://localhost:9093 alertname=justchecking --start="2023-04-03T00:01:18-00:00" severity=info --annotation=summary="summary" --annotation=description="alert desc."
      
      5. check email. The email template is in the default html instead of the defined text template. 
      
      6. change "alertmanagerMain: enableUserAlertmanagerConfig: false" in the ecluster-monitoring-config Configmap and re-trigger the email alert, the email template should now be in the specified text template from the email configs. 

      Actual results:

      html template

      Expected results:

      text template

      Additional info:

      I can provide screenshots and upload additional configuration files if allowed

            spasquie@redhat.com Simon Pasquier
            rhn-support-juwalker Julia Walker
            Junqi Zhao Junqi Zhao
            Brian Burt Brian Burt
            Julia Walker
            Andrew Block
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: