Monitor an API with steps and variables
Build a composite API monitor with authentication from the vault, several steps that pass variables to each other, JSON validations and custom metrics.
On this page
An API monitor runs one or more requests in order, as your system would: it signs in, captures a value from the response, uses it in the next request and validates each result. It can chart numeric values from the responses and alert with thresholds.
Before you start
You need permission to operate on Applications.
Tokens, keys and certificates are stored in the vault. An administrator creates them in Settings → Monitoring → Credentials.
Step 1: general details
Go to Applications → WebServices and click Add WebService (or Edit on an existing one).
Enter the Name and, if you want, choose the Group (optional).
The form has the Request, Authentication, Validations, Steps, Metrics and Where it runs tabs. When there is more than one step, in Request and Validations you choose at the top which step what you are editing belongs to.
Step 2: the request
In Request:
Choose the Method and enter the URL.
Add Parameters and Headers with Add parameter and Add header.
For methods with a body, choose the Body Type: No body, JSON, Form or Text. If the JSON is not valid, the form warns you.
In Options, adjust the Timeout (s) (1 to 60), Follow redirects and Verify the TLS certificate.
Review the request Preview.
Do not put tokens or keys in the headers or parameters: use the Authentication tab. A method that changes data (POST, PUT, PATCH, DELETE) runs on every check; confirmation is requested when you save.
Step 3: authentication (login, token or OAuth2)
In Authentication:
In Credential, choose one from the vault. It can be:
API token (in a header or a parameter, with a prefix).
Username and password (Basic).
OAuth2.
Token obtained from another API (a prior login).
Optional: choose a Client certificate (mTLS).
If there are several steps, select in Steps that use authentication which ones carry it.
Secrets are never shown and never stay in the results.
Step 4: steps and variables
In Steps:
Click Add step (up to 10). Give each one a name.
With each step's buttons you can edit its request, move it up, move it down, duplicate it or remove it.
In Variables it captures, click Capture variable and define:
The variable name, for example
tokenorpedido.Where it comes from: JSON path (for example
$.data.id), Header (for exampleLocation) or Regular expression.Secret, if it must not be shown or stored.
Use the variable in the following steps by writing its name in double braces, for example
{{pedido}}, in the URL, headers, parameters or body.
If a step uses a variable that no previous step captures, the form warns you.
Step 5: validations
In Validations, choose the type and click Add validation:
Type | What it compares |
|---|---|
HTTP code | The expected codes, such as |
Response time | Warning and critical in milliseconds. |
Header | That a header exists, does not exist, equals or contains a value. |
Body (text or expression) | That the body contains, does not contain, matches the expression or does not match the expression. |
JSON value by path | That the value at a path (for example |
Each validation is Critical or Warning. A critical one marks the service as down and stops the following steps; a warning one puts it in warning. All of them must be met.
Step 6: metrics
In Metrics, chart numeric values captured in the steps:
Click Add metric (up to 10).
Choose the variable (not secret), enter the name (for example Pending orders) and the unit.
Choose Alert if above or Alert if below and enter the warning and critical values.
The latency of each step is always charted.
Step 7: where it runs, test and save
In Where it runs, choose Check from. See Choose where it is checked from.
Click Test now. “Test now” result appears below with the status, the latency and the details of each step.
Click Save. If something is missing, the form lists it before saving.