how to set silence with alertmanager api

12,036 views
Skip to first unread message

swon...@gmail.com

unread,
Jan 24, 2018, 8:38:55 PM1/24/18
to Prometheus Users
Hi there,

I'm trying to manage the alertmanager via api.

With a few tests, I can get the list of alerts but can't post a new silence back.

Below is the format of an active silence.

{'data': [{'comment': 'under maintenance.',
   'createdBy': 'ops',
   'endsAt': '2018-02-07T00:26:58.889Z',
   'id': '6c1a7f99-f914-47f6-bcf7-dea31d212aa2',
   'matchers': [{'isRegex': False, 'name': 'job', 'value': 'snmp-apac'}],
   'startsAt': '2018-01-24T00:27:44.298491798Z',
   'status': {'state': 'active'},
   'updatedAt': '2018-01-24T00:27:44.298498851Z'}],
 'status': 'success'}


I followed the above format and post one back but the HTTP response.ok = false.

Below is the format of the silence I post back.

{'data': [{'comment': 'test to silence by api',
   'createdBy': 'ops',
   'endsAt': '2018-01-25T23:59:59',
   'matchers': [{'isRegex': 'False',
     'name': 'job',
     'value': 'snmp-singapore'}],
   'startsAt': '2018-01-25T00:00:00',
   'status': {'state': 'active'}}],
 'status': 'success'}

The API documentation isn't available and the API is subject to change since last year but there isn't any update yet.

Is there anyone able to set silence by api? Can you please comment how you set it?

Thanks,
Steven

Luiz Gustavo Tonello

unread,
Jan 26, 2018, 5:25:06 AM1/26/18
to swon...@gmail.com, Prometheus Users
Hi Steven, 

Maybe, it would help you.

Best,

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/b0b78047-5118-43a8-a63a-5a1ad71464c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Luiz Gustavo P Tonello.

Mathias Methner

unread,
Jan 31, 2018, 3:24:17 AM1/31/18
to Prometheus Users
Thanks Luiz for the hint to amtool. Did not know it is existing until now.

valentin....@genesys.com

unread,
Oct 25, 2018, 4:42:25 PM10/25/18
to Prometheus Users
It works for me:

      "matchers": [
        {
          "name": "alername1",
          "value": ".*",
          "isRegex": true
        }
      ],
      "startsAt": "2018-10-25T22:12:33.533330795Z",
      "endsAt": "2018-10-25T23:11:44.603Z",
      "createdBy": "api",
      "comment": "Silence",
      "status": {
        "state": "active"
      }

}'

Sambi Reddy

unread,
Sep 3, 2019, 4:28:29 PM9/3/19
to Prometheus Users
where do you set time to silence alarm for a certain period ?
To unsubscribe from this group and stop receiving emails from it, send an email to promethe...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.

Simon Pasquier

unread,
Sep 5, 2019, 5:39:26 AM9/5/19
to Sambi Reddy, Prometheus Users
amtool silence add --duration <duration> [--start <start date>]
alertname=SomeAlert

Check "amtool silence add --help".
> To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/5eea0f9e-73d8-4789-b57e-ffffda4aadcb%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages