Search code examples
prometheus-alertmanager

Create an alert on alertmanager using curl


I came across this need and could not find a simple answer:

I have a Prometheus + Alertmanager setup and want to test the alertmanager third party integrations.

So I wanted to create a dummy alert without having to change rules on prometheus and etc.

How can I create a test alert on alertmanager?


Solution

  • In case someone else has the same need sometime, it can be achieved by a simple curl command like bellow

    curl -w '\n' -i --user 'admin:admin' \
      --header 'Content-Type: application/json' \
      --data '[{"labels":{"alertname":"test_opsgenie", "team":"opsgenie"},"endsAt":"2023-03-21T00:10:53-03:00"}]' \
      http://alertmanager_url:9093/api/v1/alerts