Events API

The /events API endpoint

The /events API endpoint provide HTTP GET access to the Sensu event registry.

/events (GET)

EXAMPLES

The following example demonstrates a /events API query which returns a JSON Array of JSON Hashes containing event data.

$ curl -s http://127.0.0.1:3000/events | jq .
[
  {
    "_id": "us_west1/client-01/sensu_website",
    "action": "create",
    "check": {
      "total_state_change": 14,
      "history": [
        "0",
        "3",
        "3",
        "3",
        "3",
        "3",
        "3",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "0",
        "1"
      ],
      "status": 1,
      "output": "CheckHttp WARNING: 301\n",
      "command": "check-http.rb -u :::website|http://sensu.io:::",
      "subscribers": [
        "production"
      ],
      "interval": 60,
      "handler": "mail",
      "name": "sensu_website",
      "issued": 1460303502,
      "executed": 1460303502,
      "duration": 0.032
    },
    "client": {
      "timestamp": 1460303501,
      "version": "1.5.0",
      "website": "http://google.com",
      "socket": {
        "port": 3030,
        "bind": "127.0.0.1"
      },
      "subscriptions": [
        "production"
      ],
      "environment": "development",
      "address": "127.0.0.1",
      "name": "client-01",
      "silenced": false
    },
    "dc": "us_west1",
    "id": "0f42ec94-12bf-4918-a0b9-52fd57e8ee96",
    "last_ok": 1460303501,
    "last_state_change": 1460303502,
    "occurrences": 1,
    "occurrences_watermark": 1,
    "silenced": false,
    "silenced_by": null,
    "timestamp": 1460303502
  }
]

API specification

/events (GET)
description Returns the list of current events with check, client, and datacenter (dc) information
example url http://hostname:3000/events
response type Array
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
[
  {
    "_id": "us_west1/client-01/sensu_website",
    "action": "create",
    "check": {
      "total_state_change": 14,
      "history": [
        "0",
        "1"
      ],
      "status": 1,
      "output": "CheckHttp WARNING: 301\n",
      "command": "check-http.rb -u :::website|http://sensu.io:::",
      "subscribers": [
        "production"
      ],
      "interval": 60,
      "handler": "mail",
      "name": "sensu_website",
      "issued": 1460303502,
      "executed": 1460303502,
      "duration": 0.032
    },
    "client": {
      "timestamp": 1460303501,
      "version": "1.5.0",
      "website": "http://google.com",
      "subscriptions": [
        "production"
      ],
      "environment": "development",
      "address": "127.0.0.1",
      "name": "client-01",
      "silenced": false
    },
    "dc": "us_west1",
    "id": "0f42ec94-12bf-4918-a0b9-52fd57e8ee96",
    "last_ok": 1460303501,
    "last_state_change": 1460303502,
    "occurrences": 1,
    "occurrences_watermark": 1,
    "silenced": false,
    "silenced_by": null,
    "timestamp": 1460303502
  }
]

The /events/:client/:check API endpoint

The /events/:client/:check API provides HTTP DELETE access to current event data for a named client and check.

/events/:client/:check (DELETE)

EXAMPLES

The following example demonstrates a /events/:client/:check API request to to delete event data for a client named client-01 and a check named sensu_website, resulting in a 202 (Accepted) HTTP response code.

curl -s -i -X DELETE http://127.0.0.1:3000/events/client-01/sensu_website
HTTP/1.1 202 Accepted
Content-Type: application/json
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
Content-Length: 21
Connection: keep-alive
Server: thin

API specification

/events/:client/:check (DELETE)
description Resolves an event for a given check on a given client. (delayed action)
example url http://hostname:3000/events/i-424242/chef_client_process
parameters
  • dc:
    • required: false
    • type: String
    • description: If the check name is present in multiple datacenters, specifying the dc parameter accesses only the check found in that datacenter.
    • example: http://hostname:3000/events/i-424242/chef_client_process?dc=us_west1
response codes
  • Success: 202 (Accepted)
  • Found in multiple datacenters: 300 (Multiple Choices)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)
Is this page helpful?