Skip to content

Commit

Permalink
have an updated documentation for the web provider
Browse files Browse the repository at this point in the history
Signed-off-by: Noam Gal <[email protected]>
  • Loading branch information
ATGardner committed Oct 21, 2021
1 parent 086ef67 commit 7f412df
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion docs/analysis/web.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Web Metrics

A HTTP request can be performed against some external service to obtain the measurement. This example
An HTTP request can be performed against some external service to obtain the measurement. This example
makes a HTTP GET request to some URL. The webhook response must return JSON content. The result of
the optional `jsonPath` expression will be assigned to the `result` variable that can be referenced
in the `successCondition` and `failureCondition` expressions. If omitted, will use the entire body
Expand Down Expand Up @@ -49,3 +49,26 @@ NOTE: if the result is a string, two convenience functions `asInt` and `asFloat`
to convert a result value to a numeric type so that mathematical comparison operators can be used
(e.g. >, <, >=, <=).

### Optional web methods
It is possible to use a POST or PUT requests, by specifying the `method` and `body` fields

```yaml
metrics:
- name: webmetric
successCondition: result == true
provider:
web:
method: POST # valid values are GET|POST|PUT, defaults to GET
url: "http://my-server.com/api/v1/measurement?service={{ args.service-name }}"
timeoutSeconds: 20 # defaults to 10 seconds
headers:
- key: Authorization
value: "Bearer {{ args.api-token }}"
- key: Content-Type # if body is a json, it is recommended to set the Content-Type
value: "application/json"
body: "{\"key\": \"string value\"}"
jsonPath: "{$.data.ok}"
```
!!! tip
In order to send in JSON, you have to encode it yourself, and send the correct Content-Type as well.
Setting a `body` field for a `GET` request will result in an error.

0 comments on commit 7f412df

Please sign in to comment.