Alertmanager API cant create silences

23 views
Skip to first unread message

TechJunkie

unread,
May 11, 2020, 9:46:47 AM5/11/20
to Prometheus Users
Hie all ,
I am struck trying to POST a python dictionary as json for creating silence . The following is my data that i am posting to alertmanager silences endpoint:
data ={
              "id": id,
              "matchers": [
                {
                  "name": matcherName,
                  "value": matcherValue,
                  "isRegex": matcherIsRegx
                }
              ],
              "startsAt": startsAt,
              "endsAt": endsAt,
              "createdBy": createdBy,
              "comment": comment
            }
all the values are variables with datatypes as string except the isRegx which is boolean .
While posting it after creating a json using python requests library as :
payload = json.dumps(data)
I was getting error message as :
"parsing silence body from \"\" failed, because json: cannot unmarshal string into Go value of type struct { ID string \"json:\\\"id,omitempty\\\"\" }

Please help.
Regards

Łukasz Mierzwa

unread,
May 11, 2020, 11:03:17 AM5/11/20
to Prometheus Users
What are you passing under "id"?
You only pass id when editing existing silence (it must be an id of a valid active silence), not when creating a new one.
Reply all
Reply to author
Forward
0 new messages