0

I am trying to activate my spring boot application endpoints with the alerts, for the required event that is defined in the alert rules of prometheus is broken, so that I want to add my application endpoints as a receiver to receive alerts from the prometheus alertmanager. Can anyone please suggest how to configure endpoint as a receiver to this receiver label, instead of any other push notifiers?

  - receiver: 'frontend-pager'
    group_by: [product, environment]
    matchers:
    - team="frontend"
Sowbharni
  • 13
  • 3

1 Answers1

0

I think 'webhook receiver' can help you. More information can refer doc https://prometheus.io/docs/alerting/latest/configuration/#webhook_config

This is an example of a webhook alert created based on blackbox_exporter's metric scraping.

  1. prometheus rule setting

You need to create rule(s) to trigger alert, defined a rule named 'http_health_alert' here as example.

groups:
- name: http
  rules:
  - alert: http_health_alert
    expr:  probe_success == 0 
    for: 3m
    labels:
      type: http_health
    annotations:
      description: Health check for {{$labels.instance}} is down
  1. Alertmanager setting

'match' is set to http_health_alert, the alert will be sent to'http://example.com/alert/receiver' via HTTP/POST method (I think you will prepare in advance). The alert will post JSON format to the configured endpoint 'http://example.com/alert/receiver'. And you can also customize different receiving methods or receiving information in the endpoint/program for different label contents.

global:

route:
  group_by: [alertname, env]
  group_wait: 30s
  group_interval: 3m
  repeat_interval: 1h

  routes:
    - match:
        alertname: http_health_alert
      group_by: [alertname, env]
      group_wait: 30s
      group_interval: 3m
      repeat_interval: 1h
      receiver: webhook_receiver

receivers:
  - name: webhook_receiver
    webhook_configs:
      - send_resolved: true
        url: http://example.com/alert/receiver
  - name: other_receiver
    email_configs:
      - send_resolved: true
        to: xx
        from: xxx
Blithe
  • 21
  • 2