Synthetics
Dash が新機能を発表!インシデントマネジメント、Continuous Profiler など多数の機能が追加されました! Dash イベントで発表された新機能!

Synthetics

Datadog Synthetics uses simulated user requests and browser rendering to help you ensure uptime, identify regional issues, and track your application performance. Datadog Synthetics tests come in two different flavors, API tests and browser tests. You can use Datadog’s API to manage both test types programmatically.

For more information about Synthetics, see the Synthetics overview.

Create a global variable

POST https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/variables

概要

Create a Synthetics global variable.

リクエスト

Body Data (required)

Details of the global variable to create.

Expand All

Field

種類

説明

description [required]

string

Description of the global variable.

id

string

Unique identifier of the global variable.

name [required]

string

Name of the global variable.

tags [required]

[string]

Tags of the global variable.

value [required]

Value of the global variable.

secure

boolean

Determines if the variable is secure.

value [required]

string

Value of the global variable.

{
  "description": "string",
  "name": "string",
  "tags": [],
  "value": {
    "secure": false,
    "value": "string"
  }
}

応答

OK

Synthetics global variable.

Expand All

Field

種類

説明

description [required]

string

Description of the global variable.

id

string

Unique identifier of the global variable.

name [required]

string

Name of the global variable.

tags [required]

[string]

Tags of the global variable.

value [required]

Value of the global variable.

secure

boolean

Determines if the variable is secure.

value [required]

string

Value of the global variable.

{
  "description": "string",
  "id": "string",
  "name": "string",
  "tags": [],
  "value": {
    "secure": false,
    "value": "string"
  }
}

Invalid request

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


                                        # Curl command
