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 -s http://127.0.0.1:8080/api/core/v2/namespaces/default/handlers -H "Authorization: Bearer TOKEN"
[
  {
    "metadata": {
      "name": "slack",
      "namespace": "default",
      "labels": null,
      "annotations": null
    },
    "type": "pipe",
    "command": "handler-slack --webhook-url https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX --channel monitoring",
    "timeout": 0,
    "handlers": null,
    "filters": null,
    "env_vars": null,
    "runtime_assets": null
  }
]

API Specification

/handlers (GET)
description Returns the list of handlers.
example url http://hostname:8080/api/core/v2/namespaces/default/handlers
response type Array
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
[
  {
    "metadata": {
      "name": "slack",
      "namespace": "default",
      "labels": null,
      "annotations": null
    },
    "type": "pipe",
    "command": "handler-slack --webhook-url https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX --channel monitoring",
    "timeout": 0,
    "handlers": null,
    "filters": null,
    "env_vars": null,
    "runtime_assets": null
  },
  {
    "metadata": {
      "name": "influx-db",
      "namespace": "default",
      "labels": null,
      "annotations": null
    },
    "type": "pipe",
    "command": "sensu-influxdb-handler --addr 'http://123.4.5.6:8086' --db-name 'sensu' --username 'sensu' --password 'password'",
    "timeout": 0,
    "handlers": null,
    "filters": null,
    "env_vars": null,
    "runtime_assets": null
  }
]

/handlers (POST)

/handlers (POST)
description Create a Sensu handler.
example URL http://hostname:8080/api/core/v2/namespaces/default/handlers
payload
{
  "metadata": {
    "name": "influx-db",
    "namespace": "default",
    "labels": null,
    "annotations": null
  },
  "type": "pipe",
  "command": "sensu-influxdb-handler --addr 'http://123.4.5.6:8086' --db-name 'sensu' --username 'sensu' --password 'password'",
  "timeout": 0,
  "handlers": null,
  "filters": null,
  "env_vars": null,
  "runtime_assets": null
}
response codes
  • Success: 200 (OK)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

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 -s http://127.0.0.1:8080/api/core/v2/namespaces/default/handlers/slack -H "Authorization: Bearer TOKEN"
{
  "metadata": {
    "name": "slack",
    "namespace": "default",
    "labels": null,
    "annotations": null
  },
  "type": "pipe",
  "command": "handler-slack --webhook-url https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX --channel monitoring",
  "timeout": 0,
  "handlers": null,
  "filters": null,
  "env_vars": null,
  "runtime_assets": null
}

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
  • Success: 200 (OK)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)
output
{
  "metadata": {
    "name": "slack",
    "namespace": "default",
    "labels": null,
    "annotations": null
  },
  "type": "pipe",
  "command": "handler-slack --webhook-url https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX --channel monitoring",
  "timeout": 0,
  "handlers": null,
  "filters": null,
  "env_vars": null,
  "runtime_assets": null
}

/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
{
  "metadata": {
    "name": "influx-db",
    "namespace": "default",
    "labels": null,
    "annotations": null
  },
  "type": "pipe",
  "command": "sensu-influxdb-handler --addr 'http://123.4.5.6:8086' --db-name 'sensu' --username 'sensu' --password 'password'",
  "timeout": 0,
  "handlers": null,
  "filters": null,
  "env_vars": null,
  "runtime_assets": null
}
response codes
  • Success: 201 (Created)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

/handlers/:handler (DELETE)

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
  • Success: 202 (Accepted)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)