Skip to content

Commit

Permalink
Add POST and response.body examples (elastic#13941) (elastic#13952)
Browse files Browse the repository at this point in the history
* Add  POST and response.body examples

* Moved comments to text
  • Loading branch information
dedemorton authored Oct 7, 2019
1 parent 70fb0d7 commit 2a1fd96
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions heartbeat/docs/heartbeat-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,56 @@ Under `check.request`, specify these options:
*`headers`*:: A dictionary of additional HTTP headers to send.
*`body`*:: Optional request body content.

Example configuration:
This monitor POSTs an `x-www-form-urlencoded` string
to the endpoint `/demo/add`

[source,yaml]
-------------------------------------------------------------------------------
- type: http
schedule: '@every 5s'
urls: ["http://localhost:8080/demo/add"]
check.request:
method: POST
headers:
'Content-Type': 'application/x-www-form-urlencoded'
# urlencode the body:
body: "name=first&email=someemail%40someemailprovider.com"
check.response:
status: 200
body:
- Saved
- saved
-------------------------------------------------------------------------------

Under `check.response`, specify these options:

*`status`*:: The expected status code. 4xx and 5xx codes are considered `down` by default. Other codes are considered `up`.
*`headers`*:: The required response headers.
*`body`*:: A list of regular expressions to match the the body output. Only a single expression needs to match.

Example configuration:
This monitor examines the
response body for the strings `saved` or `Saved`

[source,yaml]
-------------------------------------------------------------------------------
- type: http
schedule: '@every 5s'
urls: ["http://localhost:8080/demo/add"]
check.request:
method: POST
headers:
'Content-Type': 'application/x-www-form-urlencoded'
# urlencode the body:
body: "name=first&email=someemail%40someemailprovider.com"
check.response:
status: 200
body:
- Saved
- saved
-------------------------------------------------------------------------------

*`json`*:: A list of <<conditions,condition>> expressions executed against the body when parsed as JSON.

The following configuration shows how to check the response when the body
Expand Down

0 comments on commit 2a1fd96

Please sign in to comment.