curl -X POST https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/variables \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \
-d @- << EOF
{
  "description": null,
  "name": null,
  "tags": null,
  "value": {
    "value": null
  }
}
EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    body := datadog.SyntheticsGlobalVariable{Description: "Description_example", Id: "Id_example", Name: "Name_example", Tags: []string{"Tags_example"), Value: datadog.SyntheticsGlobalVariableValue{Secure: false, Value: "Value_example"}} // SyntheticsGlobalVariable | Details of the global variable to create.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.CreateGlobalVariable(ctx, body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.CreateGlobalVariable``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `CreateGlobalVariable`: SyntheticsGlobalVariable
    fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.CreateGlobalVariable`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        SyntheticsGlobalVariable body = new SyntheticsGlobalVariable(); // SyntheticsGlobalVariable | Details of the global variable to create.
        try {
            SyntheticsGlobalVariable result = api.createGlobalVariable()
                .body(body)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#createGlobalVariable");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Create a test

POST https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests

概要

Create a Synthetic test.

リクエスト

Body Data (required)

Details of the test to create.

Expand All

Field

種類

説明

config

object

Configuration object for a Synthetic test.

assertions [required]

[object]

Array of assertions used for the test.

request [required]

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

variables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,text

locations

[string]

Array of locations used to run the test.

message

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (e.g. renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

enum

The frequency at which to run the Synthetic test (in seconds). Allowed enum values: 60,300,900,1800,3600,21600,43200,86400,604800

public_id

string

The test public ID.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

For browser test, the steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

number

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementContent,assertElementPresent,assertEmail,assertPageContains,assertPageLacks,click,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,selectOption,typeText,uploadFiles,wait

subtype

enum

The sub-type of the Synthetic API test, http, ssl, or tcp. Allowed enum values: http,ssl,tcp

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, either api or browser. Allowed enum values: api,browser

{
  "config": {
    "assertions": [
      []
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "string",
      "port": "integer",
      "query": {},
      "timeout": "number",
      "url": "string"
    },
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "",
        "pattern": "string",
        "type": "string"
      }
    ]
  },
  "locations": [],
  "message": "string",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [],
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "string",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "number",
      "type": "string"
    }
  ],
  "subtype": "string",
  "tags": [],
  "type": "string"
}

応答

OK - Returns the created test details.

Object containing details about your Synthetic test.

Expand All

Field

種類

説明

config

object

Configuration object for a Synthetic test.

assertions [required]

[object]

Array of assertions used for the test.

request [required]

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

variables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,text

locations

[string]

Array of locations used to run the test.

message

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (e.g. renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

enum

The frequency at which to run the Synthetic test (in seconds). Allowed enum values: 60,300,900,1800,3600,21600,43200,86400,604800

public_id

string

The test public ID.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

For browser test, the steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

number

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementContent,assertElementPresent,assertEmail,assertPageContains,assertPageLacks,click,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,selectOption,typeText,uploadFiles,wait

subtype

enum

The sub-type of the Synthetic API test, http, ssl, or tcp. Allowed enum values: http,ssl,tcp

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, either api or browser. Allowed enum values: api,browser

{
  "config": {
    "assertions": [
      []
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "string",
      "port": "integer",
      "query": {},
      "timeout": "number",
      "url": "string"
    },
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "",
        "pattern": "string",
        "type": "string"
      }
    ]
  },
  "locations": [],
  "message": "string",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [],
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "string",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "number",
      "type": "string"
    }
  ],
  "subtype": "string",
  "tags": [],
  "type": "string"
}

- JSON format is wrong - Creation failed

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Test quota is reached

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


                                        # Curl command
curl -X POST https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \
-d @- << EOF
{
  "config": {
    "assertions": [
      null
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      }
    },
    "variables": [
      {
        "name": "",
        "type": null
      }
    ]
  }
}
EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    body := datadog.SyntheticsTestDetails{Config: datadog.SyntheticsTestConfig{Assertions: []SyntheticsAssertion{datadog.SyntheticsAssertion{Operator: datadog.SyntheticsAssertionJSONPathOperator{}, Property: "Property_example", Target: datadog.SyntheticsAssertionJSONPathTarget_target{JsonPath: "JsonPath_example", Operator: "Operator_example", TargetValue: 123}, Type: datadog.SyntheticsAssertionType{}}), Request: datadog.SyntheticsTestRequest{BasicAuth: datadog.SyntheticsBasicAuth{Password: "Password_example", Username: "Username_example"}, Body: "Body_example", Headers: map[string]string{ "Key" = "Value" }, Host: "Host_example", Method: datadog.HTTPMethod{}, Port: int64(123), Query: 123, Timeout: 123, Url: "Url_example"}, Variables: []SyntheticsBrowserVariable{datadog.SyntheticsBrowserVariable{Example: "Example_example", Id: "Id_example", Name: "Name_example", Pattern: "Pattern_example", Type: datadog.SyntheticsBrowserVariableType{}})}, Locations: []string{"Locations_example"), Message: "Message_example", MonitorId: int64(123), Name: "Name_example", Options: datadog.SyntheticsTestOptions{AcceptSelfSigned: false, AllowInsecure: false, DeviceIds: []SyntheticsDeviceID{datadog.SyntheticsDeviceID{}), FollowRedirects: false, MinFailureDuration: int64(123), MinLocationFailed: int64(123), MonitorOptions: datadog.SyntheticsTestOptions_monitor_options{RenotifyInterval: int64(123)}, Retry: datadog.SyntheticsTestOptionsRetry{Count: int64(123), Interval: 123}, TickEvery: datadog.SyntheticsTickInterval{}}, PublicId: "PublicId_example", Status: datadog.SyntheticsTestPauseStatus{}, Steps: []SyntheticsStep{datadog.SyntheticsStep{AllowFailure: false, Name: "Name_example", Params: 123, Timeout: 123, Type: datadog.SyntheticsStepType{}}), Subtype: datadog.SyntheticsTestDetailsSubType{}, Tags: []string{"Tags_example"), Type: datadog.SyntheticsTestDetailsType{}} // SyntheticsTestDetails | Details of the test to create.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.CreateTest(ctx, body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.CreateTest``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `CreateTest`: SyntheticsTestDetails
    fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.CreateTest`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        SyntheticsTestDetails body = new SyntheticsTestDetails(); // SyntheticsTestDetails | Details of the test to create.
        try {
            SyntheticsTestDetails result = api.createTest()
                .body(body)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#createTest");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Delete a global variable

DELETE https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/variables/{variable_id}

概要

Delete a Synthetics global variable.

引数

パスパラメーター

名前

種類

説明

variable_id [required]

string

The ID of the global variable.

応答

OK

JSON format is wrong

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Not found

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


                                        # Path parameters
export variable_id="CHANGE_ME"
# Curl command curl -X DELETE https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/variables/${variable_id} \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    variableId := "variableId_example" // string | The ID of the global variable.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.DeleteGlobalVariable(ctx, variableId).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.DeleteGlobalVariable``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String variableId = "variableId_example"; // String | The ID of the global variable.
        try {
            api.deleteGlobalVariable(variableId)
                .execute();
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#deleteGlobalVariable");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Delete tests

POST https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/delete

概要

Delete multiple Synthetic tests by ID.

リクエスト

Body Data (required)

Public ID list of the Synthetic tests to be deleted.

Expand All

Field

種類

説明

public_ids

[string]

An array of Synthetic test IDs you want to delete.

{
  "public_ids": [
    []
  ]
}

応答

OK.

Response object for deleting Synthetic tests.

Expand All

Field

種類

説明

deleted_tests

[object]

Array of objects containing a deleted Synthetic test ID with the associated deletion timestamp.

deleted_at

date-time

Deletion timestamp of the Synthetic test ID.

public_id

string

The Synthetic test ID deleted.

{
  "deleted_tests": [
    {
      "deleted_at": "2019-09-19T10:00:00.000Z",
      "public_id": "string"
    }
  ]
}

- JSON format is wrong - Test cannot be deleted as it's used elsewhere (as a sub-test or in an uptime widget) - Some IDs are not owned by the user

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

- Tests to be deleted can't be found - Synthetics is not activated for the user

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


                                        # Curl command
curl -X POST https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/delete \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \
-d @- << EOF
{}
EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    body := datadog.SyntheticsDeleteTestsPayload{PublicIds: []string{"PublicIds_example")} // SyntheticsDeleteTestsPayload | Public ID list of the Synthetic tests to be deleted.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.DeleteTests(ctx, body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.DeleteTests``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `DeleteTests`: SyntheticsDeleteTestsResponse
    fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.DeleteTests`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        SyntheticsDeleteTestsPayload body = new SyntheticsDeleteTestsPayload(); // SyntheticsDeleteTestsPayload | Public ID list of the Synthetic tests to be deleted.
        try {
            SyntheticsDeleteTestsResponse result = api.deleteTests()
                .body(body)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#deleteTests");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

test_ids = ['<SYNTHETICS_TEST_PUBLIC_ID_1>','<SYNTHETICS_TEST_PUBLIC_ID_2>']

initialize(**options)

api.Synthetics.delete_test(id=test_ids)
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

test_ids = ['<SYNTHETICS_TEST_PUBLIC_ID_1>','<SYNTHETICS_TEST_PUBLIC_ID_2>']

dog.delete_synthetics_tests('test_ids' => test_ids)

Edit a global variable

PUT https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/variables/{variable_id}

概要

Edit a Synthetics global variable.

引数

パスパラメーター

名前

種類

説明

variable_id [required]

string

The ID of the global variable.

リクエスト

Body Data (required)

Details of the global variable to update.

Expand All

Field

種類

説明

description [required]

string

Description of the global variable.

id

string

Unique identifier of the global variable.

name [required]

string

Name of the global variable.

tags [required]

[string]

Tags of the global variable.

value [required]

Value of the global variable.

secure

boolean

Determines if the variable is secure.

value [required]

string

Value of the global variable.

{
  "description": "string",
  "name": "string",
  "tags": [],
  "value": {
    "secure": false,
    "value": "string"
  }
}

応答

OK

Synthetics global variable.

Expand All

Field

種類

説明

description [required]

string

Description of the global variable.

id

string

Unique identifier of the global variable.

name [required]

string

Name of the global variable.

tags [required]

[string]

Tags of the global variable.

value [required]

Value of the global variable.

secure

boolean

Determines if the variable is secure.

value [required]

string

Value of the global variable.

{
  "description": "string",
  "id": "string",
  "name": "string",
  "tags": [],
  "value": {
    "secure": false,
    "value": "string"
  }
}

Invalid request

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


                                        # Path parameters
export variable_id="CHANGE_ME"
# Curl command curl -X PUT https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/variables/${variable_id} \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \ -d @- << EOF { "description": null, "name": null, "tags": null, "value": { "value": null } } EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    variableId := "variableId_example" // string | The ID of the global variable.
    body := datadog.SyntheticsGlobalVariable{Description: "Description_example", Id: "Id_example", Name: "Name_example", Tags: []string{"Tags_example"), Value: datadog.SyntheticsGlobalVariableValue{Secure: false, Value: "Value_example"}} // SyntheticsGlobalVariable | Details of the global variable to update.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.EditGlobalVariable(ctx, variableId, body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.EditGlobalVariable``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `EditGlobalVariable`: SyntheticsGlobalVariable
    fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.EditGlobalVariable`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String variableId = "variableId_example"; // String | The ID of the global variable.
        SyntheticsGlobalVariable body = new SyntheticsGlobalVariable(); // SyntheticsGlobalVariable | Details of the global variable to update.
        try {
            SyntheticsGlobalVariable result = api.editGlobalVariable(variableId)
                .body(body)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#editGlobalVariable");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Edit a test

PUT https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/{public_id}

概要

Edit the configuration of a Synthetic test.

引数

パスパラメーター

名前

種類

説明

public_id [required]

string

The public ID of the test to get details from.

リクエスト

Body Data (required)

New test details to be saved.

Expand All

Field

種類

説明

config

object

Configuration object for a Synthetic test.

assertions [required]

[object]

Array of assertions used for the test.

request [required]

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

variables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,text

locations

[string]

Array of locations used to run the test.

message

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (e.g. renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

enum

The frequency at which to run the Synthetic test (in seconds). Allowed enum values: 60,300,900,1800,3600,21600,43200,86400,604800

public_id

string

The test public ID.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

For browser test, the steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

number

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementContent,assertElementPresent,assertEmail,assertPageContains,assertPageLacks,click,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,selectOption,typeText,uploadFiles,wait

subtype

enum

The sub-type of the Synthetic API test, http, ssl, or tcp. Allowed enum values: http,ssl,tcp

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, either api or browser. Allowed enum values: api,browser

{
  "config": {
    "assertions": [
      []
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "string",
      "port": "integer",
      "query": {},
      "timeout": "number",
      "url": "string"
    },
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "",
        "pattern": "string",
        "type": "string"
      }
    ]
  },
  "locations": [],
  "message": "string",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [],
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "string",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "number",
      "type": "string"
    }
  ],
  "subtype": "string",
  "tags": [],
  "type": "string"
}

