Multistep API tests allow you to chain HTTP tests to proactively monitor that sophisticated journeys on your key services are available at anytime and from anywhere:
If one of your services starts answering more slowly, or in an unexpected way (for example, unexpected response body, status code, etc.), your test can alert your team, block your CI pipeline, or even roll back the faulty deployment.
Multistep API tests can run from Datadog managed locations and private locations, allowing full coverage of your systems, both external and internal.
Note: Multistep API tests allow you to link several HTTP requests in a single test. If you want to perform single requests to your services, you can leverage API tests.
env
Tags as well as any other tag to your Multistep API test. You can then use these tags to quickly filter through your Synthetic tests on the Synthetic Monitoring homepage.Select the Locations to run your Multistep API test from: Multistep API tests can run from both managed and private locations depending on whether you are willing to run the test from outside or inside your network.
Hit Create Your First Request to start designing your test’s requests.
GET
, POST
, PATCH
, PUT
, HEAD
, DELETE
, and OPTIONS
. Both http
and https
URLs are supported.user-agent
header).<COOKIE_NAME1>=<COOKIE_VALUE1>; <COOKIE_NAME2>=<COOKIE_VALUE2>
.text/plain
, application/json
, text/xml
, text/html
, or None
) you want to add to your HTTP request.http://<YOUR_USER>:<YOUR_PWD>@<YOUR_IP>:<YOUR_PORT>
).Click on Test URL to try out the request configuration. You should see a response preview show up.
Assertions define what an expected test result is. When hitting Test URL
basic assertions on response time
, status code
, and header
content-type
are added based on the response that was obtained. In Multistep API tests, assertions are optional.
Type | Operator | Value type |
---|---|---|
body | contains , does not contain , is , is not ,matches , does not match ,jsonpath | String Regex String, Regex |
header | contains , does not contain , is , is not ,matches , does not match | String _Regex |
response time | is less than | Integer (ms) |
status code | is , is not | Integer |
Note: HTTP tests can uncompress bodies with the following content-encoding
headers: br
, deflate
, gzip
, and identity
.
You can create up to 10 assertions per step by clicking on New Assertion or by clicking directly on the response preview:
You can also optionally extract variables from the response of your HTTP request by parsing its response headers or body. The value of the variable is updated each time the HTTP request step is being run.
To parse your variable:
Enter a Variable Name. Your variable name can only use uppercase letters, numbers, and underscores and must have at least three characters.
Decide whether to extract your variable from the response headers, or from the response body:
Once created this variable can be used in the following steps of your Multistep API test.
Multistep API tests can run:
Set alert conditions to determine the circumstances under which you want a test to fail and trigger an alert.
When you set the alert conditions to: An alert is triggered if any assertion fails for X minutes from any n of N locations
, an alert is triggered only if these two conditions are true:
Your test can trigger retries in case of failed test result. By default, the retries are performed 300 ms after the first failed test result-this interval can be configured via the API.
Location uptime is computed on a per-evaluation basis (whether the last test result before evaluation was up or down). The total uptime is computed based on the configured alert conditions. Notifications sent are based on the total uptime.
A notification is sent by your test based on the alerting conditions previously defined. Use this section to define how and what message to send to your teams.
Similar to monitors, select users and/or services that should receive notifications either by adding an @notification
to the message or by searching for team members and connected integrations with the drop-down box.
Enter the notification message for your test. This field allows standard Markdown formatting and supports the following conditional variables:
Conditional Variable | Description |
---|---|
{{#is_alert}} | Show when the test alerts. |
{{^is_alert}} | Show unless the test alerts. |
{{#is_recovery}} | Show when the test recovers from alert. |
{{^is_recovery}} | Show unless the test recovers from alert. |
Specify how often you want your test to re-send the notification message in case of test failure. To prevent renotification on failing tests, leave the option as Never renotify if the monitor has not been resolved
.
Email notifications include the message defined in this section as well as a summary of failed assertions. Notifications example:
Click on Save to save your test and have Datadog start executing it.
You can extract variables from any step of your Multistep API test to then re-inject their values in subsequent steps of your test.
You can create local variables by defining their values from one of the below available builtins:
Pattern | Description |
---|---|
{{ numeric(n) }} | Generates a numeric string with n digits. |
{{ alphabetic(n) }} | Generates an alphabetic string with n letters. |
{{ alphanumeric(n) }} | Generates an alphanumeric string with n characters. |
{{ date(n, format) }} | Generates a date in one of our accepted formats with a value of the date the test is initiated + n days. |
{{ timestamp(n, unit) }} | Generates a timestamp in one of our accepted units with a value of the timestamp the test is initiated at +/- n chosen unit. |
You can use the global variables defined in the Settings
and the locally defined variables in the URL, Advanced Options, and assertions of your HTTP tests.
To display your list of variables, type {{
in your desired field.
A test is considered FAILED
if a step does not satisfy one or several assertions or if a step’s request prematurely failed. In some cases, the test can indeed fail without being able to test the assertions against the endpoint, these reasons include:
Error | Description |
---|---|
CONNRESET | The connection was abruptly closed by the remote server. Possible causes include the webserver encountering an error or crashing while responding, or loss of connectivity of the webserver. |
DNS | DNS entry not found for the test URL. Possible causes include misconfigured test URL, wrong configuration of your DNS entries, etc. |
INVALID_REQUEST | The configuration of the test is invalid (for example, a typo in the URL). |
SSL | The SSL connection couldn’t be performed. See the dedicated error page for more information. |
TIMEOUT | The request couldn’t be completed in a reasonable time. Two types of TIMEOUT can happen.- TIMEOUT: The request couldn’t be completed in a reasonable time. indicates that the timeout happened at the TCP socket connection level.- TIMEOUT: Retrieving the response couldn’t be completed in a reasonable time. indicates that the timeout happened on the overall run (which includes TCP socket connection, data transfer, and assertions). |
Additional helpful documentation, links, and articles: