core/v2/silenced
NOTE: Requests to core/v2/silenced API endpoints require you to authenticate with a Sensu API key or access token.
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 GET request to the /silenced API endpoint:
curl -X GET \
-H "Authorization: Key $SENSU_API_KEY" \
http://127.0.0.1:8080/api/core/v2/namespaces/default/silencedThe request results in a successful HTTP/1.1 200 OK response and a JSON array that contains the silencing definitions in the default namespace:
[
{
"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:
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/silencedThe request will return a successful HTTP/1.1 201 Created response.
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:
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/silencedThe request will return a successful HTTP/1.1 201 Created response.
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
The following example queries the /silenced/:silenced API endpoint for the silencing entry named linux:check_cpu:
curl -X GET \
-H "Authorization: Key $SENSU_API_KEY" \
http://127.0.0.1:8080/api/core/v2/namespaces/default/silenced/linux:check_cpuThe request will return a successful HTTP/1.1 200 OK response and a JSON map that contains the requested :silenced definition (in this example, linux:check_cpu):
{
"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:
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-serverThe request will return a successful HTTP/1.1 201 Created response.
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/1.1 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_cpuAPI 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
The following example queries the silenced/subscriptions/:subscription API endpoint for 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/linuxThe example request will result in a successful HTTP/1.1 200 OK response and a JSON array that contains only silencing definitions for the linux subscription:
[
{
"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
The following example queries the silenced/checks/:check API endpoint for silences for the specified 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_cpuThe example request will result in a successful HTTP/1.1 200 OK response and a JSON array that contains only silencing definitions for the check_cpu check:
[
{
"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 | |
Get a subset of silences with response filtering
The /silenced API endpoint supports response filtering for a subset of silences data based on labels and the following fields:
silenced.namesilenced.namespacesilenced.checksilenced.creatorsilenced.expire_on_resolvesilenced.subscription
Example
The following example demonstrates a request to the /silenced API endpoint with response filtering for only silencing definitions in the development namespace:
curl -H "Authorization: Key $SENSU_API_KEY" http://127.0.0.1:8080/api/core/v2/silenced -G \
--data-urlencode 'fieldSelector="development" in silenced.namespace'The example request will result in a successful HTTP/1.1 200 OK response and a JSON array that contains only silencing definitions in the development namespace:
[
{
"metadata": {
"name": "linux:*",
"namespace": "development",
"created_by": "admin"
},
"expire": -1,
"expire_on_resolve": false,
"creator": "admin",
"subscription": "linux",
"begin": 1644868317,
"expire_at": 0
}
]NOTE: Read API response filtering for more filter statement examples that demonstrate how to filter responses using different operators with label and field selectors.
API Specification
| /silenced (GET) with response filters | |
|---|---|
| description | Returns the list of silences that match the response filters applied in the API request. |
| example url | http://hostname:8080/api/core/v2/silenced |
| pagination | This endpoint supports pagination using the limit and continue query parameters. |
| response type | Array |
| response codes |
|
| output | |