Créer une règle personnalisée WAF
https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/custom_ruleshttps://api.us3.datadoghq.com/api/v2/remote_config/products/asm/waf/custom_ruleshttps://api.us5.datadoghq.com/api/v2/remote_config/products/asm/waf/custom_ruleshttps://api.datadoghq.eu/api/v2/remote_config/products/asm/waf/custom_ruleshttps://api.ap1.datadoghq.com/api/v2/remote_config/products/asm/waf/custom_ruleshttps://api.ap2.datadoghq.com/api/v2/remote_config/products/asm/waf/custom_ruleshttps://api.uk1.datadoghq.com/api/v2/remote_config/products/asm/waf/custom_ruleshttps://api.ddog-gov.com/api/v2/remote_config/products/asm/waf/custom_ruleshttps://api.us2.ddog-gov.com/api/v2/remote_config/products/asm/waf/custom_rulesPrésentation
Créer une nouvelle règle personnalisée WAF avec les paramètres fournis.
Requête
Body Data (required)
Définition de la nouvelle règle personnalisée WAF.
data [required]Objet de requête contenant la règle personnalisée à créer.
attributes [required]Create a new WAF custom rule.
actionThe definition of ApplicationSecurityWafCustomRuleAction object.
actionOverride the default action to take when the WAF custom rule would block.
block_requestredirect_request, block_requestparametersThe definition of ApplicationSecurityWafCustomRuleActionParameters object.
locationThe location to redirect to when the WAF custom rule triggers.
status_codeThe status code to return when the WAF custom rule triggers.
403blocking [required]Indicates whether the WAF custom rule will block the request.
conditions [required]Conditions for which the WAF Custom Rule will triggers, all conditions needs to match in order for the WAF rule to trigger
operator [required]Operator to use for the WAF Condition.
match_regex, !match_regex, phrase_match, !phrase_match, is_xss, is_sqli, exact_match, !exact_match, ip_match, !ip_matchShow 5 more
capture_data, exists, !exists, equals, !equalsparameters [required]The scope of the WAF custom rule.
dataIdentifier of a list of data from the denylist. Can only be used as substitution from the list parameter.
inputs [required]List of inputs on which at least one should match with the given operator.
address [required]Input from the request on which the condition should apply.
server.db.statement, server.io.fs.file, server.io.fs.file_write, server.io.net.url, server.sys.shell.cmd, server.request.method, server.request.uri.raw, server.request.path_params, server.request.query, server.request.headersShow 24 more
server.request.headers.no_cookies, server.request.custom-auth, server.request.cookies, server.request.trailers, server.request.body, server.request.body.filenames, server.request.body.files_content, server.response.status, server.response.headers.no_cookies, server.response.trailers, server.response.body, server.response.body.raw, grpc.server.request.metadata, grpc.server.request.message, grpc.server.method, graphql.server.all_resolvers, usr.id, http.client_ip, server.llm.event, server.llm.guard.verdict, _dd.appsec.fp.http.header, _dd.appsec.fp.http.network, _dd.appsec.fp.session, _dd.appsec.fp.http.endpointkey_pathSpecific path for the input.
listList of value to use with the condition. Only used with the phrase_match, !phrase_match, exact_match and !exact_match operator.
optionsOptions for the operator of this condition.
case_sensitiveEvaluate the value as case sensitive.
falsemin_lengthOnly evaluate this condition if the value has a minimum amount of characters.
0regexRegex to use with the condition. Only used with match_regex and !match_regex operator.
typeThe type of the value to compare against. Only used with the equals and !equals operator.
boolean, signed, unsigned, float, stringvalueStore the captured value in the specified tag name. Only used with the capture_data operator.
enabled [required]Indicates whether the WAF custom rule is enabled.
name [required]The name of the WAF custom rule.
path_globThe path glob for the WAF custom rule.
scopeThe scope of the WAF custom rule.
env [required]The environment scope for the WAF custom rule.
service [required]The service scope for the WAF custom rule.
tags [required]Tags associated with the WAF Custom Rule. The concatenation of category and type will form the security activity field associated with the traces.
category [required]The category of the WAF Rule, can be either business_logic, attack_attempt or security_response.
attack_attempt, business_logic, security_responsetype [required]The type of the WAF rule, associated with the category will form the security activity.
type [required]The type of the resource. The value should always be custom_rule.
custom_rulecustom_rule{
"data": {
"attributes": {
"action": {
"action": "block_request",
"parameters": {
"location": "/blocking",
"status_code": 403
}
},
"blocking": false,
"conditions": [
{
"operator": "match_regex",
"parameters": {
"data": "blocked_users",
"regex": "path.*",
"value": "custom_tag"
}
}
],
"enabled": false,
"name": "Block request from a bad useragent",
"path_glob": "/api/search/*",
"scope": [
{
"env": "prod",
"service": "billing-service"
}
],
"tags": {
"category": "business_logic",
"type": "users.login.success"
}
},
"type": "custom_rule"
}
}Réponse
Created
Response object that includes a single WAF custom rule.
dataObject for a single WAF custom rule.
attributesA WAF custom rule.
actionThe definition of ApplicationSecurityWafCustomRuleAction object.
actionOverride the default action to take when the WAF custom rule would block.
block_requestredirect_request, block_requestparametersThe definition of ApplicationSecurityWafCustomRuleActionParameters object.
locationThe location to redirect to when the WAF custom rule triggers.
status_codeThe status code to return when the WAF custom rule triggers.
403blocking [required]Indicates whether the WAF custom rule will block the request.
conditions [required]Conditions for which the WAF Custom Rule will triggers, all conditions needs to match in order for the WAF rule to trigger.
operator [required]Operator to use for the WAF Condition.
match_regex, !match_regex, phrase_match, !phrase_match, is_xss, is_sqli, exact_match, !exact_match, ip_match, !ip_matchShow 5 more
capture_data, exists, !exists, equals, !equalsparameters [required]The scope of the WAF custom rule.
dataIdentifier of a list of data from the denylist. Can only be used as substitution from the list parameter.
inputs [required]List of inputs on which at least one should match with the given operator.
address [required]Input from the request on which the condition should apply.
server.db.statement, server.io.fs.file, server.io.fs.file_write, server.io.net.url, server.sys.shell.cmd, server.request.method, server.request.uri.raw, server.request.path_params, server.request.query, server.request.headersShow 24 more
server.request.headers.no_cookies, server.request.custom-auth, server.request.cookies, server.request.trailers, server.request.body, server.request.body.filenames, server.request.body.files_content, server.response.status, server.response.headers.no_cookies, server.response.trailers, server.response.body, server.response.body.raw, grpc.server.request.metadata, grpc.server.request.message, grpc.server.method, graphql.server.all_resolvers, usr.id, http.client_ip, server.llm.event, server.llm.guard.verdict, _dd.appsec.fp.http.header, _dd.appsec.fp.http.network, _dd.appsec.fp.session, _dd.appsec.fp.http.endpointkey_pathSpecific path for the input.
listList of value to use with the condition. Only used with the phrase_match, !phrase_match, exact_match and !exact_match operator.
optionsOptions for the operator of this condition.
case_sensitiveEvaluate the value as case sensitive.
falsemin_lengthOnly evaluate this condition if the value has a minimum amount of characters.
0regexRegex to use with the condition. Only used with match_regex and !match_regex operator.
typeThe type of the value to compare against. Only used with the equals and !equals operator.
boolean, signed, unsigned, float, stringvalueStore the captured value in the specified tag name. Only used with the capture_data operator.
enabled [required]Indicates whether the WAF custom rule is enabled.
metadataMetadata associated with the WAF Custom Rule.
added_atThe date and time the WAF custom rule was created.
added_byThe handle of the user who created the WAF custom rule.
added_by_nameThe name of the user who created the WAF custom rule.
modified_atThe date and time the WAF custom rule was last updated.
modified_byThe handle of the user who last updated the WAF custom rule.
modified_by_nameThe name of the user who last updated the WAF custom rule.
name [required]The name of the WAF custom rule.
path_globThe path glob for the WAF custom rule.
scopeThe scope of the WAF custom rule.
env [required]The environment scope for the WAF custom rule.
service [required]The service scope for the WAF custom rule.
tags [required]Tags associated with the WAF Custom Rule. The concatenation of category and type will form the security activity field associated with the traces.
category [required]The category of the WAF Rule, can be either business_logic, attack_attempt or security_response.
attack_attempt, business_logic, security_responsetype [required]The type of the WAF rule, associated with the category will form the security activity.
idThe ID of the custom rule.
typeThe type of the resource. The value should always be custom_rule.
custom_rulecustom_rule{
"data": {
"attributes": {
"action": {
"action": "block_request",
"parameters": {
"location": "/blocking",
"status_code": 403
}
},
"blocking": false,
"conditions": [
{
"operator": "match_regex",
"parameters": {
"data": "blocked_users",
"inputs": [
{
"address": "server.db.statement",
"key_path": []
}
],
"list": [],
"options": {
"case_sensitive": false,
"min_length": "integer"
},
"regex": "path.*",
"type": "string",
"value": "custom_tag"
}
}
],
"enabled": false,
"metadata": {
"added_at": "2021-01-01T00:00:00Z",
"added_by": "john.doe@datadoghq.com",
"added_by_name": "John Doe",
"modified_at": "2021-01-01T00:00:00Z",
"modified_by": "john.doe@datadoghq.com",
"modified_by_name": "John Doe"
},
"name": "Block request from bad useragent",
"path_glob": "/api/search/*",
"scope": [
{
"env": "prod",
"service": "billing-service"
}
],
"tags": {
"category": "business_logic",
"type": "users.login.success"
}
},
"id": "2857c47d-1e3a-4300-8b2f-dc24089c084b",
"type": "custom_rule"
}
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Not Authorized
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Concurrent Modification
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/remote_config/products/asm/waf/custom_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"action": {
"action": "block_request",
"parameters": {
"location": "/blocking",
"status_code": 403
}
},
"blocking": false,
"conditions": [
{
"operator": "match_regex",
"parameters": {
"data": "blocked_users",
"regex": "path.*",
"value": "custom_tag"
}
}
],
"enabled": false,
"name": "Block request from a bad useragent",
"path_glob": "/api/search/*",
"scope": [
{
"env": "prod",
"service": "billing-service"
}
],
"tags": {
"category": "business_logic",
"type": "users.login.success"
}
},
"type": "custom_rule"
}
}
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/remote_config/products/asm/waf/custom_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"action": {
"action": "block_request",
"parameters": {
"location": "/blocking",
"status_code": 403
}
},
"blocking": false,
"conditions": [
{
"operator": "match_regex",
"parameters": {
"data": "blocked_users",
"regex": "path.*",
"value": "custom_tag"
}
}
],
"enabled": false,
"name": "Block request from a bad useragent",
"path_glob": "/api/search/*",
"scope": [
{
"env": "prod",
"service": "billing-service"
}
],
"tags": {
"category": "business_logic",
"type": "users.login.success"
}
},
"type": "custom_rule"
}
}
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/remote_config/products/asm/waf/custom_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"action": {
"action": "block_request",
"parameters": {
"location": "/blocking",
"status_code": 403
}
},
"blocking": false,
"conditions": [
{
"operator": "match_regex",
"parameters": {
"data": "blocked_users",
"regex": "path.*",
"value": "custom_tag"
}
}
],
"enabled": false,
"name": "Block request from a bad useragent",
"path_glob": "/api/search/*",
"scope": [
{
"env": "prod",
"service": "billing-service"
}
],
"tags": {
"category": "business_logic",
"type": "users.login.success"
}
},
"type": "custom_rule"
}
}
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/remote_config/products/asm/waf/custom_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"action": {
"action": "block_request",
"parameters": {
"location": "/blocking",
"status_code": 403
}
},
"blocking": false,
"conditions": [
{
"operator": "match_regex",
"parameters": {
"data": "blocked_users",
"regex": "path.*",
"value": "custom_tag"
}
}
],
"enabled": false,
"name": "Block request from a bad useragent",
"path_glob": "/api/search/*",
"scope": [
{
"env": "prod",
"service": "billing-service"
}
],
"tags": {
"category": "business_logic",
"type": "users.login.success"
}
},
"type": "custom_rule"
}
}
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/remote_config/products/asm/waf/custom_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"action": {
"action": "block_request",
"parameters": {
"location": "/blocking",
"status_code": 403
}
},
"blocking": false,
"conditions": [
{
"operator": "match_regex",
"parameters": {
"data": "blocked_users",
"regex": "path.*",
"value": "custom_tag"
}
}
],
"enabled": false,
"name": "Block request from a bad useragent",
"path_glob": "/api/search/*",
"scope": [
{
"env": "prod",
"service": "billing-service"
}
],
"tags": {
"category": "business_logic",
"type": "users.login.success"
}
},
"type": "custom_rule"
}
}
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/remote_config/products/asm/waf/custom_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"action": {
"action": "block_request",
"parameters": {
"location": "/blocking",
"status_code": 403
}
},
"blocking": false,
"conditions": [
{
"operator": "match_regex",
"parameters": {
"data": "blocked_users",
"regex": "path.*",
"value": "custom_tag"
}
}
],
"enabled": false,
"name": "Block request from a bad useragent",
"path_glob": "/api/search/*",
"scope": [
{
"env": "prod",
"service": "billing-service"
}
],
"tags": {
"category": "business_logic",
"type": "users.login.success"
}
},
"type": "custom_rule"
}
}
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/remote_config/products/asm/waf/custom_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"action": {
"action": "block_request",
"parameters": {
"location": "/blocking",
"status_code": 403
}
},
"blocking": false,
"conditions": [
{
"operator": "match_regex",
"parameters": {
"data": "blocked_users",
"regex": "path.*",
"value": "custom_tag"
}
}
],
"enabled": false,
"name": "Block request from a bad useragent",
"path_glob": "/api/search/*",
"scope": [
{
"env": "prod",
"service": "billing-service"
}
],
"tags": {
"category": "business_logic",
"type": "users.login.success"
}
},
"type": "custom_rule"
}
}
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/remote_config/products/asm/waf/custom_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"action": {
"action": "block_request",
"parameters": {
"location": "/blocking",
"status_code": 403
}
},
"blocking": false,
"conditions": [
{
"operator": "match_regex",
"parameters": {
"data": "blocked_users",
"regex": "path.*",
"value": "custom_tag"
}
}
],
"enabled": false,
"name": "Block request from a bad useragent",
"path_glob": "/api/search/*",
"scope": [
{
"env": "prod",
"service": "billing-service"
}
],
"tags": {
"category": "business_logic",
"type": "users.login.success"
}
},
"type": "custom_rule"
}
}
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/remote_config/products/asm/waf/custom_rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"action": {
"action": "block_request",
"parameters": {
"location": "/blocking",
"status_code": 403
}
},
"blocking": false,
"conditions": [
{
"operator": "match_regex",
"parameters": {
"data": "blocked_users",
"regex": "path.*",
"value": "custom_tag"
}
}
],
"enabled": false,
"name": "Block request from a bad useragent",
"path_glob": "/api/search/*",
"scope": [
{
"env": "prod",
"service": "billing-service"
}
],
"tags": {
"category": "business_logic",
"type": "users.login.success"
}
},
"type": "custom_rule"
}
}
EOF// Create a WAF custom rule returns "Created" 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.ApplicationSecurityWafCustomRuleCreateRequest{
Data: datadogV2.ApplicationSecurityWafCustomRuleCreateData{
Attributes: datadogV2.ApplicationSecurityWafCustomRuleCreateAttributes{
Action: &datadogV2.ApplicationSecurityWafCustomRuleAction{
Action: datadogV2.APPLICATIONSECURITYWAFCUSTOMRULEACTIONACTION_BLOCK_REQUEST.Ptr(),
Parameters: &datadogV2.ApplicationSecurityWafCustomRuleActionParameters{
Location: datadog.PtrString("/blocking"),
StatusCode: datadog.PtrInt64(403),
},
},
Blocking: false,
Conditions: []datadogV2.ApplicationSecurityWafCustomRuleCondition{
{
Operator: datadogV2.APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_MATCH_REGEX,
Parameters: datadogV2.ApplicationSecurityWafCustomRuleConditionParameters{
Data: datadog.PtrString("blocked_users"),
Inputs: []datadogV2.ApplicationSecurityWafCustomRuleConditionInput{
{
Address: datadogV2.APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_DB_STATEMENT,
KeyPath: []string{},
},
},
List: []string{},
Options: &datadogV2.ApplicationSecurityWafCustomRuleConditionOptions{
CaseSensitive: datadog.PtrBool(false),
MinLength: datadog.PtrInt64(0),
},
Regex: datadog.PtrString("path.*"),
Type: datadogV2.APPLICATIONSECURITYWAFCUSTOMRULECONDITIONPARAMETERSTYPE_STRING.Ptr(),
Value: datadog.PtrString("custom_tag"),
},
},
},
Enabled: false,
Name: "Block request from a bad useragent",
PathGlob: datadog.PtrString("/api/search/*"),
Scope: []datadogV2.ApplicationSecurityWafCustomRuleScope{
{
Env: "prod",
Service: "billing-service",
},
},
Tags: datadogV2.ApplicationSecurityWafCustomRuleTags{
Category: datadogV2.APPLICATIONSECURITYWAFCUSTOMRULETAGSCATEGORY_BUSINESS_LOGIC,
Type: "users.login.success",
},
},
Type: datadogV2.APPLICATIONSECURITYWAFCUSTOMRULETYPE_CUSTOM_RULE,
},
}
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.NewApplicationSecurityApi(apiClient)
resp, r, err := api.CreateApplicationSecurityWafCustomRule(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `ApplicationSecurityApi.CreateApplicationSecurityWafCustomRule`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `ApplicationSecurityApi.CreateApplicationSecurityWafCustomRule`:\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 WAF custom rule returns "Created" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.ApplicationSecurityApi;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleAction;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleActionAction;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleActionParameters;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleCondition;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleConditionInput;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleConditionInputAddress;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleConditionOperator;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleConditionOptions;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleConditionParameters;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleConditionParametersType;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleCreateAttributes;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleCreateData;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleCreateRequest;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleResponse;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleScope;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleTags;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleTagsCategory;
import com.datadog.api.client.v2.model.ApplicationSecurityWafCustomRuleType;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
ApplicationSecurityApi apiInstance = new ApplicationSecurityApi(defaultClient);
ApplicationSecurityWafCustomRuleCreateRequest body =
new ApplicationSecurityWafCustomRuleCreateRequest()
.data(
new ApplicationSecurityWafCustomRuleCreateData()
.attributes(
new ApplicationSecurityWafCustomRuleCreateAttributes()
.action(
new ApplicationSecurityWafCustomRuleAction()
.action(
ApplicationSecurityWafCustomRuleActionAction.BLOCK_REQUEST)
.parameters(
new ApplicationSecurityWafCustomRuleActionParameters()
.location("/blocking")
.statusCode(403L)))
.blocking(false)
.conditions(
Collections.singletonList(
new ApplicationSecurityWafCustomRuleCondition()
.operator(
ApplicationSecurityWafCustomRuleConditionOperator
.MATCH_REGEX)
.parameters(
new ApplicationSecurityWafCustomRuleConditionParameters()
.data("blocked_users")
.inputs(
Collections.singletonList(
new ApplicationSecurityWafCustomRuleConditionInput()
.address(
ApplicationSecurityWafCustomRuleConditionInputAddress
.SERVER_DB_STATEMENT)))
.options(
new ApplicationSecurityWafCustomRuleConditionOptions()
.caseSensitive(false)
.minLength(0L))
.regex("path.*")
.type(
ApplicationSecurityWafCustomRuleConditionParametersType
.STRING)
.value("custom_tag"))))
.enabled(false)
.name("Block request from a bad useragent")
.pathGlob("/api/search/*")
.scope(
Collections.singletonList(
new ApplicationSecurityWafCustomRuleScope()
.env("prod")
.service("billing-service")))
.tags(
new ApplicationSecurityWafCustomRuleTags()
.category(
ApplicationSecurityWafCustomRuleTagsCategory.BUSINESS_LOGIC)
.type("users.login.success")))
.type(ApplicationSecurityWafCustomRuleType.CUSTOM_RULE));
try {
ApplicationSecurityWafCustomRuleResponse result =
apiInstance.createApplicationSecurityWafCustomRule(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling ApplicationSecurityApi#createApplicationSecurityWafCustomRule");
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 WAF custom rule returns "Created" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.application_security_api import ApplicationSecurityApi
from datadog_api_client.v2.model.application_security_waf_custom_rule_action import (
ApplicationSecurityWafCustomRuleAction,
)
from datadog_api_client.v2.model.application_security_waf_custom_rule_action_action import (
ApplicationSecurityWafCustomRuleActionAction,
)
from datadog_api_client.v2.model.application_security_waf_custom_rule_action_parameters import (
ApplicationSecurityWafCustomRuleActionParameters,
)
from datadog_api_client.v2.model.application_security_waf_custom_rule_condition import (
ApplicationSecurityWafCustomRuleCondition,
)
from datadog_api_client.v2.model.application_security_waf_custom_rule_condition_input import (
ApplicationSecurityWafCustomRuleConditionInput,
)
from datadog_api_client.v2.model.application_security_waf_custom_rule_condition_input_address import (
ApplicationSecurityWafCustomRuleConditionInputAddress,
)
from datadog_api_client.v2.model.application_security_waf_custom_rule_condition_operator import (
ApplicationSecurityWafCustomRuleConditionOperator,
)
from datadog_api_client.v2.model.application_security_waf_custom_rule_condition_options import (
ApplicationSecurityWafCustomRuleConditionOptions,
)
from datadog_api_client.v2.model.application_security_waf_custom_rule_condition_parameters import (
ApplicationSecurityWafCustomRuleConditionParameters,
)
from datadog_api_client.v2.model.application_security_waf_custom_rule_condition_parameters_type import (
ApplicationSecurityWafCustomRuleConditionParametersType,
)
from datadog_api_client.v2.model.application_security_waf_custom_rule_create_attributes import (
ApplicationSecurityWafCustomRuleCreateAttributes,
)
from datadog_api_client.v2.model.application_security_waf_custom_rule_create_data import (
ApplicationSecurityWafCustomRuleCreateData,
)
from datadog_api_client.v2.model.application_security_waf_custom_rule_create_request import (
ApplicationSecurityWafCustomRuleCreateRequest,
)
from datadog_api_client.v2.model.application_security_waf_custom_rule_scope import ApplicationSecurityWafCustomRuleScope
from datadog_api_client.v2.model.application_security_waf_custom_rule_tags import ApplicationSecurityWafCustomRuleTags
from datadog_api_client.v2.model.application_security_waf_custom_rule_tags_category import (
ApplicationSecurityWafCustomRuleTagsCategory,
)
from datadog_api_client.v2.model.application_security_waf_custom_rule_type import ApplicationSecurityWafCustomRuleType
body = ApplicationSecurityWafCustomRuleCreateRequest(
data=ApplicationSecurityWafCustomRuleCreateData(
attributes=ApplicationSecurityWafCustomRuleCreateAttributes(
action=ApplicationSecurityWafCustomRuleAction(
action=ApplicationSecurityWafCustomRuleActionAction.BLOCK_REQUEST,
parameters=ApplicationSecurityWafCustomRuleActionParameters(
location="/blocking",
status_code=403,
),
),
blocking=False,
conditions=[
ApplicationSecurityWafCustomRuleCondition(
operator=ApplicationSecurityWafCustomRuleConditionOperator.MATCH_REGEX,
parameters=ApplicationSecurityWafCustomRuleConditionParameters(
data="blocked_users",
inputs=[
ApplicationSecurityWafCustomRuleConditionInput(
address=ApplicationSecurityWafCustomRuleConditionInputAddress.SERVER_DB_STATEMENT,
key_path=[],
),
],
list=[],
options=ApplicationSecurityWafCustomRuleConditionOptions(
case_sensitive=False,
min_length=0,
),
regex="path.*",
type=ApplicationSecurityWafCustomRuleConditionParametersType.STRING,
value="custom_tag",
),
),
],
enabled=False,
name="Block request from a bad useragent",
path_glob="/api/search/*",
scope=[
ApplicationSecurityWafCustomRuleScope(
env="prod",
service="billing-service",
),
],
tags=ApplicationSecurityWafCustomRuleTags(
category=ApplicationSecurityWafCustomRuleTagsCategory.BUSINESS_LOGIC,
type="users.login.success",
),
),
type=ApplicationSecurityWafCustomRuleType.CUSTOM_RULE,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = ApplicationSecurityApi(api_client)
response = api_instance.create_application_security_waf_custom_rule(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 WAF custom rule returns "Created" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::ApplicationSecurityAPI.new
body = DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleCreateRequest.new({
data: DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleCreateData.new({
attributes: DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleCreateAttributes.new({
action: DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleAction.new({
action: DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleActionAction::BLOCK_REQUEST,
parameters: DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleActionParameters.new({
location: "/blocking",
status_code: 403,
}),
}),
blocking: false,
conditions: [
DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleCondition.new({
operator: DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleConditionOperator::MATCH_REGEX,
parameters: DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleConditionParameters.new({
data: "blocked_users",
inputs: [
DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleConditionInput.new({
address: DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleConditionInputAddress::SERVER_DB_STATEMENT,
key_path: [],
}),
],
list: [],
options: DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleConditionOptions.new({
case_sensitive: false,
min_length: 0,
}),
regex: "path.*",
type: DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleConditionParametersType::STRING,
value: "custom_tag",
}),
}),
],
enabled: false,
name: "Block request from a bad useragent",
path_glob: "/api/search/*",
scope: [
DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleScope.new({
env: "prod",
service: "billing-service",
}),
],
tags: DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleTags.new({
category: DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleTagsCategory::BUSINESS_LOGIC,
type: "users.login.success",
}),
}),
type: DatadogAPIClient::V2::ApplicationSecurityWafCustomRuleType::CUSTOM_RULE,
}),
})
p api_instance.create_application_security_waf_custom_rule(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 WAF custom rule returns "Created" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_application_security::ApplicationSecurityAPI;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleAction;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleActionAction;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleActionParameters;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleCondition;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleConditionInput;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleConditionInputAddress;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleConditionOperator;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleConditionOptions;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleConditionParameters;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleConditionParametersType;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleCreateAttributes;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleCreateData;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleCreateRequest;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleScope;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleTags;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleTagsCategory;
use datadog_api_client::datadogV2::model::ApplicationSecurityWafCustomRuleType;
use std::collections::BTreeMap;
#[tokio::main]
async fn main() {
let body =
ApplicationSecurityWafCustomRuleCreateRequest::new(
ApplicationSecurityWafCustomRuleCreateData::new(
ApplicationSecurityWafCustomRuleCreateAttributes::new(
false,
vec![
ApplicationSecurityWafCustomRuleCondition::new(
ApplicationSecurityWafCustomRuleConditionOperator::MATCH_REGEX,
ApplicationSecurityWafCustomRuleConditionParameters::new(
vec![
ApplicationSecurityWafCustomRuleConditionInput::new(
ApplicationSecurityWafCustomRuleConditionInputAddress::SERVER_DB_STATEMENT,
).key_path(vec![])
],
)
.data("blocked_users".to_string())
.list(vec![])
.options(
ApplicationSecurityWafCustomRuleConditionOptions::new()
.case_sensitive(false)
.min_length(0),
)
.regex("path.*".to_string())
.type_(ApplicationSecurityWafCustomRuleConditionParametersType::STRING)
.value("custom_tag".to_string()),
)
],
false,
"Block request from a bad useragent".to_string(),
ApplicationSecurityWafCustomRuleTags::new(
ApplicationSecurityWafCustomRuleTagsCategory::BUSINESS_LOGIC,
"users.login.success".to_string(),
).additional_properties(BTreeMap::from([])),
)
.action(
ApplicationSecurityWafCustomRuleAction::new()
.action(ApplicationSecurityWafCustomRuleActionAction::BLOCK_REQUEST)
.parameters(
ApplicationSecurityWafCustomRuleActionParameters::new()
.location("/blocking".to_string())
.status_code(403),
),
)
.path_glob("/api/search/*".to_string())
.scope(
vec![
ApplicationSecurityWafCustomRuleScope::new(
"prod".to_string(),
"billing-service".to_string(),
)
],
),
ApplicationSecurityWafCustomRuleType::CUSTOM_RULE,
),
);
let configuration = datadog::Configuration::new();
let api = ApplicationSecurityAPI::with_config(configuration);
let resp = api.create_application_security_waf_custom_rule(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="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run/**
* Create a WAF custom rule returns "Created" 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.ApplicationSecurityApi(configuration);
const params: v2.ApplicationSecurityApiCreateApplicationSecurityWafCustomRuleRequest =
{
body: {
data: {
attributes: {
action: {
action: "block_request",
parameters: {
location: "/blocking",
statusCode: 403,
},
},
blocking: false,
conditions: [
{
operator: "match_regex",
parameters: {
data: "blocked_users",
inputs: [
{
address: "server.db.statement",
keyPath: [],
},
],
list: [],
options: {
caseSensitive: false,
minLength: 0,
},
regex: "path.*",
type: "string",
value: "custom_tag",
},
},
],
enabled: false,
name: "Block request from a bad useragent",
pathGlob: "/api/search/*",
scope: [
{
env: "prod",
service: "billing-service",
},
],
tags: {
category: "business_logic",
type: "users.login.success",
},
},
type: "custom_rule",
},
},
};
apiInstance
.createApplicationSecurityWafCustomRule(params)
.then((data: v2.ApplicationSecurityWafCustomRuleResponse) => {
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"