Handlers API
The /handlers
API endpoint
/handlers
(GET)
The /handlers
API endpoint provides HTTP GET access to handler data.
EXAMPLE
The following example demonstrates a request to the /handlers
API, resulting in
a JSON Array containing handler definitions.
curl http://127.0.0.1:8080/api/core/v2/namespaces/default/handlers -H "Authorization: Bearer $SENSU_TOKEN"
[
{
"metadata": {
"name": "slack",
"namespace": "default",
"labels": null,
"annotations": null
},
"command": "sensu-slack-handler --channel '#monitoring'",
"env_vars": [
"SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
],
"filters": [
"is_incident",
"not_silenced"
],
"handlers": [],
"runtime_assets": [],
"timeout": 0,
"type": "pipe"
}
]
API Specification
/handlers (GET) | |
---|---|
description | Returns the list of handlers. |
example url | http://hostname:8080/api/core/v2/namespaces/default/handlers |
pagination | This endpoint supports pagination using the limit and continue query parameters. See the API overview for details. |
response type | Array |
response codes |
|
output |
|
/handlers
(POST)
/handlers (POST) | |
---|---|
description | Create a Sensu handler. |
example URL | http://hostname:8080/api/core/v2/namespaces/default/handlers |
payload |
|
response codes |
|
The /handlers/:handler
API endpoint
/handlers/:handler
(GET)
The /handlers/:handler
API endpoint provides HTTP GET access to handler data for specific :handler
definitions, by handler name
.
EXAMPLE
In the following example, querying the /handlers/:handler
API returns a JSON Map
containing the requested :handler
definition (in this example: for the :handler
named
slack
).
curl http://127.0.0.1:8080/api/core/v2/namespaces/default/handlers/slack -H "Authorization: Bearer $SENSU_TOKEN"
{
"metadata": {
"name": "slack",
"namespace": "default",
"labels": null,
"annotations": null
},
"command": "sensu-slack-handler --channel '#monitoring'",
"env_vars": [
"SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
],
"filters": [
"is_incident",
"not_silenced"
],
"handlers": [],
"runtime_assets": [],
"timeout": 0,
"type": "pipe"
}
API Specification
/handlers/:handler (GET) | |
---|---|
description | Returns a handler. |
example url | http://hostname:8080/api/core/v2/namespaces/default/handlers/slack |
response type | Map |
response codes |
|
output |
|
/handlers/:handler
(PUT)
API Specification
/handlers/:handler (PUT) | |
---|---|
description | Create or update a Sensu handler. |
example URL | http://hostname:8080/api/core/v2/namespaces/default/handlers/influx-db |
payload |
|
response codes |
|
/handlers/:handler
(DELETE)
The /handlers/:handler
API endpoint provides HTTP DELETE access to delete a handler from Sensu given the handler name.
EXAMPLE
The following example shows a request to delete the handler slack
, 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/handlers/slack
HTTP/1.1 204 No Content
API Specification
/handlers/:handler (DELETE) | |
---|---|
description | Removes a handler from Sensu given the handler name. |
example url | http://hostname:8080/api/core/v2/namespaces/default/handlers/slack |
response codes |
|