Identify Synthetic Bots

Identify Synthetic Bots

Overview

Some parts of your systems might not be available to robots without the right identification, or you might want to avoid collecting analytics from Datadog robots. You can use the below methods to detect Datadog Synthetic Monitoring robots.

IP addresses

You can use the Synthetic Monitoring IP ranges corresponding to each Datadog managed location:

https://ip-ranges./synthetics.json

Note: IPs listed use the CIDR notation and may require conversion to IPv4 address ranges before use.

Note: Except in the case of new managed locations IPs, the listed IPs rarely change. That being said, if you want to be alerted when the listed IPs change, you can create an API test on the above endpoint with a JSONPath assertion like $.synthetics['prefixes_ipv4_by_location']['aws:ap-northeast-1'].length.

Default headers

You can also identify Datadog robots by using some of the default headers attached to the requests generated by Synthetic tests:

user-agent

A user-agent header is added to all requests performed by Synthetic tests.

For single and multistep API tests, the user-agent header is Datadog/Synthetics.

For browser tests, the value of the user-agent header varies depending on the browser and device executing the test. The user-agent value always ends with DatadogSynthetics to allow you to identify Synthetic tests.

sec-datadog

A sec-datadog header is added to all requests performed by Synthetic tests. The value notably includes the id of the test from which the request originated.

sec-datadog: Request sent by a Datadog Synthetics API Test (https://docs.datadoghq.com/synthetics/) - test_id: <SYNTHETIC_TEST_PUBLIC_ID>
sec-datadog: Request sent by a Datadog Synthetics Browser Test (https://docs.datadoghq.com/synthetics/) - test_id: <SYNTHETIC_TEST_PUBLIC_ID>

APM headers

A number of other APM specific headers such as x-datadog-origin: synthetics is also added to requests generated by Synthetic API and browser tests.

Customize requests

You can also leverage your API and browser test configuration Advanced options to add specific identifiers to your tests' requests. You can for instance add custom headers, cookies, or request bodies.

Browser variable

The browser variable is deprecated. Datadog recommends using the user-agent header instead.

When a Datadog robot is rendering your application, the window._DATADOG_SYNTHETICS_BROWSER variable is set to true. To remove the robot actions from your analytics data, wrap your analytics tool code with the following test:

if (window._DATADOG_SYNTHETICS_BROWSER === undefined) {
  initializeAnalytics()
}

Further Reading