API: Silence check without subscription

According to the documentation, silences can be applied to subscriptions or checks. If a silence is applied to an subscription, a wildcard is provided for the check, and vice versa.

From the Web UI, I can manually create a silence for a specific check and not specify the subscription. The result is that the check is applied to all subscriptions/entities.

For example, if I create a new silence for a check called check_salt_procs and leave subscription field blank, I get the following silence: *:check_salt_procs

The API seems to behave differently and I’ve been unable to successfully create the same silence.

If I try to submit my request without a subscription, the backend returns a 400.
If I include the name of the targeted subscription (which is not desirable for this use case), the entry name of the silence becomes the name of the subscription.

For example, if I define subscription in my request as "subscription": "salts", my silence becomes salts:*

Is this type of silence via the API possible? And if so, is there an example of a check silence without a subscription anywhere? The reference examples only appear to cover subscriptions.

I was able to create a silence similar to what you are saying, I believe, using the following:

curl -X PUT -H "Authorization: Key $SENSU_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
  "metadata": {
    "name": "*:http",
    "namespace": "default",
    "labels": null,
    "annotations": null
  "expire": -1,
  "expire_on_resolve": false,
  "creator": "admin",
  "check": "http",
  "reason": "Testing"
}' \*:http

This results in:

sensuctl silenced list
   Name    Subscription   Check          Begin          Expire   ExpireOnResolve   Creator   Reason   Namespace
 ──────── ────────────── ─────── ───────────────────── ──────── ───────────────── ───────── ──────── ───────────
  *:http                  http    20 Oct 20 12:10 UTC   -1s      false             admin     test     default
1 Like

I followed your lead and it worked.

The problem I see is that there is (still) no documentation on how to silence the checks via the api and the check attribute isn’t even listed in the api spec so I’m not sure how I would have even know about it without browsing the code.

I have submitted an issue for our docs, please feel free to comment on this issue if you wish to provide further background or clarification.

1 Like

It has been pointed out to me that the check attribute is listed in the spec attributes.

@todd, thank you for creating and reviewing the docs issue!

@irleg, thank you for bringing this to our attention. We added a check-only silence example to the GET and POST commands in the silencing API doc and links to check-only and subscription-only examples in the introduction of the silencing reference doc.

1 Like