carrotcakeslayer
carrotcakeslayer

Reputation: 1008

Prometheus Alertmanager API to manage silences

I'd like to create and delete silences via API using curl calls if possible. I am able to create the silences by using this sort of calls:

curl https://cluster.internal.org/path/alertmanager/api/v2/silences -H "Content-Type: application/json" -d '{
  "matchers": [
    {
      "name": "env",
      "value": "pakalu",
      "isRegex": false
    }
  ],
  "startsAt": "2023-10-25T22:12:33.533330795Z",
  "endsAt": "2023-10-25T23:11:44.603Z",
  "createdBy": "api",
  "comment": "Silence",
  "status": {
    "state": "active"
  }

}'

But I do not know how to make the call to delete it. Using -XDELETE in the calls, returns a "Method not valid".

Upvotes: 2

Views: 5278

Answers (1)

Use the following call:

curl --request DELETE https://cluster.internal.org/path/alertmanager/api/v2/silence/SILENCE-ID"

SILENT-ID is the Id returned by the creation API call (ex: c177e559-0d81-41ad-a866-9748fc16ef42).

Upvotes: 2

Related Questions