応答

OK

Object containing details about your Synthetic test.

Expand All

Field

種類

説明

config

object

Configuration object for a Synthetic test.

assertions [required]

[object]

Array of assertions used for the test.

request [required]

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

variables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,text

locations

[string]

Array of locations used to run the test.

message

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (e.g. renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

enum

The frequency at which to run the Synthetic test (in seconds). Allowed enum values: 60,300,900,1800,3600,21600,43200,86400,604800

public_id

string

The test public ID.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

For browser test, the steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

number

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementContent,assertElementPresent,assertEmail,assertPageContains,assertPageLacks,click,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,selectOption,typeText,uploadFiles,wait

subtype

enum

The sub-type of the Synthetic API test, http, ssl, or tcp. Allowed enum values: http,ssl,tcp

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, either api or browser. Allowed enum values: api,browser

{
  "config": {
    "assertions": [
      []
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "string",
      "port": "integer",
      "query": {},
      "timeout": "number",
      "url": "string"
    },
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "",
        "pattern": "string",
        "type": "string"
      }
    ]
  },
  "locations": [],
  "message": "string",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [],
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "string",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "number",
      "type": "string"
    }
  ],
  "subtype": "string",
  "tags": [],
  "type": "string"
}

- JSON format is wrong - Updating sub-type is forbidden

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

- Synthetic is not activated for the user - Test is not owned by the user - Test can't be found

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


                                        # Path parameters
