Stashes API

The /stashes API endpoints

The /stashes API endpoint provides HTTP GET and HTTP POST access to Sensu stash data via the Sensu key/value store.

/stashes (GET)

EXAMPLES

The following example demonstrates a /stashes query, which results in a JSON Array of JSON Hashes containing stash data.

$ curl -s http://127.0.0.1:3000/stashes | jq .
[
  {
    "_id": "us_west1/silence/i-424242/chef_client_process",
    "dc": "us_west1",
    "path": "silence/i-424242/chef_client_process",
    "content": {
      "timestamp": 1383441836
    },
    "expire": 3600
  },
  {
    "_id": "us_east1/application/storefront",
    "dc": "us_east1",
    "path": "application/storefront",
    "content": {
      "timestamp": 1381350802,
      "endpoints": [
        "https://hostname/store"
      ]
    },
    "expire": -1
  }
]

API specification

/stashes (GET)
description Returns a list of stashes by path and datacenter (dc).
example url http://hostname:3000/stashes
response type Array
response codes
  • Success: 200 (OK)
  • Error: 500 (Internal Server Error)
output
[
  {
    "_id": "us_west1/silence/i-424242/chef_client_process",
    "dc": "us_west1",
    "path": "silence/i-424242/chef_client_process",
    "content": {
      "timestamp": 1383441836
    },
    "expire": 3600
  },
  {
    "_id": "us_east1/application/storefront",
    "dc": "us_east1",
    "path": "application/storefront",
    "content": {
      "timestamp": 1381350802,
      "endpoints": [
        "https://hostname/store"
      ]
    },
    "expire": -1
  }
]

/stashes (POST)

The /stashes API provides HTTP POST access to create a Sensu stash.

EXAMPLES

The following example demonstrates submitting an HTTP POST request containing a JSON document payload to the /stashes API, resulting in a 200 (OK) HTTP response code and a payload containing a JSON Hash confirming the stash path.

$ curl -s -i -X POST \
-H 'Content-Type: application/json' \
-d '{ "dc": "us_west1", "path": "example/stash/path", "content": { "foo": "bar" }}' \
http://127.0.0.1:3000/stashes

HTTP/1.1 200 OK
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: 29
Connection: keep-alive
Server: thin

{"path":"example/stash/path"}

API specification

/stashes (POST)
description Create a Sensu stash.
example URL http://hostname:3000/stashes
payload
{
  "dc": "us_west1",
  "path": "example/stash",
  "content": {
    "message": "example"
  },
  "expire": -1
}
payload parameters
  • dc
    • required: true
    • type: String
    • description: Specifies the name of the datacenter where the stash applies.
    • example: "us_west1"
  • path
    • required: true
    • type: String
    • description: The path (or “key”) the stash is created and accessible at.
    • example: "example/stash"
  • content
    • required: false
    • type: Hash
    • description: Arbitrary JSON data.
    • example: {"message": "example"}
  • expire
    • required: false
    • type: Integer
    • description: How long the stash exists before it is removed by the API, in seconds
    • example: 3600
response codes
  • Success: 200 (OK)
  • Malformed: 400 (Bad Request)
  • Error: 500 (Internal Server Error)

The /stashes/:path API endpoint

The /stashes/:path API endpoint provides HTTP DELETE access to Sensu stash data for a stash specified by its path.

/stashes/:path (DELETE)

EXAMPLES

The following example demonstrates submitting an HTTP DELETE request to the /stashes/:path API to delete a stash with the path my/example/path, resulting in a 202 (Accepted) HTTP response code.

$ curl -s -i -X DELETE http://127.0.0.1:3000/stashes/my/example/path                                                                                                                                                                                        
HTTP/1.1 202 Accepted
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
Connection: close
Server: thin

API specification

/stashes/:path (DELETE)
description Delete a Sensu stash.
example URL http://hostname:3000/stashes/example/stash
response type HTTP-header only (no output)
response codes
  • Success: 202 (Accepted)
  • Missing: 404 (Not Found)
  • Error: 500 (Internal Server Error)
output
HTTP/1.1 202 Accepted
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
Connection: close
Server: thin
Is this page helpful?