Hooks API
The /hooks
API endpoint
/hooks
(GET)
The /hooks
API endpoint provides HTTP GET access to hook data.
EXAMPLE
The following example demonstrates a request to the /hooks
API, resulting in
a JSON Array containing hook definitions.
curl http://127.0.0.1:8080/api/core/v2/namespaces/default/hooks -H "Authorization: Bearer $SENSU_TOKEN"
[
{
"metadata": {
"name": "process-tree",
"namespace": "default",
"labels": null,
"annotations": null
},
"command": "ps aux",
"timeout": 10,
"stdin": false
}
]
API Specification
/hooks (GET) | |
---|---|
description | Returns the list of hooks. |
example url | http://hostname:8080/api/core/v2/namespaces/default/hooks |
pagination | This endpoint supports pagination using the limit and continue query parameters. See the API overview for details. |
response type | Array |
response codes |
|
output |
|
/hooks
(POST)
/hooks (POST) | |
---|---|
description | Create a Sensu hook. |
example URL | http://hostname:8080/api/core/v2/namespaces/default/hooks |
payload |
|
response codes |
|
The /hooks/:hook
API endpoint
/hooks/:hook
(GET)
The /hooks/:hook
API endpoint provides HTTP GET access to hook data for specific :hook
definitions, by hook name
.
EXAMPLE
In the following example, querying the /hooks/:hook
API returns a JSON Map
containing the requested :hook
definition (in this example: for the :hook
named
process-tree
).
curl http://127.0.0.1:8080/api/core/v2/namespaces/default/hooks/process-tree -H "Authorization: Bearer $SENSU_TOKEN"
{
"metadata": {
"name": "process-tree",
"namespace": "default",
"labels": null,
"annotations": null
},
"command": "ps aux",
"timeout": 10,
"stdin": false
}
API Specification
/hooks/:hook (GET) | |
---|---|
description | Returns a hook. |
example url | http://hostname:8080/api/core/v2/namespaces/default/hooks/process-tree |
response type | Map |
response codes |
|
output |
|
/hooks/:hook
(PUT)
API Specification
/hooks/:hook (PUT) | |
---|---|
description | Create or update a Sensu hook. |
example URL | http://hostname:8080/api/core/v2/namespaces/default/hooks/process-tree |
payload |
|
response codes |
|
/hooks/:hook
(DELETE)
The /hooks/:hook
API endpoint provides HTTP DELETE access to delete a check hook from Sensu given the hook name.
EXAMPLE
The following example shows a request to delete the hook process-tree
, 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/hooks/process-tree
HTTP/1.1 204 No Content
API Specification
/hooks/:hook (DELETE) | |
---|---|
description | Removes a hook from Sensu given the hook name. |
example url | http://hostname:8080/api/core/v2/namespaces/default/hooks/process-tree |
response codes |
|