Créer un test Network Path
https://api.datadoghq.com/api/v2/synthetics/tests/networkhttps://api.us3.datadoghq.com/api/v2/synthetics/tests/networkhttps://api.us5.datadoghq.com/api/v2/synthetics/tests/networkhttps://api.datadoghq.eu/api/v2/synthetics/tests/networkhttps://api.ap1.datadoghq.com/api/v2/synthetics/tests/networkhttps://api.ap2.datadoghq.com/api/v2/synthetics/tests/networkhttps://api.uk1.datadoghq.com/api/v2/synthetics/tests/networkhttps://api.ddog-gov.com/api/v2/synthetics/tests/networkhttps://api.us2.ddog-gov.com/api/v2/synthetics/tests/networkPrésentation
OAuth apps require the synthetics_write authorization scope to access this endpoint.
Requête
Body Data (required)
data [required]Requête de test Network Path.
attributes [required]Object containing details about a Network Path test.
config [required]Configuration object for a Network Path test.
assertionsArray of assertions used for the test.
<type=latency>Network latency assertion for a Network Path test.
operator [required]Assertion operator to apply.
is, isNot, lessThan, lessThanOrEqual, moreThan, moreThanOrEqualproperty [required]The associated assertion property.
avg, max, mintarget [required]Target value in milliseconds.
type [required]Type of the latency assertion.
latencylatency<type=multiNetworkHop>Multi-network hop assertion for a Network Path test.
operator [required]Assertion operator to apply.
is, isNot, lessThan, lessThanOrEqual, moreThan, moreThanOrEqualproperty [required]The associated assertion property.
avg, max, mintarget [required]Target value in number of hops.
type [required]Type of the multi-network hop assertion.
multiNetworkHopmultiNetworkHop<type=packetLossPercentage>Packet loss percentage assertion for a Network Path test.
operator [required]Assertion operator to apply.
is, isNot, lessThan, lessThanOrEqual, moreThan, moreThanOrEqualtarget [required]Target value as a percentage (0 to 1).
type [required]Type of the packet loss percentage assertion.
packetLossPercentagepacketLossPercentage<type=jitter>Jitter assertion for a Network Path test.
operator [required]Assertion operator to apply.
is, isNot, lessThan, lessThanOrEqual, moreThan, moreThanOrEqualtarget [required]Target value in milliseconds.
type [required]Type of the jitter assertion.
jitterjitterrequestObject describing the request for a Network Path test.
destination_serviceAn optional label displayed for the destination host in the Network Path visualization.
e2e_queries [required]The number of packets sent to probe the destination to measure packet loss, latency and jitter.
host [required]Host name to query.
max_ttl [required]The maximum time-to-live (max number of hops) used in outgoing probe packets.
portFor TCP or UDP tests, the port to use when performing the test. If not set on a UDP test, a random port is assigned, which may affect the results.
source_serviceAn optional label displayed for the source host in the Network Path visualization.
tcp_methodFor TCP tests, the TCP traceroute strategy.
prefer_sack, syn, sacktimeoutTimeout in seconds.
traceroute_queries [required]The number of traceroute path tracings.
locations [required]Array of locations used to run the test. Network Path tests can be run from managed locations to test public endpoints, or from a Datadog Agent to test private environments.
message [required]Notification message associated with the test.
name [required]Name of the test.
options [required]Object describing the extra options for a Synthetic test.
min_failure_durationMinimum amount of time in failure required to trigger an alert.
min_location_failedMinimum number of locations in failure required to trigger an alert.
monitor_nameThe monitor name is used for the alert title as well as for all monitor dashboard widgets and SLOs.
monitor_optionsObject containing the options for a Synthetic test as a monitor (for example, renotification).
escalation_messageMessage to include in the escalation notification.
notification_preset_nameThe name of the preset for the notification for the monitor.
show_all, hide_all, hide_query, hide_handles, hide_query_and_handles, show_only_snapshot, hide_handles_and_footerrenotify_intervalTime interval before renotifying if the test is still failing (in minutes).
renotify_occurrencesThe number of times to renotify if the test is still failing.
monitor_priorityInteger from 1 (high) to 5 (low) indicating alert severity.
restricted_rolesDEPRECATED A list of role identifiers that can be pulled from the Roles API, for restricting read and write access. This field is deprecated. Use the restriction policies API to manage permissions.
retryObject describing the retry strategy to apply to a Synthetic test.
countNumber of times a test needs to be retried before marking a location as failed. Defaults to 0.
intervalTime interval between retries (in milliseconds). Defaults to 300ms.
schedulingObject containing timeframes and timezone used for advanced scheduling.
timeframes [required]Array containing objects describing the scheduling pattern to apply to each day.
day [required]Number representing the day of the week.
from [required]The hour of the day on which scheduling starts.
to [required]The hour of the day on which scheduling ends.
timezone [required]Timezone in which the timeframe is based.
tick_everyThe frequency at which to run the Synthetic test (in seconds).
statusDefine whether you want to start (live) or pause (paused) a
Synthetic test.
live, pausedsubtypeSubtype of the Synthetic Network Path test: tcp, udp, or icmp.
tcp, udp, icmptagsArray of tags attached to the test.
type [required]Type of the Synthetic test, network.
networknetworktype [required]Type of the Synthetic test, network.
networknetwork{
"data": {
"attributes": {
"config": {
"assertions": [
{
"operator": "lessThan",
"property": "avg",
"target": 500,
"type": "latency"
}
],
"request": {
"host": "example.com",
"port": 443,
"tcp_method": "prefer_sack",
"max_ttl": 30,
"e2e_queries": 50,
"traceroute_queries": 3
}
},
"locations": [
"aws:us-east-1",
"agent:my-agent-name"
],
"message": "Network Path test notification",
"name": "Example Network Path test",
"options": {
"tick_every": 60
},
"status": "live",
"subtype": "tcp",
"tags": [
"env:production"
],
"type": "network"
},
"type": "network"
}
}Réponse
OK
Network Path test response.
dataNetwork Path test response data.
attributesObject containing details about a Network Path test.
config [required]Configuration object for a Network Path test.
assertionsArray of assertions used for the test.
<type=latency>Network latency assertion for a Network Path test.
operator [required]Assertion operator to apply.
is, isNot, lessThan, lessThanOrEqual, moreThan, moreThanOrEqualproperty [required]The associated assertion property.
avg, max, mintarget [required]Target value in milliseconds.
type [required]Type of the latency assertion.
latencylatency<type=multiNetworkHop>Multi-network hop assertion for a Network Path test.
operator [required]Assertion operator to apply.
is, isNot, lessThan, lessThanOrEqual, moreThan, moreThanOrEqualproperty [required]The associated assertion property.
avg, max, mintarget [required]Target value in number of hops.
type [required]Type of the multi-network hop assertion.
multiNetworkHopmultiNetworkHop<type=packetLossPercentage>Packet loss percentage assertion for a Network Path test.
operator [required]Assertion operator to apply.
is, isNot, lessThan, lessThanOrEqual, moreThan, moreThanOrEqualtarget [required]Target value as a percentage (0 to 1).
type [required]Type of the packet loss percentage assertion.
packetLossPercentagepacketLossPercentage<type=jitter>Jitter assertion for a Network Path test.
operator [required]Assertion operator to apply.
is, isNot, lessThan, lessThanOrEqual, moreThan, moreThanOrEqualtarget [required]Target value in milliseconds.
type [required]Type of the jitter assertion.
jitterjitterrequestObject describing the request for a Network Path test.
destination_serviceAn optional label displayed for the destination host in the Network Path visualization.
e2e_queries [required]The number of packets sent to probe the destination to measure packet loss, latency and jitter.
host [required]Host name to query.
max_ttl [required]The maximum time-to-live (max number of hops) used in outgoing probe packets.
portFor TCP or UDP tests, the port to use when performing the test. If not set on a UDP test, a random port is assigned, which may affect the results.
source_serviceAn optional label displayed for the source host in the Network Path visualization.
tcp_methodFor TCP tests, the TCP traceroute strategy.
prefer_sack, syn, sacktimeoutTimeout in seconds.
traceroute_queries [required]The number of traceroute path tracings.
locations [required]Array of locations used to run the test. Network Path tests can be run from managed locations to test public endpoints, or from a Datadog Agent to test private environments.
message [required]Notification message associated with the test.
monitor_idThe associated monitor ID.
name [required]Name of the test.
options [required]Object describing the extra options for a Synthetic test.
min_failure_durationMinimum amount of time in failure required to trigger an alert.
min_location_failedMinimum number of locations in failure required to trigger an alert.
monitor_nameThe monitor name is used for the alert title as well as for all monitor dashboard widgets and SLOs.
monitor_optionsObject containing the options for a Synthetic test as a monitor (for example, renotification).
escalation_messageMessage to include in the escalation notification.
notification_preset_nameThe name of the preset for the notification for the monitor.
show_all, hide_all, hide_query, hide_handles, hide_query_and_handles, show_only_snapshot, hide_handles_and_footerrenotify_intervalTime interval before renotifying if the test is still failing (in minutes).
renotify_occurrencesThe number of times to renotify if the test is still failing.
monitor_priorityInteger from 1 (high) to 5 (low) indicating alert severity.
restricted_rolesDEPRECATED A list of role identifiers that can be pulled from the Roles API, for restricting read and write access. This field is deprecated. Use the restriction policies API to manage permissions.
retryObject describing the retry strategy to apply to a Synthetic test.
countNumber of times a test needs to be retried before marking a location as failed. Defaults to 0.
intervalTime interval between retries (in milliseconds). Defaults to 300ms.
schedulingObject containing timeframes and timezone used for advanced scheduling.
timeframes [required]Array containing objects describing the scheduling pattern to apply to each day.
day [required]Number representing the day of the week.
from [required]The hour of the day on which scheduling starts.
to [required]The hour of the day on which scheduling ends.
timezone [required]Timezone in which the timeframe is based.
tick_everyThe frequency at which to run the Synthetic test (in seconds).
public_idThe public ID for the test.
statusDefine whether you want to start (live) or pause (paused) a
Synthetic test.
live, pausedsubtypeSubtype of the Synthetic Network Path test: tcp, udp, or icmp.
tcp, udp, icmptagsArray of tags attached to the test.
type [required]Type of the Synthetic test, network.
networknetworkidThe public ID of the Network Path test.
typeType of response, network_test.
network_testnetwork_test{
"data": {
"attributes": {
"config": {
"assertions": [
{
"operator": "lessThan",
"property": "avg",
"target": 500,
"type": "latency"
}
],
"request": {
"destination_service": "string",
"e2e_queries": 50,
"host": "",
"max_ttl": 30,
"port": 443,
"source_service": "string",
"tcp_method": "prefer_sack",
"timeout": "integer",
"traceroute_queries": 3
}
},
"locations": [
"aws:us-east-1",
"agent:my-agent-name"
],
"message": "Network Path test notification",
"monitor_id": 12345678,
"name": "Example Network Path test",
"options": {
"min_failure_duration": "integer",
"min_location_failed": "integer",
"monitor_name": "string",
"monitor_options": {
"escalation_message": "string",
"notification_preset_name": "string",
"renotify_interval": "integer",
"renotify_occurrences": "integer"
},
"monitor_priority": "integer",
"restricted_roles": [
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
],
"retry": {
"count": "integer",
"interval": "number"
},
"scheduling": {
"timeframes": [
{
"day": 1,
"from": "07:00",
"to": "16:00"
}
],
"timezone": "America/New_York"
},
"tick_every": "integer"
},
"public_id": "abc-def-123",
"status": "live",
"subtype": "tcp",
"tags": [
"env:production"
],
"type": "network"
},
"id": "abc-def-123",
"type": "network_test"
}
}API error response.
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Exemple de code
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/synthetics/tests/network" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"config": {
"assertions": [
{
"operator": "lessThan",
"property": "avg",
"target": 500,
"type": "latency"
}
],
"request": {
"host": "example.com",
"port": 443,
"tcp_method": "prefer_sack",
"max_ttl": 30,
"e2e_queries": 50,
"traceroute_queries": 3
}
},
"locations": [
"aws:us-east-1",
"agent:my-agent-name"
],
"message": "Network Path test notification",
"name": "Example Network Path test",
"options": {
"tick_every": 60
},
"status": "live",
"subtype": "tcp",
"tags": [
"env:production"
],
"type": "network"
},
"type": "network"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/synthetics/tests/network" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"config": {
"assertions": [
{
"operator": "lessThan",
"property": "avg",
"target": 500,
"type": "latency"
}
],
"request": {
"host": "example.com",
"port": 443,
"tcp_method": "prefer_sack",
"max_ttl": 30,
"e2e_queries": 50,
"traceroute_queries": 3
}
},
"locations": [
"aws:us-east-1",
"agent:my-agent-name"
],
"message": "Network Path test notification",
"name": "Example Network Path test",
"options": {
"tick_every": 60
},
"status": "live",
"subtype": "tcp",
"tags": [
"env:production"
],
"type": "network"
},
"type": "network"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/synthetics/tests/network" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"config": {
"assertions": [
{
"operator": "lessThan",
"property": "avg",
"target": 500,
"type": "latency"
}
],
"request": {
"host": "example.com",
"port": 443,
"tcp_method": "prefer_sack",
"max_ttl": 30,
"e2e_queries": 50,
"traceroute_queries": 3
}
},
"locations": [
"aws:us-east-1",
"agent:my-agent-name"
],
"message": "Network Path test notification",
"name": "Example Network Path test",
"options": {
"tick_every": 60
},
"status": "live",
"subtype": "tcp",
"tags": [
"env:production"
],
"type": "network"
},
"type": "network"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/synthetics/tests/network" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"config": {
"assertions": [
{
"operator": "lessThan",
"property": "avg",
"target": 500,
"type": "latency"
}
],
"request": {
"host": "example.com",
"port": 443,
"tcp_method": "prefer_sack",
"max_ttl": 30,
"e2e_queries": 50,
"traceroute_queries": 3
}
},
"locations": [
"aws:us-east-1",
"agent:my-agent-name"
],
"message": "Network Path test notification",
"name": "Example Network Path test",
"options": {
"tick_every": 60
},
"status": "live",
"subtype": "tcp",
"tags": [
"env:production"
],
"type": "network"
},
"type": "network"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/synthetics/tests/network" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"config": {
"assertions": [
{
"operator": "lessThan",
"property": "avg",
"target": 500,
"type": "latency"
}
],
"request": {
"host": "example.com",
"port": 443,
"tcp_method": "prefer_sack",
"max_ttl": 30,
"e2e_queries": 50,
"traceroute_queries": 3
}
},
"locations": [
"aws:us-east-1",
"agent:my-agent-name"
],
"message": "Network Path test notification",
"name": "Example Network Path test",
"options": {
"tick_every": 60
},
"status": "live",
"subtype": "tcp",
"tags": [
"env:production"
],
"type": "network"
},
"type": "network"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/synthetics/tests/network" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"config": {
"assertions": [
{
"operator": "lessThan",
"property": "avg",
"target": 500,
"type": "latency"
}
],
"request": {
"host": "example.com",
"port": 443,
"tcp_method": "prefer_sack",
"max_ttl": 30,
"e2e_queries": 50,
"traceroute_queries": 3
}
},
"locations": [
"aws:us-east-1",
"agent:my-agent-name"
],
"message": "Network Path test notification",
"name": "Example Network Path test",
"options": {
"tick_every": 60
},
"status": "live",
"subtype": "tcp",
"tags": [
"env:production"
],
"type": "network"
},
"type": "network"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/synthetics/tests/network" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"config": {
"assertions": [
{
"operator": "lessThan",
"property": "avg",
"target": 500,
"type": "latency"
}
],
"request": {
"host": "example.com",
"port": 443,
"tcp_method": "prefer_sack",
"max_ttl": 30,
"e2e_queries": 50,
"traceroute_queries": 3
}
},
"locations": [
"aws:us-east-1",
"agent:my-agent-name"
],
"message": "Network Path test notification",
"name": "Example Network Path test",
"options": {
"tick_every": 60
},
"status": "live",
"subtype": "tcp",
"tags": [
"env:production"
],
"type": "network"
},
"type": "network"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/synthetics/tests/network" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"config": {
"assertions": [
{
"operator": "lessThan",
"property": "avg",
"target": 500,
"type": "latency"
}
],
"request": {
"host": "example.com",
"port": 443,
"tcp_method": "prefer_sack",
"max_ttl": 30,
"e2e_queries": 50,
"traceroute_queries": 3
}
},
"locations": [
"aws:us-east-1",
"agent:my-agent-name"
],
"message": "Network Path test notification",
"name": "Example Network Path test",
"options": {
"tick_every": 60
},
"status": "live",
"subtype": "tcp",
"tags": [
"env:production"
],
"type": "network"
},
"type": "network"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/synthetics/tests/network" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"config": {
"assertions": [
{
"operator": "lessThan",
"property": "avg",
"target": 500,
"type": "latency"
}
],
"request": {
"host": "example.com",
"port": 443,
"tcp_method": "prefer_sack",
"max_ttl": 30,
"e2e_queries": 50,
"traceroute_queries": 3
}
},
"locations": [
"aws:us-east-1",
"agent:my-agent-name"
],
"message": "Network Path test notification",
"name": "Example Network Path test",
"options": {
"tick_every": 60
},
"status": "live",
"subtype": "tcp",
"tags": [
"env:production"
],
"type": "network"
},
"type": "network"
}
}
EOF// Create a Network Path test returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.SyntheticsNetworkTestEditRequest{
Data: datadogV2.SyntheticsNetworkTestEdit{
Attributes: datadogV2.SyntheticsNetworkTest{
Config: datadogV2.SyntheticsNetworkTestConfig{
Assertions: []datadogV2.SyntheticsNetworkAssertion{
datadogV2.SyntheticsNetworkAssertion{
SyntheticsNetworkAssertionLatency: &datadogV2.SyntheticsNetworkAssertionLatency{
Operator: datadogV2.SYNTHETICSNETWORKASSERTIONOPERATOR_LESS_THAN,
Property: datadogV2.SYNTHETICSNETWORKASSERTIONPROPERTY_AVG,
Target: 500,
Type: datadogV2.SYNTHETICSNETWORKASSERTIONLATENCYTYPE_LATENCY,
}},
},
Request: &datadogV2.SyntheticsNetworkTestRequest{
Host: "example.com",
Port: datadog.PtrInt64(443),
TcpMethod: datadogV2.SYNTHETICSNETWORKTESTREQUESTTCPMETHOD_PREFER_SACK.Ptr(),
MaxTtl: 30,
E2eQueries: 50,
TracerouteQueries: 3,
},
},
Locations: []string{
"aws:us-east-1",
"agent:my-agent-name",
},
Message: "Network Path test notification",
Name: "Example Network Path test",
Options: datadogV2.SyntheticsTestOptions{
TickEvery: datadog.PtrInt64(60),
},
Status: datadogV2.SYNTHETICSTESTPAUSESTATUS_LIVE.Ptr(),
Subtype: datadogV2.SYNTHETICSNETWORKTESTSUBTYPE_TCP.Ptr(),
Tags: []string{
"env:production",
},
Type: datadogV2.SYNTHETICSNETWORKTESTTYPE_NETWORK,
},
Type: datadogV2.SYNTHETICSNETWORKTESTTYPE_NETWORK,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewSyntheticsApi(apiClient)
resp, r, err := api.CreateSyntheticsNetworkTest(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `SyntheticsApi.CreateSyntheticsNetworkTest`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.CreateSyntheticsNetworkTest`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Create a Network Path test returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.SyntheticsApi;
import com.datadog.api.client.v2.model.SyntheticsNetworkAssertion;
import com.datadog.api.client.v2.model.SyntheticsNetworkAssertionLatency;
import com.datadog.api.client.v2.model.SyntheticsNetworkAssertionLatencyType;
import com.datadog.api.client.v2.model.SyntheticsNetworkAssertionOperator;
import com.datadog.api.client.v2.model.SyntheticsNetworkAssertionProperty;
import com.datadog.api.client.v2.model.SyntheticsNetworkTest;
import com.datadog.api.client.v2.model.SyntheticsNetworkTestConfig;
import com.datadog.api.client.v2.model.SyntheticsNetworkTestEdit;
import com.datadog.api.client.v2.model.SyntheticsNetworkTestEditRequest;
import com.datadog.api.client.v2.model.SyntheticsNetworkTestRequest;
import com.datadog.api.client.v2.model.SyntheticsNetworkTestRequestTCPMethod;
import com.datadog.api.client.v2.model.SyntheticsNetworkTestResponse;
import com.datadog.api.client.v2.model.SyntheticsNetworkTestSubType;
import com.datadog.api.client.v2.model.SyntheticsNetworkTestType;
import com.datadog.api.client.v2.model.SyntheticsTestOptions;
import com.datadog.api.client.v2.model.SyntheticsTestPauseStatus;
import java.util.Arrays;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
SyntheticsApi apiInstance = new SyntheticsApi(defaultClient);
SyntheticsNetworkTestEditRequest body =
new SyntheticsNetworkTestEditRequest()
.data(
new SyntheticsNetworkTestEdit()
.attributes(
new SyntheticsNetworkTest()
.config(
new SyntheticsNetworkTestConfig()
.assertions(
Collections.singletonList(
new SyntheticsNetworkAssertion(
new SyntheticsNetworkAssertionLatency()
.operator(
SyntheticsNetworkAssertionOperator
.LESS_THAN)
.property(
SyntheticsNetworkAssertionProperty.AVG)
.target(500.0)
.type(
SyntheticsNetworkAssertionLatencyType
.LATENCY))))
.request(
new SyntheticsNetworkTestRequest()
.host("example.com")
.port(443L)
.tcpMethod(
SyntheticsNetworkTestRequestTCPMethod.PREFER_SACK)
.maxTtl(30L)
.e2eQueries(50L)
.tracerouteQueries(3L)))
.locations(Arrays.asList("aws:us-east-1", "agent:my-agent-name"))
.message("Network Path test notification")
.name("Example Network Path test")
.options(new SyntheticsTestOptions().tickEvery(60L))
.status(SyntheticsTestPauseStatus.LIVE)
.subtype(SyntheticsNetworkTestSubType.TCP)
.tags(Collections.singletonList("env:production"))
.type(SyntheticsNetworkTestType.NETWORK))
.type(SyntheticsNetworkTestType.NETWORK));
try {
SyntheticsNetworkTestResponse result = apiInstance.createSyntheticsNetworkTest(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling SyntheticsApi#createSyntheticsNetworkTest");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Create a Network Path test returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.synthetics_api import SyntheticsApi
from datadog_api_client.v2.model.synthetics_network_assertion_latency import SyntheticsNetworkAssertionLatency
from datadog_api_client.v2.model.synthetics_network_assertion_latency_type import SyntheticsNetworkAssertionLatencyType
from datadog_api_client.v2.model.synthetics_network_assertion_operator import SyntheticsNetworkAssertionOperator
from datadog_api_client.v2.model.synthetics_network_assertion_property import SyntheticsNetworkAssertionProperty
from datadog_api_client.v2.model.synthetics_network_test import SyntheticsNetworkTest
from datadog_api_client.v2.model.synthetics_network_test_config import SyntheticsNetworkTestConfig
from datadog_api_client.v2.model.synthetics_network_test_edit import SyntheticsNetworkTestEdit
from datadog_api_client.v2.model.synthetics_network_test_edit_request import SyntheticsNetworkTestEditRequest
from datadog_api_client.v2.model.synthetics_network_test_request import SyntheticsNetworkTestRequest
from datadog_api_client.v2.model.synthetics_network_test_request_tcp_method import SyntheticsNetworkTestRequestTCPMethod
from datadog_api_client.v2.model.synthetics_network_test_sub_type import SyntheticsNetworkTestSubType
from datadog_api_client.v2.model.synthetics_network_test_type import SyntheticsNetworkTestType
from datadog_api_client.v2.model.synthetics_test_options import SyntheticsTestOptions
from datadog_api_client.v2.model.synthetics_test_pause_status import SyntheticsTestPauseStatus
body = SyntheticsNetworkTestEditRequest(
data=SyntheticsNetworkTestEdit(
attributes=SyntheticsNetworkTest(
config=SyntheticsNetworkTestConfig(
assertions=[
SyntheticsNetworkAssertionLatency(
operator=SyntheticsNetworkAssertionOperator.LESS_THAN,
_property=SyntheticsNetworkAssertionProperty.AVG,
target=500.0,
type=SyntheticsNetworkAssertionLatencyType.LATENCY,
),
],
request=SyntheticsNetworkTestRequest(
host="example.com",
port=443,
tcp_method=SyntheticsNetworkTestRequestTCPMethod.PREFER_SACK,
max_ttl=30,
e2e_queries=50,
traceroute_queries=3,
),
),
locations=[
"aws:us-east-1",
"agent:my-agent-name",
],
message="Network Path test notification",
name="Example Network Path test",
options=SyntheticsTestOptions(
tick_every=60,
),
status=SyntheticsTestPauseStatus.LIVE,
subtype=SyntheticsNetworkTestSubType.TCP,
tags=[
"env:production",
],
type=SyntheticsNetworkTestType.NETWORK,
),
type=SyntheticsNetworkTestType.NETWORK,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = SyntheticsApi(api_client)
response = api_instance.create_synthetics_network_test(body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Create a Network Path test returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::SyntheticsAPI.new
body = DatadogAPIClient::V2::SyntheticsNetworkTestEditRequest.new({
data: DatadogAPIClient::V2::SyntheticsNetworkTestEdit.new({
attributes: DatadogAPIClient::V2::SyntheticsNetworkTest.new({
config: DatadogAPIClient::V2::SyntheticsNetworkTestConfig.new({
assertions: [
DatadogAPIClient::V2::SyntheticsNetworkAssertionLatency.new({
operator: DatadogAPIClient::V2::SyntheticsNetworkAssertionOperator::LESS_THAN,
property: DatadogAPIClient::V2::SyntheticsNetworkAssertionProperty::AVG,
target: 500,
type: DatadogAPIClient::V2::SyntheticsNetworkAssertionLatencyType::LATENCY,
}),
],
request: DatadogAPIClient::V2::SyntheticsNetworkTestRequest.new({
host: "example.com",
port: 443,
tcp_method: DatadogAPIClient::V2::SyntheticsNetworkTestRequestTCPMethod::PREFER_SACK,
max_ttl: 30,
e2e_queries: 50,
traceroute_queries: 3,
}),
}),
locations: [
"aws:us-east-1",
"agent:my-agent-name",
],
message: "Network Path test notification",
name: "Example Network Path test",
options: DatadogAPIClient::V2::SyntheticsTestOptions.new({
tick_every: 60,
}),
status: DatadogAPIClient::V2::SyntheticsTestPauseStatus::LIVE,
subtype: DatadogAPIClient::V2::SyntheticsNetworkTestSubType::TCP,
tags: [
"env:production",
],
type: DatadogAPIClient::V2::SyntheticsNetworkTestType::NETWORK,
}),
type: DatadogAPIClient::V2::SyntheticsNetworkTestType::NETWORK,
}),
})
p api_instance.create_synthetics_network_test(body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Create a Network Path test returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_synthetics::SyntheticsAPI;
use datadog_api_client::datadogV2::model::SyntheticsNetworkAssertion;
use datadog_api_client::datadogV2::model::SyntheticsNetworkAssertionLatency;
use datadog_api_client::datadogV2::model::SyntheticsNetworkAssertionLatencyType;
use datadog_api_client::datadogV2::model::SyntheticsNetworkAssertionOperator;
use datadog_api_client::datadogV2::model::SyntheticsNetworkAssertionProperty;
use datadog_api_client::datadogV2::model::SyntheticsNetworkTest;
use datadog_api_client::datadogV2::model::SyntheticsNetworkTestConfig;
use datadog_api_client::datadogV2::model::SyntheticsNetworkTestEdit;
use datadog_api_client::datadogV2::model::SyntheticsNetworkTestEditRequest;
use datadog_api_client::datadogV2::model::SyntheticsNetworkTestRequest;
use datadog_api_client::datadogV2::model::SyntheticsNetworkTestRequestTCPMethod;
use datadog_api_client::datadogV2::model::SyntheticsNetworkTestSubType;
use datadog_api_client::datadogV2::model::SyntheticsNetworkTestType;
use datadog_api_client::datadogV2::model::SyntheticsTestOptions;
use datadog_api_client::datadogV2::model::SyntheticsTestPauseStatus;
#[tokio::main]
async fn main() {
let body = SyntheticsNetworkTestEditRequest::new(SyntheticsNetworkTestEdit::new(
SyntheticsNetworkTest::new(
SyntheticsNetworkTestConfig::new()
.assertions(vec![
SyntheticsNetworkAssertion::SyntheticsNetworkAssertionLatency(Box::new(
SyntheticsNetworkAssertionLatency::new(
SyntheticsNetworkAssertionOperator::LESS_THAN,
SyntheticsNetworkAssertionProperty::AVG,
500.0,
SyntheticsNetworkAssertionLatencyType::LATENCY,
),
)),
])
.request(
SyntheticsNetworkTestRequest::new(50, "example.com".to_string(), 30, 3)
.port(443)
.tcp_method(SyntheticsNetworkTestRequestTCPMethod::PREFER_SACK),
),
vec![
"aws:us-east-1".to_string(),
"agent:my-agent-name".to_string(),
],
"Network Path test notification".to_string(),
"Example Network Path test".to_string(),
SyntheticsTestOptions::new().tick_every(60),
SyntheticsNetworkTestType::NETWORK,
)
.status(SyntheticsTestPauseStatus::LIVE)
.subtype(SyntheticsNetworkTestSubType::TCP)
.tags(vec!["env:production".to_string()]),
SyntheticsNetworkTestType::NETWORK,
));
let configuration = datadog::Configuration::new();
let api = SyntheticsAPI::with_config(configuration);
let resp = api.create_synthetics_network_test(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Create a Network Path test returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.SyntheticsApi(configuration);
const params: v2.SyntheticsApiCreateSyntheticsNetworkTestRequest = {
body: {
data: {
attributes: {
config: {
assertions: [
{
operator: "lessThan",
property: "avg",
target: 500,
type: "latency",
},
],
request: {
host: "example.com",
port: 443,
tcpMethod: "prefer_sack",
maxTtl: 30,
e2eQueries: 50,
tracerouteQueries: 3,
},
},
locations: ["aws:us-east-1", "agent:my-agent-name"],
message: "Network Path test notification",
name: "Example Network Path test",
options: {
tickEvery: 60,
},
status: "live",
subtype: "tcp",
tags: ["env:production"],
type: "network",
},
type: "network",
},
},
};
apiInstance
.createSyntheticsNetworkTest(params)
.then((data: v2.SyntheticsNetworkTestResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"