export public_id="CHANGE_ME"
# Curl command curl -X PUT https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/${public_id} \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \ -d @- << EOF { "config": { "assertions": [ null ], "request": { "basicAuth": { "password": "", "username": "" } }, "variables": [ { "name": "", "type": null } ] } } EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    publicId := "publicId_example" // string | The public ID of the test to get details from.
    body := datadog.SyntheticsTestDetails{Config: datadog.SyntheticsTestConfig{Assertions: []SyntheticsAssertion{datadog.SyntheticsAssertion{Operator: datadog.SyntheticsAssertionJSONPathOperator{}, Property: "Property_example", Target: datadog.SyntheticsAssertionJSONPathTarget_target{JsonPath: "JsonPath_example", Operator: "Operator_example", TargetValue: 123}, Type: datadog.SyntheticsAssertionType{}}), Request: datadog.SyntheticsTestRequest{BasicAuth: , Body: "Body_example", Headers: map[string]string{ "Key" = "Value" }, Host: "Host_example", Method: datadog.HTTPMethod{}, Port: int64(123), Query: 123, Timeout: 123, Url: "Url_example"}, Variables: []SyntheticsBrowserVariable{datadog.SyntheticsBrowserVariable{Example: "Example_example", Id: "Id_example", Name: "Name_example", Pattern: "Pattern_example", Type: datadog.SyntheticsBrowserVariableType{}})}, Locations: []string{"Locations_example"), Message: "Message_example", MonitorId: int64(123), Name: "Name_example", Options: datadog.SyntheticsTestOptions{AcceptSelfSigned: false, AllowInsecure: false, DeviceIds: []SyntheticsDeviceID{), FollowRedirects: false, MinFailureDuration: int64(123), MinLocationFailed: int64(123), MonitorOptions: datadog.SyntheticsTestOptions_monitor_options{RenotifyInterval: int64(123)}, Retry: , TickEvery: datadog.SyntheticsTickInterval{}}, PublicId: "PublicId_example", Status: datadog.SyntheticsTestPauseStatus{}, Steps: []SyntheticsStep{datadog.SyntheticsStep{AllowFailure: false, Name: "Name_example", Params: 123, Timeout: 123, Type: datadog.SyntheticsStepType{}}), Subtype: datadog.SyntheticsTestDetailsSubType{}, Tags: []string{"Tags_example"), Type: datadog.SyntheticsTestDetailsType{}} // SyntheticsTestDetails | New test details to be saved.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.UpdateTest(ctx, publicId, body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.UpdateTest``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `UpdateTest`: SyntheticsTestDetails
    fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.UpdateTest`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String publicId = "publicId_example"; // String | The public ID of the test to get details from.
        SyntheticsTestDetails body = new SyntheticsTestDetails(); // SyntheticsTestDetails | New test details to be saved.
        try {
            SyntheticsTestDetails result = api.updateTest(publicId)
                .body(body)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#updateTest");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Get a test configuration (API)

GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/{public_id}

概要

Get the detailed configuration associated with a Synthetics test.

引数

パスパラメーター

名前

種類

説明

public_id [required]

string

The public ID of the test to get details from.

応答

OK

Object containing details about your Synthetic test.

Expand All

Field

種類

説明

config

object

Configuration object for a Synthetic test.

assertions [required]

[object]

Array of assertions used for the test.

request [required]

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

variables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,text

locations

[string]

Array of locations used to run the test.

message

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (e.g. renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

enum

The frequency at which to run the Synthetic test (in seconds). Allowed enum values: 60,300,900,1800,3600,21600,43200,86400,604800

public_id

string

The test public ID.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

For browser test, the steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

number

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementContent,assertElementPresent,assertEmail,assertPageContains,assertPageLacks,click,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,selectOption,typeText,uploadFiles,wait

subtype

enum

The sub-type of the Synthetic API test, http, ssl, or tcp. Allowed enum values: http,ssl,tcp

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, either api or browser. Allowed enum values: api,browser

{
  "config": {
    "assertions": [
      []
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "string",
      "port": "integer",
      "query": {},
      "timeout": "number",
      "url": "string"
    },
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "",
        "pattern": "string",
        "type": "string"
      }
    ]
  },
  "locations": [],
  "message": "string",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [],
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "string",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "number",
      "type": "string"
    }
  ],
  "subtype": "string",
  "tags": [],
  "type": "string"
}

Forbidden

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

- Synthetic is not activated for the user - Test is not owned by the user

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


                                        # Path parameters
export public_id="CHANGE_ME"
# Curl command curl -X GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/${public_id} \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    publicId := "publicId_example" // string | The public ID of the test to get details from.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.GetTest(ctx, publicId).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.GetTest``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetTest`: SyntheticsTestDetails
    fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.GetTest`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String publicId = "publicId_example"; // String | The public ID of the test to get details from.
        try {
            SyntheticsTestDetails result = api.getTest(publicId)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#getTest");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

test_id = '<SYNTHETICS_TEST_PUBLIC_ID>'

initialize(**options)

api.Synthetics.get_test(id=test_id)
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

test_id = '<SYNTHETICS_TEST_PUBLIC_ID>'

dog = Dogapi::Client.new(api_key, app_key)

dog.get_synthetics_test('test_id'  => test_id)

Get a test configuration (browser)

GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/browser/{public_id}

概要

Get the detailed configuration (including steps) associated with a Synthetics browser test.

引数

パスパラメーター

名前

種類

説明

public_id [required]

string

The public ID of the test to get details from.

応答

OK

Object containing details about your Synthetic test.

Expand All

Field

種類

説明

config

object

Configuration object for a Synthetic test.

assertions [required]

[object]

Array of assertions used for the test.

request [required]

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

variables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,text

locations

[string]

Array of locations used to run the test.

message

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (e.g. renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

enum

The frequency at which to run the Synthetic test (in seconds). Allowed enum values: 60,300,900,1800,3600,21600,43200,86400,604800

public_id

string

The test public ID.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

For browser test, the steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

number

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementContent,assertElementPresent,assertEmail,assertPageContains,assertPageLacks,click,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,selectOption,typeText,uploadFiles,wait

subtype

enum

The sub-type of the Synthetic API test, http, ssl, or tcp. Allowed enum values: http,ssl,tcp

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, either api or browser. Allowed enum values: api,browser

{
  "config": {
    "assertions": [
      []
    ],
    "request": {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "headers": {
        "<any-key>": "string"
      },
      "host": "string",
      "method": "string",
      "port": "integer",
      "query": {},
      "timeout": "number",
      "url": "string"
    },
    "variables": [
      {
        "example": "string",
        "id": "string",
        "name": "",
        "pattern": "string",
        "type": "string"
      }
    ]
  },
  "locations": [],
  "message": "string",
  "monitor_id": "integer",
  "name": "string",
  "options": {
    "accept_self_signed": false,
    "allow_insecure": false,
    "device_ids": [],
    "follow_redirects": false,
    "min_failure_duration": "integer",
    "min_location_failed": "integer",
    "monitor_options": {
      "renotify_interval": "integer"
    },
    "retry": {
      "count": "integer",
      "interval": "number"
    },
    "tick_every": "integer"
  },
  "public_id": "string",
  "status": "string",
  "steps": [
    {
      "allowFailure": false,
      "name": "string",
      "params": {},
      "timeout": "number",
      "type": "string"
    }
  ],
  "subtype": "string",
  "tags": [],
  "type": "string"
}

Forbidden

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

- Synthetic is not activated for the user - Test is not owned by the user

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


                                        # Path parameters
export public_id="CHANGE_ME"
# Curl command curl -X GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/browser/${public_id} \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    publicId := "publicId_example" // string | The public ID of the test to get details from.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.GetBrowserTest(ctx, publicId).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.GetBrowserTest``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetBrowserTest`: SyntheticsTestDetails
    fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.GetBrowserTest`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String publicId = "publicId_example"; // String | The public ID of the test to get details from.
        try {
            SyntheticsTestDetails result = api.getBrowserTest(publicId)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#getBrowserTest");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Get a test result (API)

GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/{public_id}/results/{result_id}

概要

Get a specific full result from a given (API) Synthetic test.

引数

パスパラメーター

名前

種類

説明

public_id [required]

string

The public ID of the API test to which the target result belongs.

result_id [required]

string

The ID of the result to get.

応答

OK

Object returned describing a API test result.

Expand All

Field

種類

説明

check

object

Object describing the API test configuration.

config [required]

object

Configuration object for a Synthetic test.

assertions [required]

[object]

Array of assertions used for the test.

request [required]

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

variables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,text

check_time

double

When the API test was conducted.

check_version

int64

Version of the API test used.

probe_dc

string

Locations for which to query the API test results.

result

object

Object containing results for your Synthetic API test.

cert

object

Object describing the SSL certificate used for a Synthetic test.

cipher

string

Cipher used for the connection.

exponent

double

Exponent associated to the certificate.

extKeyUsage

[string]

Array of extensions and details used for the certificate.

fingerprint

string

MD5 digest of the DER-encoded Certificate information.

fingerprint256

string

SHA-1 digest of the DER-encoded Certificate information.

issuer

object

Object describing the issuer of a SSL certificate.

C

string

Country Name that issued the certificate.

CN

string

Common Name that issued certificate.

L

string

Locality that issued the certificate.

O

string

Organization that issued the certificate.

OU

string

Organizational Unit that issued the certificate.

ST

string

State Or Province Name that issued the certificate.

modulus

string

Modulus associated to the SSL certificate private key.

protocol

string

TLS protocol used for the test.

serialNumber

string

Serial Number assigned by Symantec to the SSL certificate.

subject

object

Object describing the SSL certificate used for the test.

C

string

Country Name associated with the certificate.

CN

string

Common Name that associated with the certificate.

L

string

Locality associated with the certificate.

O

string

Organization associated with the certificate.

OU

string

Organizational Unit associated with the certificate.

ST

string

State Or Province Name associated with the certificate.

altName

string

Subject Alternative Name associated with the certificate.

validFrom

date-time

Date from which the SSL certificate is valid.

validTo

date-time

Date until which the SSL certificate is valid.

errorCode

enum

Error code that can be returned by a Synthetic test. Allowed enum values: NO_ERROR,UNKNOWN,DNS,SSL,TIMEOUT,DENIED,INCORRECT_ASSERTION

errorMessage

string

The API test error message.

eventType

enum

Status of a Synthetic test. Allowed enum values: not_scheduled,scheduled,started,finished,finished_with_error

httpStatusCode

int64

The API test HTTP status code.

requestHeaders

object

Request header object used for the API test.

<any-key>

object

Requested request header.

responseBody

string

Response body returned for the API test.

responseHeaders

object

Response headers returned for the API test.

<any-key>

object

Returned request header.

responseSize

int64

Global size in byte of the API test response.

timings

object

Object containing all metrics and their values collected for a Synthetic API test. Learn more about those metrics in Synthetics documentation.

dns

double

The duration in millisecond of the DNS lookup.

download

double

The time in millisecond to download the response.

firstByte

double

The time in millisecond to first byte.

handshake

double

The duration in millisecond of the TLS handshake.

redirect

double

The time in millisecond spent during redirections.

ssl

double

The duration in millisecond of the TLS handshake.

tcp

double

Time in millisecond to establish the TCP connection.

total

double

The overall time in millisecond the request took to be processed.

wait

double

Time spent in millisecond waiting for a response.

result_id

string

ID of the API test result.

status

enum

The status of your Synthetic monitor.

  • O for not triggered
  • 1 for triggered
  • 2 for no data Allowed enum values: 0,1,2
{
  "check": {
    "config": {
      "assertions": [
        []
      ],
      "request": {
        "basicAuth": {
          "password": "",
          "username": ""
        },
        "body": "string",
        "headers": {
          "<any-key>": "string"
        },
        "host": "string",
        "method": "string",
        "port": "integer",
        "query": {},
        "timeout": "number",
        "url": "string"
      },
      "variables": [
        {
          "example": "string",
          "id": "string",
          "name": "",
          "pattern": "string",
          "type": "string"
        }
      ]
    }
  },
  "check_time": "number",
  "check_version": "integer",
  "probe_dc": "string",
  "result": {
    "cert": {
      "cipher": "string",
      "exponent": "number",
      "extKeyUsage": [],
      "fingerprint": "string",
      "fingerprint256": "string",
      "issuer": {
        "C": "string",
        "CN": "string",
        "L": "string",
        "O": "string",
        "OU": "string",
        "ST": "string"
      },
      "modulus": "string",
      "protocol": "string",
      "serialNumber": "string",
      "subject": {
        "C": "string",
        "CN": "string",
        "L": "string",
        "O": "string",
        "OU": "string",
        "ST": "string",
        "altName": "string"
      },
      "validFrom": "2019-09-19T10:00:00.000Z",
      "validTo": "2019-09-19T10:00:00.000Z"
    },
    "errorCode": "string",
    "errorMessage": "string",
    "eventType": "string",
    "httpStatusCode": "integer",
    "requestHeaders": {
      "<any-key>": {}
    },
    "responseBody": "string",
    "responseHeaders": {
      "<any-key>": {}
    },
    "responseSize": "integer",
    "timings": {
      "dns": "number",
      "download": "number",
      "firstByte": "number",
      "handshake": "number",
      "redirect": "number",
      "ssl": "number",
      "tcp": "number",
      "total": "number",
      "wait": "number"
    }
  },
  "result_id": "string",
  "status": "integer"
}

Forbidden

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

- Synthetic is not activated for the user - Test or result is not owned by the user

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


                                        # Path parameters
export public_id="CHANGE_ME"
export result_id="CHANGE_ME"
# Curl command curl -X GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/${public_id}/results/${result_id} \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    publicId := "publicId_example" // string | The public ID of the API test to which the target result belongs.
    resultId := "resultId_example" // string | The ID of the result to get.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.GetAPITestResult(ctx, publicId, resultId).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.GetAPITestResult``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetAPITestResult`: SyntheticsAPITestResultFull
    fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.GetAPITestResult`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String publicId = "publicId_example"; // String | The public ID of the API test to which the target result belongs.
        String resultId = "resultId_example"; // String | The ID of the result to get.
        try {
            SyntheticsAPITestResultFull result = api.getAPITestResult(publicId, resultId)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#getAPITestResult");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

test_id = '<SYNTHETICS_TEST_PUBLIC_ID>'
result_id = '<TEST_RESULT_ID>'

initialize(**options)

api.Synthetics.get_result(id=test_id, result_id=result_id)
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

test_id = '<SYNTHETICS_TEST_PUBLIC_ID>'
result_id = '<TEST_RESULT_ID>'


dog = Dogapi::Client.new(api_key, app_key)

dog.get_synthetics_result('test_id'  => test_id , 'result_id'  => result_id)

Get a test result (browser)

GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/browser/{public_id}/results/{result_id}

概要

Get a specific full result from a given (browser) Synthetic test.

引数

パスパラメーター

名前

種類

説明

public_id [required]

string

The public ID of the browser test to which the target result belongs.

result_id [required]

string

The ID of the result to get.

応答

OK

Object returned describing a browser test result.

Expand All

Field

種類

説明

check

object

Object describing the browser test configuration.

config [required]

object

Configuration object for a Synthetic test.

assertions [required]

[object]

Array of assertions used for the test.

request [required]

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

variables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,text

check_time

double

When the browser test was conducted.

check_version

int64

Version of the browser test used.

probe_dc

string

Location from which the browser test was performed.

result

object

Object containing results for your Synthetic browser test.

browserType

string

Type of browser device used for the browser test.

browserVersion

string

Browser version used for the browser test.

device

object

Object describing the device used to perform the Synthetic test.

height [required]

int64

Screen height of the device.

id [required]

enum

The device ID. Allowed enum values: laptop_large,tablet,mobile_small,chrome.laptop_large,chrome.tablet,chrome.mobile_small,firefox.laptop_large,firefox.tablet,firefox.mobile_small

isMobile

boolean

Whether or not the device is a mobile.

name [required]

string

The device name.

width [required]

int64

Screen width of the device.

duration

double

Global duration in second of the browser test.

error

string

Error returned for the browser test.

passed

boolean

Whether or not the browser test was conducted.

receivedEmailCount

int64

The amount of email received during the browser test.

startUrl

string

Starting URL for the browser test.

stepDetails

[object]

Array containing the different browser test steps.

browserErrors

[object]

Array of errors collected for a browser test.

description [required]

string

Description of the error.

name [required]

string

Name of the error.

statusCode

int64

Status Code of the error.

type [required]

enum

Error type returned by a browser test. Allowed enum values: network,js

checkType

enum

Type of assertion to apply in an API test. Allowed enum values: equals,notEquals,contains,notContains,startsWith,notStartsWith,greater,lower,greaterEquals,lowerEquals,matchRegex

description

string

Description of the test.

duration

double

Total duration in millisecond of the test.

error

string

Error returned by the test.

playingTab

enum

Navigate between different tabs for your browser test. Allowed enum values: -1,0,1,2,3

resources

[object]

Array of resources collected by the test.

duration

double

Number of time the resource was collected.

method

string

HTTP method associated to the resource.

size

int64

Size of the resource in bytes.

status

int64

Status Code of the resource.

timestamp

double

Timestamp of the resource collection.

traceId

string

Trace ID associated with the resource if any.

type [required]

enum

Document type to apply an assertion against. Allowed enum values: document,stylesheet,fetch,image,script,xhr,other

url

string

URL of the resource.

screenshotBucketKey

boolean

Whether or not screenshots where collected by the test.

skipped

boolean

Whether or not to skip this step.

snapshotBucketKey

boolean

Whether or not snapshots where collected by the test.

stepId

int64

The step ID.

subTestStepDetails

[object]

If this steps include a sub-test. Subtests documentation.

timeToInteractive

double

Time before starting the step.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementContent,assertElementPresent,assertEmail,assertPageContains,assertPageLacks,click,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,selectOption,typeText,uploadFiles,wait

url

string

URL to perform the step against.

value

object

Value for the step.

warnings

[object]

Warning collected that didn't failed the step.

message [required]

string

Message for the warning.

type [required]

enum

User locator used. Allowed enum values: user_locator

thumbnailsBucketKey

boolean

Whether or not a thumbnail is associated with the browser test.

timeToInteractive

double

Time in second to wait before the browser test starts after reaching the start URL.

result_id

string

ID of the browser test result.

status

enum

The status of your Synthetic monitor.

  • O for not triggered
  • 1 for triggered
  • 2 for no data Allowed enum values: 0,1,2
{
  "check": {
    "config": {
      "assertions": [
        []
      ],
      "request": {
        "basicAuth": {
          "password": "",
          "username": ""
        },
        "body": "string",
        "headers": {
          "<any-key>": "string"
        },
        "host": "string",
        "method": "string",
        "port": "integer",
        "query": {},
        "timeout": "number",
        "url": "string"
      },
      "variables": [
        {
          "example": "string",
          "id": "string",
          "name": "",
          "pattern": "string",
          "type": "string"
        }
      ]
    }
  },
  "check_time": "number",
  "check_version": "integer",
  "probe_dc": "string",
  "result": {
    "browserType": "string",
    "browserVersion": "string",
    "device": {
      "height": 0,
      "id": "string",
      "isMobile": false,
      "name": "",
      "width": 0
    },
    "duration": "number",
    "error": "string",
    "passed": false,
    "receivedEmailCount": "integer",
    "startUrl": "string",
    "stepDetails": [
      {
        "browserErrors": [
          {
            "description": "",
            "name": "",
            "statusCode": "integer",
            "type": "string"
          }
        ],
        "checkType": "string",
        "description": "string",
        "duration": "number",
        "error": "string",
        "playingTab": "integer",
        "resources": [
          {
            "duration": "number",
            "method": "string",
            "size": "integer",
            "status": "integer",
            "timestamp": "number",
            "traceId": "string",
            "type": "string",
            "url": "string"
          }
        ],
        "screenshotBucketKey": false,
        "skipped": false,
        "snapshotBucketKey": false,
        "stepId": "integer",
        "subTestStepDetails": [],
        "timeToInteractive": "number",
        "type": "string",
        "url": "string",
        "value": {},
        "warnings": [
          {
            "message": "",
            "type": "string"
          }
        ]
      }
    ],
    "thumbnailsBucketKey": false,
    "timeToInteractive": "number"
  },
  "result_id": "string",
  "status": "integer"
}

Forbidden

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

- Synthetic is not activated for the user - Test or result is not owned by the user

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


                                        # Path parameters
export public_id="CHANGE_ME"
export result_id="CHANGE_ME"
# Curl command curl -X GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/browser/${public_id}/results/${result_id} \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    publicId := "publicId_example" // string | The public ID of the browser test to which the target result belongs.
    resultId := "resultId_example" // string | The ID of the result to get.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.GetBrowserTestResult(ctx, publicId, resultId).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.GetBrowserTestResult``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetBrowserTestResult`: SyntheticsBrowserTestResultFull
    fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.GetBrowserTestResult`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String publicId = "publicId_example"; // String | The public ID of the browser test to which the target result belongs.
        String resultId = "resultId_example"; // String | The ID of the result to get.
        try {
            SyntheticsBrowserTestResultFull result = api.getBrowserTestResult(publicId, resultId)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#getBrowserTestResult");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Get all locations (public and private)

GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/locations

概要

Get the list of public and private locations available for Synthetics tests. No arguments required.

応答

OK

List of Synthetics locations.

Expand All

Field

種類

説明

locations

[object]

List of Synthetics locations.

id

string

Unique identifier of the location.

name

string

Name of the location.

{
  "locations": [
    {
      "id": "string",
      "name": "string"
    }
  ]
}

コード例


                                        # Curl command
curl -X GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/locations \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )


    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.ListLocations(ctx).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.ListLocations``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `ListLocations`: SyntheticsLocations
    fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.ListLocations`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        try {
            SyntheticsLocations result = api.listLocations()
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#listLocations");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Get the list of all tests

GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests

概要

Get the list of all Synthetic tests.

応答

OK - Returns the list of all Synthetic tests.

Object containing an array of Synthetic tests configuration.

Expand All

Field

種類

説明

tests

[object]

Array of Synthetic tests configuration.

config

object

Configuration object for a Synthetic test.

assertions [required]

[object]

Array of assertions used for the test.

request [required]

object

Object describing the Synthetic test request.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

host

string

Host name to perform the test with.

method

enum

The HTTP method. Allowed enum values: GET,POST,PATCH,PUT,DELETE,HEAD,OPTIONS

port

int64

Port to use when performing the test.

query

object

Query to use for the test.

timeout

double

Timeout in seconds for the test.

url

string

URL to perform the test with.

variables

[object]

Array of variables used for the test.

example

string

Example for the variable.

id

string

ID for the variable.

name [required]

string

Name of the variable.

pattern

string

Pattern of the variable.

type [required]

enum

Type of browser test variable. Allowed enum values: element,email,global,text

locations

[string]

Array of locations used to run the test.

message

string

Notification message associated with the test.

monitor_id

int64

The associated monitor ID.

name

string

Name of the test.

options

object

Object describing the extra options for a Synthetic test.

accept_self_signed

boolean

For SSL test, whether or not the test should allow self signed certificates.

allow_insecure

boolean

Allows loading insecure content for an HTTP request.

device_ids

[string]

For browser test, array with the different device IDs used to run the test.

follow_redirects

boolean

For API HTTP test, whether or not the test should follow redirects.

min_failure_duration

int64

Minimum amount of time in failure required to trigger an alert.

min_location_failed

int64

Minimum number of locations in failure required to trigger an alert.

monitor_options

object

Object containing the options for a Synthetic test as a monitor (e.g. renotification).

renotify_interval

int64

Time interval before renotifying if the test is still failing (in minutes).

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

tick_every

enum

The frequency at which to run the Synthetic test (in seconds). Allowed enum values: 60,300,900,1800,3600,21600,43200,86400,604800

public_id

string

The test public ID.

status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

steps

[object]

For browser test, the steps of the test.

allowFailure

boolean

A boolean set to allow this step to fail.

name

string

The name of the step.

params

object

The parameters of the step.

timeout

number

The time before declaring a step failed.

type

enum

Step type used in your Synthetic test. Allowed enum values: assertCurrentUrl,assertElementContent,assertElementPresent,assertEmail,assertPageContains,assertPageLacks,click,extractVariable,goToEmailLink,goToUrl,goToUrlAndMeasureTti,hover,playSubTest,pressKey,refresh,selectOption,typeText,uploadFiles,wait

subtype

enum

The sub-type of the Synthetic API test, http, ssl, or tcp. Allowed enum values: http,ssl,tcp

tags

[string]

Array of tags attached to the test.

type

enum

Type of the Synthetic test, either api or browser. Allowed enum values: api,browser

{
  "tests": [
    {
      "config": {
        "assertions": [
          []
        ],
        "request": {
          "basicAuth": {
            "password": "",
            "username": ""
          },
          "body": "string",
          "headers": {
            "<any-key>": "string"
          },
          "host": "string",
          "method": "string",
          "port": "integer",
          "query": {},
          "timeout": "number",
          "url": "string"
        },
        "variables": [
          {
            "example": "string",
            "id": "string",
            "name": "",
            "pattern": "string",
            "type": "string"
          }
        ]
      },
      "locations": [],
      "message": "string",
      "monitor_id": "integer",
      "name": "string",
      "options": {
        "accept_self_signed": false,
        "allow_insecure": false,
        "device_ids": [],
        "follow_redirects": false,
        "min_failure_duration": "integer",
        "min_location_failed": "integer",
        "monitor_options": {
          "renotify_interval": "integer"
        },
        "retry": {
          "count": "integer",
          "interval": "number"
        },
        "tick_every": "integer"
      },
      "public_id": "string",
      "status": "string",
      "steps": [
        {
          "allowFailure": false,
          "name": "string",
          "params": {},
          "timeout": "number",
          "type": "string"
        }
      ],
      "subtype": "string",
      "tags": [],
      "type": "string"
    }
  ]
}

Forbidden

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Synthetics is not activated for the user.

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


                                        # Curl command
curl -X GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )


    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.ListTests(ctx).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.ListTests``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `ListTests`: SyntheticsListTestsResponse
    fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.ListTests`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        try {
            SyntheticsListTestsResponse result = api.listTests()
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#listTests");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

initialize(**options)

api.Synthetics.get_all_tests()
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

dog = Dogapi::Client.new(api_key, app_key)

dog.get_all_synthetics_tests()

Get the test's latest results summaries (API)

GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/{public_id}/results

概要

Get the last 50 test results summaries for a given Synthetics API test.

引数

パスパラメーター

名前

種類

説明

public_id [required]

string

The public ID of the test for which to search results for.

クエリ文字列

名前

種類

説明

from_ts

integer

Timestamp from which to start querying results.

to_ts

integer

Timestamp up to which to query results.

probe_dc

array

Locations for which to query results.

応答

OK

Object with the latest Synthetic API test run.

Expand All

Field

種類

説明

last_timestamp_fetched

int64

Timestamp of the latest API test run.

results

[object]

Result of the latest API test run.

check_time

double

Last time the API test was performed.

probe_dc

string

Location from which the API test was performed.

result

object

Result of the last API test run.

timings

object

Object containing all metrics and their values collected for a Synthetic API test. Learn more about those metrics in Synthetics documentation.

dns

double

The duration in millisecond of the DNS lookup.

download

double

The time in millisecond to download the response.

firstByte

double

The time in millisecond to first byte.

handshake

double

The duration in millisecond of the TLS handshake.

redirect

double

The time in millisecond spent during redirections.

ssl

double

The duration in millisecond of the TLS handshake.

tcp

double

Time in millisecond to establish the TCP connection.

total

double

The overall time in millisecond the request took to be processed.

wait

double

Time spent in millisecond waiting for a response.

result_id

string

ID of the API test result.

status

enum

The status of your Synthetic monitor.

  • O for not triggered
  • 1 for triggered
  • 2 for no data Allowed enum values: 0,1,2
{
  "last_timestamp_fetched": "integer",
  "results": [
    {
      "check_time": "number",
      "probe_dc": "string",
      "result": {
        "timings": {
          "dns": "number",
          "download": "number",
          "firstByte": "number",
          "handshake": "number",
          "redirect": "number",
          "ssl": "number",
          "tcp": "number",
          "total": "number",
          "wait": "number"
        }
      },
      "result_id": "string",
      "status": "integer"
    }
  ]
}

Forbidden

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

- Synthetic is not activated for the user - Test is not owned by the user

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


                                        # Path parameters
export public_id="CHANGE_ME"
# Curl command curl -X GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/${public_id}/results \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    publicId := "publicId_example" // string | The public ID of the test for which to search results for.
    fromTs := 987 // int64 | Timestamp from which to start querying results. (optional)
    toTs := 987 // int64 | Timestamp up to which to query results. (optional)
    probeDc := []string{"Inner_example"} // []string | Locations for which to query results. (optional)

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.GetAPITestLatestResults(ctx, publicId).FromTs(fromTs).ToTs(toTs).ProbeDc(probeDc).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.GetAPITestLatestResults``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetAPITestLatestResults`: SyntheticsGetAPITestLatestResultsResponse
    fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.GetAPITestLatestResults`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String publicId = "publicId_example"; // String | The public ID of the test for which to search results for.
        Long fromTs = 56L; // Long | Timestamp from which to start querying results.
        Long toTs = 56L; // Long | Timestamp up to which to query results.
        List<String> probeDc = Arrays.asList(); // List<String> | Locations for which to query results.
        try {
            SyntheticsGetAPITestLatestResultsResponse result = api.getAPITestLatestResults(publicId)
                .fromTs(fromTs)
                .toTs(toTs)
                .probeDc(probeDc)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#getAPITestLatestResults");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
from datadog import initialize, api

options = {
    'api_key': '<DATADOG_API_KEY>',
    'app_key': '<DATADOG_APPLICATION_KEY>'
}

test_id = '<SYNTHETICS_TEST_PUBLIC_ID>'

initialize(**options)

api.Synthetics.get_results(id=test_id)
require 'dogapi'

api_key = '<DATADOG_API_KEY>'
app_key = '<DATADOG_APPLICATION_KEY>'

test_id = '<SYNTHETICS_TEST_PUBLIC_ID>'

dog = Dogapi::Client.new(api_key, app_key)

dog.get_synthetics_results('test_id'  => test_id)

Get the test's latest results summaries (browser)

GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/browser/{public_id}/results

概要

Get the last 50 test results summaries for a given Synthetics Browser test.

引数

パスパラメーター

名前

種類

説明

public_id [required]

string

The public ID of the browser test for which to search results for.

クエリ文字列

名前

種類

説明

from_ts

integer

Timestamp from which to start querying results.

to_ts

integer

Timestamp up to which to query results.

probe_dc

array

Locations for which to query results.

応答

OK

Object with the latest Synthetic browser test run.

Expand All

Field

種類

説明

last_timestamp_fetched

int64

Timestamp of the latest browser test run.

results

[object]

Result of the latest browser test run.

check_time

double

Last time the browser test was performed.

probe_dc

string

Location from which the Browser test was performed.

result

object

Object with the result of the last browser test run.

device

object

Object describing the device used to perform the Synthetic test.

height [required]

int64

Screen height of the device.

id [required]

enum

The device ID. Allowed enum values: laptop_large,tablet,mobile_small,chrome.laptop_large,chrome.tablet,chrome.mobile_small,firefox.laptop_large,firefox.tablet,firefox.mobile_small

isMobile

boolean

Whether or not the device is a mobile.

name [required]

string

The device name.

width [required]

int64

Screen width of the device.

duration

double

Length in second of the browser test run.

errorCount

int64

Amount of errors collected for a single browser test run.

stepCountCompleted

int64

Amount of browser test steps completed before failing.

stepCountTotal

int64

Total amount of browser test steps.

result_id

string

ID of the browser test result.

status

enum

The status of your Synthetic monitor.

  • O for not triggered
  • 1 for triggered
  • 2 for no data Allowed enum values: 0,1,2
{
  "last_timestamp_fetched": "integer",
  "results": [
    {
      "check_time": "number",
      "probe_dc": "string",
      "result": {
        "device": {
          "height": 0,
          "id": "string",
          "isMobile": false,
          "name": "",
          "width": 0
        },
        "duration": "number",
        "errorCount": "integer",
        "stepCountCompleted": "integer",
        "stepCountTotal": "integer"
      },
      "result_id": "string",
      "status": "integer"
    }
  ]
}

forbidden

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

- Synthetic is not activated for the user - Test is not owned by the user

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


                                        # Path parameters
export public_id="CHANGE_ME"
# Curl command curl -X GET https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/browser/${public_id}/results \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    publicId := "publicId_example" // string | The public ID of the browser test for which to search results for.
    fromTs := 987 // int64 | Timestamp from which to start querying results. (optional)
    toTs := 987 // int64 | Timestamp up to which to query results. (optional)
    probeDc := []string{"Inner_example"} // []string | Locations for which to query results. (optional)

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.GetBrowserTestLatestResults(ctx, publicId).FromTs(fromTs).ToTs(toTs).ProbeDc(probeDc).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.GetBrowserTestLatestResults``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetBrowserTestLatestResults`: SyntheticsGetBrowserTestLatestResultsResponse
    fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.GetBrowserTestLatestResults`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String publicId = "publicId_example"; // String | The public ID of the browser test for which to search results for.
        Long fromTs = 56L; // Long | Timestamp from which to start querying results.
        Long toTs = 56L; // Long | Timestamp up to which to query results.
        List<String> probeDc = Arrays.asList(); // List<String> | Locations for which to query results.
        try {
            SyntheticsGetBrowserTestLatestResultsResponse result = api.getBrowserTestLatestResults(publicId)
                .fromTs(fromTs)
                .toTs(toTs)
                .probeDc(probeDc)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#getBrowserTestLatestResults");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Pause or start a test

PUT https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/{public_id}/status

概要

Pause or start a Synthetics test by changing the status.

引数

パスパラメーター

名前

種類

説明

public_id [required]

string

The public ID of the Synthetic test to update.

リクエスト

Body Data (required)

Status to set the given Synthetic test to.

Expand All

Field

種類

説明

new_status

enum

Define whether you want to start (live) or pause (paused) a Synthetic test. Allowed enum values: live,paused

{
  "new_status": "string"
}

応答

OK - Returns a boolean indicating if the update was successful.

Expand All

Field

種類

説明

No response body

{}

JSON format is wrong.

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

- Synthetic is not activated for the user - Test is not owned by the user

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


                                        # Path parameters
export public_id="CHANGE_ME"
# Curl command curl -X PUT https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/${public_id}/status \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \ -d @- << EOF {} EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    publicId := "publicId_example" // string | The public ID of the Synthetic test to update.
    body := datadog.SyntheticsUpdateTestPauseStatusPayload{NewStatus: } // SyntheticsUpdateTestPauseStatusPayload | Status to set the given Synthetic test to.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.UpdateTestPauseStatus(ctx, publicId, body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.UpdateTestPauseStatus``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `UpdateTestPauseStatus`: bool
    fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.UpdateTestPauseStatus`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        String publicId = "publicId_example"; // String | The public ID of the Synthetic test to update.
        SyntheticsUpdateTestPauseStatusPayload body = new SyntheticsUpdateTestPauseStatusPayload(); // SyntheticsUpdateTestPauseStatusPayload | Status to set the given Synthetic test to.
        try {
            Boolean result = api.updateTestPauseStatus(publicId)
                .body(body)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#updateTestPauseStatus");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Trigger some Synthetics tests for CI

POST https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/trigger/ci

概要

Trigger a set of Synthetics tests for continuous integration

リクエスト

Body Data (required)

Details of the test to trigger.

Expand All

Field

種類

説明

tests

[]

Individual synthetics test.

allowInsecureCertificates

boolean

Disable certificate checks in API tests.

basicAuth

object

Object to handle basic authentication when performing the test.

password [required]

string

Password to use for the basic authentication.

username [required]

string

Username to use for the basic authentication.

body

string

Body to include in the test.

bodyType

string

Type of the data sent in a synthetics API test.

cookies

string

Cookies for the request.

deviceIds

[string]

For browser test, array with the different device IDs used to run the test.

followRedirects

boolean

For API HTTP test, whether or not the test should follow redirects.

headers

object

Headers to include when performing the test.

<any-key>

string

A single Header.

locations

[string]

Array of locations used to run the test.

metadata

object

Metadata for the Synthetics tests run

ci

object

pipeline

string

provider

string

git

object

branch

string

commit_sha

string

public_id [required]

string

The public ID of the Synthetics test to trigger.

retry

object

Object describing the retry strategy to apply to a Synthetic test.

count

int64

Number of times a test needs to be retried before marking a location as failed. Defaults to 0.

interval

double

Time interval between retries (in milliseconds). Defaults to 300ms.

startUrl

string

Starting URL for the browser test.

variables

object

Variables to replace in the test.

<any-key>

string

A single variable.

{
  "tests": [
    {
      "allowInsecureCertificates": false,
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "body": "string",
      "bodyType": "string",
      "cookies": "string",
      "deviceIds": [],
      "followRedirects": false,
      "headers": {
        "<any-key>": "string"
      },
      "locations": [],
      "metadata": {
        "ci": {
          "pipeline": "string",
          "provider": "string"
        },
        "git": {
          "branch": "string",
          "commit_sha": "string"
        }
      },
      "public_id": "string",
      "retry": {
        "count": "integer",
        "interval": "number"
      },
      "startUrl": "string",
      "variables": {
        "<any-key>": "string"
      }
    }
  ]
}

応答

OK

Object containing information about the tests triggered.

Expand All

Field

種類

説明

locations

[object]

List of Synthetics locations.

id

number

Unique identifier of the location.

name

string

Name of the location.

results

[object]

Information about the tests runs.

device

enum

The device ID. Allowed enum values: laptop_large,tablet,mobile_small,chrome.laptop_large,chrome.tablet,chrome.mobile_small,firefox.laptop_large,firefox.tablet,firefox.mobile_small

location

number

The location ID of the test run.

public_id

string

The public ID of the Synthetics test.

result_id

string

ID of the result.

triggered_check_ids

[string]

The public IDs of the Synthetics test triggered.

{
  "locations": [
    {
      "id": "number",
      "name": "string"
    }
  ],
  "results": [
    {
      "device": "string",
      "location": "number",
      "public_id": "string",
      "result_id": "string"
    }
  ],
  "triggered_check_ids": []
}

JSON format is wrong

Error response object.

Expand All

Field

種類

説明

errors [required]

[string]

Array of errors returned by the API.

{
  "errors": [
    "Bad Request"
  ]
}

コード例


                                        # Curl command
curl -X POST https://api.datadoghq.comhttps://api.datadoghq.eu/api/v1/synthetics/tests/trigger/ci \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \
-d @- << EOF
{
  "tests": [
    {
      "basicAuth": {
        "password": "",
        "username": ""
      },
      "public_id": null
    }
  ]
}
EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    body := datadog.SyntheticsCITestBody{Tests: []SyntheticsCITest{datadog.SyntheticsCITest{AllowInsecureCertificates: false, BasicAuth: datadog.SyntheticsBasicAuth{Password: "Password_example", Username: "Username_example"}, Body: "Body_example", BodyType: "BodyType_example", Cookies: "Cookies_example", DeviceIds: []SyntheticsDeviceID{datadog.SyntheticsDeviceID{}), FollowRedirects: false, Headers: map[string]string{ "Key" = "Value" }, Locations: []string{"Locations_example"), Metadata: datadog.SyntheticsCITest_metadata{Ci: datadog.SyntheticsCITest_metadata_ci{Pipeline: "Pipeline_example", Provider: "Provider_example"}, Git: datadog.SyntheticsCITest_metadata_git{Branch: "Branch_example", CommitSha: "CommitSha_example"}}, PublicId: "PublicId_example", Retry: datadog.SyntheticsTestOptionsRetry{Count: int64(123), Interval: 123}, StartUrl: "StartUrl_example", Variables: map[string]string{ "Key" = "Value" }})} // SyntheticsCITestBody | Details of the test to trigger.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.SyntheticsApi.TriggerCITests(ctx, body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.TriggerCITests``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `TriggerCITests`: SyntheticsTriggerCITestsResponse
    fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.TriggerCITests`: %v\n", resp)
}
// Import classes:
import com.datadog.api.v1.client.ApiClient;
import com.datadog.api.v1.client.ApiException;
import com.datadog.api.v1.client.Configuration;
import com.datadog.api.v1.client.auth.*;
import com.datadog.api.v1.client.model.*;
import com.datadog.api.v1.client.api.SyntheticsApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
        SyntheticsCITestBody body = new SyntheticsCITestBody(); // SyntheticsCITestBody | Details of the test to trigger.
        try {
            SyntheticsTriggerCITestsResponse result = api.triggerCITests()
                .body(body)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling SyntheticsApi#triggerCITests");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}