Silencing API
NOTE: Requests to the silencing API require you to authenticate with a Sensu access token or API key.
The code examples in this document use the environment variable $SENSU_API_KEY
to represent a valid API key in API requests.
Get all silences
The /silenced
API endpoint provides HTTP GET access to silencing entry data.
Example
The following example demonstrates a request to the /silenced
API endpoint, resulting in a JSON array that contains silencing entry definitions.
curl -X GET \
-H "Authorization: Key $SENSU_API_KEY" \
http://127.0.0.1:8080/api/core/v2/namespaces/default/silenced
HTTP/1.1 200 OK
[
{
"metadata": {
"name": "*:http",
"namespace": "default",
"created_by": "admin"
},
"expire": -1,
"expire_on_resolve": false,
"creator": "admin",
"check": "http",
"reason": "Testing",
"begin": 1605024595,
"expire_at": 0
},
{
"metadata": {
"name": "linux:*",
"namespace": "default",
"created_by": "admin"
},
"expire": -1,
"expire_on_resolve": false,
"creator": "admin",
"reason": "reason for silence",
"subscription": "linux",
"begin": 1542671205,
"expire_at": 0
}
]
API Specification
/silenced (GET) | |
---|---|
description | Returns the list of silences. |
example url | http://hostname:8080/api/core/v2/namespaces/default/silenced |
pagination | This endpoint does not support pagination. |
response filtering | This endpoint supports API response filtering. |
response type | Array |
response codes |
|
output |
|
Create a new silence
The /silenced
API endpoint provides HTTP POST access to create silencing entries.
Example
In the following example, an HTTP POST request is submitted to the /silenced
API endpoint to create the silencing entry linux:check-cpu
.
The request returns a successful HTTP 201 Created
response.
curl -X POST \
-H "Authorization: Key $SENSU_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"metadata": {
"name": "linux:check-cpu",
"namespace": "default",
"labels": null,
"annotations": null
},
"expire": -1,
"expire_on_resolve": false,
"creator": "admin",
"reason": "reason for silence",
"subscription": "linux",
"begin": 1542671205
}' \
http://127.0.0.1:8080/api/core/v2/namespaces/default/silenced
HTTP/1.1 201 Created
Here’s another example that shows an HTTP POST request to the /silenced
API endpoint to create the silencing entry *:http
, which will create a silence for any event with the check name http
, regardless of the originating entities’ subscriptions.
The request returns a successful HTTP 201 Created
response.
curl -X POST \
-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://127.0.0.1:8080/api/core/v2/namespaces/default/silenced
HTTP/1.1 201 Created
API Specification
/silenced (POST) | |
---|---|
description | Creates a Sensu silencing entry. |
example URL | http://hostname:8080/api/core/v2/namespaces/default/silenced |
payload |
|
response codes |
|
Get a specific silence
The /silenced/:silenced
API endpoint provides HTTP GET access to silencing entry data for specific :silenced
definitions, by silencing entry name.
Example
In the following example, querying the /silenced/:silenced
API endpoint returns a JSON map that contains the requested silencing entry definition (in this example, for the silencing entry named linux:check-cpu
).
Silencing entry names are generated from the combination of a subscription name and check name.
curl -X GET \
-H "Authorization: Key $SENSU_API_KEY" \
http://127.0.0.1:8080/api/core/v2/namespaces/default/silenced/linux:check-cpu
HTTP/1.1 200 OK
{
"metadata": {
"name": "linux:check-cpu",
"namespace": "default",
"created_by": "admin",
"labels": null,
"annotations": null
},
"expire": -1,
"expire_on_resolve": false,
"creator": "admin",
"reason": "reason for silence",
"subscription": "linux",
"begin": 1542671205
}
API Specification
/silenced/:silenced (GET) | |
---|---|
description | Returns the specified silencing entry. |
example url | http://hostname:8080/api/core/v2/namespaces/default/silenced/linux:check-cpu |
response type | Map |
response codes |
|
output |
|
Create or update a silence
The /silenced/:silenced
API endpoint provides HTTP PUT access to create or update specific :silenced
definitions, by silencing entry name.
Example
In the following example, an HTTP PUT request is submitted to the /silenced/:silenced
API endpoint to create the silencing entry linux:check-server
.
The request returns a successful HTTP 201 Created
response.
curl -X PUT \
-H "Authorization: Key $SENSU_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"metadata": {
"name": "linux:check-server",
"namespace": "default",
"labels": null,
"annotations": null
},
"expire": -1,
"expire_on_resolve": false,
"creator": "admin",
"reason": "reason for silence",
"subscription": "linux",
"begin": 1542671205
}' \
http://127.0.0.1:8080/api/core/v2/namespaces/default/silenced/linux:check-server
HTTP/1.1 201 Created
API Specification
/silenced/:silenced (PUT) | |
---|---|
description | Creates or updates a Sensu silencing entry. |
example URL | http://hostname:8080/api/core/v2/namespaces/default/silenced/linux:check-server |
payload |
|
response codes |
|
Delete a silence
The /silenced/:silenced
API endpoint provides HTTP DELETE access to delete a silencing entry (specified by the silencing entry name).
Example
In the following example, querying the /silenced/:silenced
API endpoint to delete the the silencing entry named linux:check-cpu
results in a successful HTTP 204 No Content
response.
curl -X DELETE \
-H "Authorization: Key $SENSU_API_KEY" \
http://127.0.0.1:8080/api/core/v2/namespaces/default/silenced/linux:check-cpu
HTTP/1.1 204 No Content
API Specification
/silenced/:silenced (DELETE) | |
---|---|
description | Removes the specified silencing entry from Sensu. |
example url | http://hostname:8080/api/core/v2/namespaces/default/silenced/linux:check-cpu |
response codes |
|
Get all silences for a specific subscription
The /silenced/subscriptions/:subscription
API endpoint provides HTTP GET access to silencing entry data by subscription name.
Example
In the following example, querying the silenced/subscriptions/:subscription
API endpoint returns a JSON array that contains the requested silences for the given subscription (in this example, for the linux
subscription).
curl -X GET \
-H "Authorization: Key $SENSU_API_KEY" \
http://127.0.0.1:8080/api/core/v2/namespaces/default/silenced/subscriptions/linux
HTTP/1.1 200 OK
[
{
"metadata": {
"name": "linux:check-cpu",
"namespace": "default",
"created_by": "admin",
"labels": null,
"annotations": null
},
"expire": -1,
"expire_on_resolve": false,
"creator": "admin",
"reason": "reason for silence",
"subscription": "linux",
"begin": 1542671205
}
]
API Specification
/silenced /subscriptions /:subscription (GET) | |
---|---|
description | Returns all silences for the specified subscription. |
example url | http://hostname:8080/api/core/v2/namespaces/default/silenced/subscriptions/linux |
pagination | This endpoint supports pagination using the limit and continue query parameters. |
response type | Array |
response codes |
|
output |
|
Get all silences for a specific check
The /silenced/checks/:check
API endpoint provides HTTP GET access to silencing entry data by check name.
Example
In the following example, querying the silenced/checks/:check
API endpoint returns a JSON array that contains the requested silences for the given check (in this example, for the check-cpu
check).
curl -X GET \
-H "Authorization: Key $SENSU_API_KEY" \
http://127.0.0.1:8080/api/core/v2/namespaces/default/silenced/checks/check-cpu
HTTP/1.1 200 OK
[
{
"metadata": {
"name": "linux:check-cpu",
"namespace": "default",
"created_by": "admin",
"labels": null,
"annotations": null
},
"expire": -1,
"expire_on_resolve": false,
"creator": "admin",
"reason": "reason for silence",
"check": "linux",
"begin": 1542671205
}
]
API Specification
/silenced/checks /:check (GET) | |
---|---|
description | Returns all silences for the specified check. |
example url | http://hostname:8080/api/core/v2/namespaces/default/silenced/checks/check-cpu |
pagination | This endpoint supports pagination using the limit and continue query parameters. |
response type | Array |
response codes |
|
output |
|