Prometheus error emails

Hi,

Yesterday I received a series of blank emails a few minutes apart and was initially puzzled as to what was going on.
Then it dawned on me that they must have come from Prometheus, so I checked the log and found that a certificate update had failed.
Is it possible to adjust the interval and the number of emails sent by Prometheus in the event of an error?
Is it possible to include a note in the message asking the recipient to check the log, rather than sending a blank message, if there is no specific information available?

Best, Erwin

Usually a mail including some information should be sent instead of a blank one.

Let’s check the TLS alert, see ns8-metrics/imageroot/actions/create-module/30alerts at main · NethServer/ns8-metrics · GitHub to compare

runagent -m metrics1 nano rules.d/tlscert.yml

Did you customize alerts or alert mails as explained in the README?

@mrmarkuz I haven’t set up any custom alerts. The automatic certificate update didn’t work because the port wasn’t open in my firewall; I’m not sure if it’s the same issue. Once the certificate had been renewed, the error message no longer appeared.

runagent -m metrics1 nano rules.d/tlscert.yml

groups:

  • name: TLS certificates
    rules:
    • alert: certexp
      expr: 7d <= (max by (cn, sans) (traefik_tls_certs_not_after) - time()) < 28d
      for: 5m
      labels:
      severity: warning
      annotations:
      summary: “TLS certificate on Node {{ $labels.node }} expires in {{ $value | humanizeDuration }}”
      description: >
      The {{ $labels.module_id }} certificate {{ $labels.cn }} valid for {{ $labels.sans }}
      on Node {{ $labels.node }} expires in less than 28 days. It must be renewed, or
      removed from the TLS certificates page.
    • alert: certexp
      expr: 0 < (max by (cn, sans) (traefik_tls_certs_not_after) - time()) < 7d
      for: 5m
      labels:
      severity: critical
      annotations:
      summary: “TLS certificate on Node {{ $labels.node }} expires in {{ $value | humanizeDuration }}”
      description: >
      The {{ $labels.module_id }} certificate {{ $labels.cn }} valid for {{ $labels.sans }}
      on Node {{ $labels.node }} expires in less than 7 days. It must be renewed, or
      removed from the TLS certificates page.
    • alert: certexp
      expr: (time() - max by (cn, sans) (traefik_tls_certs_not_after)) > 0
      for: 5m
      labels:
      severity: critical
      annotations:
      summary: “TLS certificate on Node {{ $labels.node }} has expired since {{ $value | humanizeDuration }}”
      description: >
      The {{ $labels.module_id }} expired certificate {{ $labels.cn }} (also for {{ $labels.sans }})
      on Node {{ $labels.node }} must be immediately renewed, or removed from the TLS certificates page.

Mails are sent when a certificate expires < 7 days which usually means that it wasn’t possible to renew it automatically.

I assume that you enabled the “Alert notifications” in Settings/Metrics:

You could fire a test alert so a test alert mail should be sent which shouldn’t be blank:

runagent -m metrics1 test-alert

@mrmarkuz

runagent -m metrics1 test-alert

Unfortunately, this one is also an empty email with no subject line or content.

Let’s check the metrics configuration, maybe a wrong template is still enabled:

api-cli run module/metrics1/get-configuration | jq

Related issue:

api-cli run module/metrics1/get-configuration | jq

{
“grafana_path”: “”,
“mail_from”: “user@mail.de”,
“mail_template”: “default_en”,
“mail_to”: [
user@mail.de
],
“prometheus_path”: “”
}

I think the “mail_template” needs to be emptied to use the default one as in the other issue.

api-cli run module/metrics1/configure-module --data '{"grafana_path": "", "mail_from": "user@mail.de", "mail_template": "", "mail_to": ["user@mail.de"], "prometheus_path": ""}'

To apply the config, restart alertmanager:

runagent -m metrics1 systemctl --user restart alertmanager

Now the alert mails shouldn’t be empty anymore.

Yes, you’re right, it’s working perfectly now.
If there’s an error, will the same message still appear every few minutes until the error is resolved?

Yes, the message appears every few hours until it’s resolved. There’s also a mail sent, when the error is resolved.

Every few hours is perfect, yesterday the blank email was coming every few minutes.
Thank you very much for your support.