Filters API
The /filters
API endpoint
/filters
(GET)
The /filters
API endpoint provides HTTP GET access to filter data.
EXAMPLE
The following example demonstrates a request to the /filters
API, resulting in
a JSON Array containing filter definitions.
curl http://127.0.0.1:8080/api/core/v2/namespaces/default/filters -H "Authorization: Bearer $TOKEN"
[
{
"metadata": {
"name": "state_change_only",
"namespace": "default",
"labels": null,
"annotations": null
},
"action": "allow",
"expressions": [
"event.check.occurrences == 1"
],
"runtime_assets": []
}
]
API Specification
/filters (GET) | |
---|---|
description | Returns the list of filters. |
example url | http://hostname:8080/api/core/v2/namespaces/default/filters |
pagination | This endpoint supports pagination using the limit and continue query parameters. See the API overview for details. |
response type | Array |
response codes |
|
output |
|
/filters
(POST)
/filters (POST) | |
---|---|
description | Create a Sensu filter. |
example URL | http://hostname:8080/api/core/v2/namespaces/default/filters |
payload |
|
response codes |
|
The /filters/:filter
API endpoint
/filters/:filter
(GET)
The /filters/:filter
API endpoint provides HTTP GET access to filter data for specific :filter
definitions, by filter name
.
EXAMPLE
In the following example, querying the /filters/:filter
API returns a JSON Map
containing the requested :filter
definition (in this example: for the :filter
named
state_change_only
).
curl http://127.0.0.1:8080/api/core/v2/namespaces/default/filters/state_change_only -H "Authorization: Bearer $TOKEN"
{
"metadata": {
"name": "state_change_only",
"namespace": "default",
"labels": null,
"annotations": null
},
"action": "allow",
"expressions": [
"event.check.occurrences == 1"
],
"runtime_assets": []
}
API Specification
/filters/:filter (GET) | |
---|---|
description | Returns a filter. |
example url | http://hostname:8080/api/core/v2/namespaces/default/filters/state_change_only |
response type | Map |
response codes |
|
output |
|
/filters/:filter
(PUT)
API Specification
/filters/:filter (PUT) | |
---|---|
description | Create or update a Sensu filter. |
example URL | http://hostname:8080/api/core/v2/namespaces/default/filters/development_filter |
payload |
|
response codes |
|
/filters/:filter
(DELETE)
The /filters/:filter
API endpoint provides HTTP DELETE access to delete a filter from Sensu given the filter name.
EXAMPLE
The following example shows a request to delete the filter production-only
, resulting in a successful HTTP 204 No Content response.
curl -X DELETE \
-H "Authorization: Bearer $SENSU_TOKEN" \
http://127.0.0.1:8080/api/core/v2/namespaces/default/filters/production-only
HTTP/1.1 204 No Content
API Specification
/filters/:filter (DELETE) | |
---|---|
description | Removes a filter from Sensu given the filter name. |
example url | http://hostname:8080/api/core/v2/namespaces/default/filters/production-only |
response codes |
|