Créer une destination personnalisée
https://api.datadoghq.com/api/v2/logs/config/custom-destinationshttps://api.us3.datadoghq.com/api/v2/logs/config/custom-destinationshttps://api.us5.datadoghq.com/api/v2/logs/config/custom-destinationshttps://api.datadoghq.eu/api/v2/logs/config/custom-destinationshttps://api.ap1.datadoghq.com/api/v2/logs/config/custom-destinationshttps://api.ap2.datadoghq.com/api/v2/logs/config/custom-destinationshttps://api.uk1.datadoghq.com/api/v2/logs/config/custom-destinationshttps://api.ddog-gov.com/api/v2/logs/config/custom-destinationshttps://api.us2.ddog-gov.com/api/v2/logs/config/custom-destinationsPrésentation
Créez une destination personnalisée dans votre organisation.
Requête
Body Data (required)
La définition de la nouvelle destination personnalisée.
dataLa destination personnalisée.
attributes [required]The attributes associated with the custom destination.
enabledWhether logs matching this custom destination should be forwarded or not.
trueforward_tagsWhether tags from the forwarded logs should be forwarded or not.
trueforward_tags_restriction_listList of keys of tags to be filtered.
An empty list represents no restriction is in place and either all or no tags will be
forwarded depending on forward_tags_restriction_list_type parameter.
forward_tags_restriction_list_typeHow forward_tags_restriction_list parameter should be interpreted.
If ALLOW_LIST, then only tags whose keys on the forwarded logs match the ones on the restriction list
are forwarded.
BLOCK_LIST works the opposite way. It does not forward the tags matching the ones on the list.
ALLOW_LISTALLOW_LIST, BLOCK_LISTforwarder_destination [required]A custom destination's location to forward logs.
<type=http>The HTTP destination.
auth [required]Authentication method of the HTTP requests.
<type=basic>Basic access authentication.
password [required]The password of the authentication. This field is not returned by the API.
type [required]Type of the basic access authentication.
basicbasicusername [required]The username of the authentication. This field is not returned by the API.
<type=custom_header>Custom header access authentication.
header_name [required]The header name of the authentication.
header_value [required]The header value of the authentication. This field is not returned by the API.
type [required]Type of the custom header access authentication.
custom_headercustom_headerendpoint [required]The destination for which logs will be forwarded to. Must have HTTPS scheme and forwarding back to Datadog is not allowed.
type [required]Type of the HTTP destination.
httphttp<type=splunk_hec>The Splunk HTTP Event Collector (HEC) destination.
access_token [required]Access token of the Splunk HTTP Event Collector. This field is not returned by the API.
endpoint [required]The destination for which logs will be forwarded to. Must have HTTPS scheme and forwarding back to Datadog is not allowed.
sourcetypeThe Splunk sourcetype for the events sent to this Splunk destination.
If the field is absent from the request and no sourcetype has been previously set on this destination, the default sourcetype _json is used.
On update, if the field is absent from the request but a sourcetype was previously set, the previous value is kept.
If set to null, the sourcetype field is omitted from the forwarded event entirely.
Otherwise, the provided string value is used as the sourcetype.
type [required]Type of the Splunk HTTP Event Collector (HEC) destination.
splunk_hecsplunk_hec<type=elasticsearch>The Elasticsearch destination.
auth [required]Basic access authentication.
password [required]The password of the authentication. This field is not returned by the API.
username [required]The username of the authentication. This field is not returned by the API.
endpoint [required]The destination for which logs will be forwarded to. Must have HTTPS scheme and forwarding back to Datadog is not allowed.
index_rotationDate pattern with US locale and UTC timezone to be appended to the index name after adding -
(that is, ${index_name}-${indexPattern}).
You can customize the index rotation naming pattern by choosing one of these options:
- Hourly:
yyyy-MM-dd-HH(as an example, it would render:2022-10-19-09) - Daily:
yyyy-MM-dd(as an example, it would render:2022-10-19) - Weekly:
yyyy-'W'ww(as an example, it would render:2022-W42) - Monthly:
yyyy-MM(as an example, it would render:2022-10)
If this field is missing or is blank, it means that the index name will always be the same (that is, no rotation).
type [required]Type of the Elasticsearch destination.
elasticsearchelasticsearch<type=microsoft_sentinel>The Microsoft Sentinel destination.
client_id [required]Client ID from the Datadog Azure integration.
data_collection_endpoint [required]Azure data collection endpoint.
data_collection_rule_id [required]Azure data collection rule ID.
stream_name [required]Azure stream name.
tenant_id [required]Tenant ID from the Datadog Azure integration.
type [required]Type of the Microsoft Sentinel destination.
microsoft_sentinelmicrosoft_sentinelname [required]The custom destination name.
queryThe custom destination query and filter. Logs matching this query are forwarded to the destination.
""type [required]The type of the resource. The value should always be custom_destination.
custom_destinationcustom_destinationCreate a Basic HTTP custom destination returns "OK" response
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"password": "datadog-custom-destination-password",
"type": "basic",
"username": "datadog-custom-destination-username"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}Create a Custom Header HTTP custom destination returns "OK" response
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"header_value": "my-secret",
"type": "custom_header",
"header_name": "MY-AUTHENTICATION-HEADER"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}Create a Microsoft Sentinel custom destination returns "OK" response
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"type": "microsoft_sentinel",
"tenant_id": "f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2",
"client_id": "9a2f4d83-2b5e-429e-a35a-2b3c4182db71",
"data_collection_endpoint": "https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com",
"data_collection_rule_id": "dcr-000a00a000a00000a000000aa000a0aa",
"stream_name": "Custom-MyTable"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}Réponse
OK
The custom destination.
dataThe definition of a custom destination.
attributesThe attributes associated with the custom destination.
enabledWhether logs matching this custom destination should be forwarded or not.
trueforward_tagsWhether tags from the forwarded logs should be forwarded or not.
trueforward_tags_restriction_listList of keys of tags to be filtered.
An empty list represents no restriction is in place and either all or no tags will be
forwarded depending on forward_tags_restriction_list_type parameter.
forward_tags_restriction_list_typeHow forward_tags_restriction_list parameter should be interpreted.
If ALLOW_LIST, then only tags whose keys on the forwarded logs match the ones on the restriction list
are forwarded.
BLOCK_LIST works the opposite way. It does not forward the tags matching the ones on the list.
ALLOW_LISTALLOW_LIST, BLOCK_LISTforwarder_destinationA custom destination's location to forward logs.
<type=http>The HTTP destination.
auth [required]Authentication method of the HTTP requests.
<type=basic>Basic access authentication.
type [required]Type of the basic access authentication.
basicbasic<type=custom_header>Custom header access authentication.
header_name [required]The header name of the authentication.
type [required]Type of the custom header access authentication.
custom_headercustom_headerendpoint [required]The destination for which logs will be forwarded to. Must have HTTPS scheme and forwarding back to Datadog is not allowed.
type [required]Type of the HTTP destination.
httphttp<type=splunk_hec>The Splunk HTTP Event Collector (HEC) destination.
endpoint [required]The destination for which logs will be forwarded to. Must have HTTPS scheme and forwarding back to Datadog is not allowed.
sourcetypeThe Splunk sourcetype for the events sent to this Splunk destination.
If the field is absent from the request and no sourcetype has been previously set on this destination, the default sourcetype _json is used.
On update, if the field is absent from the request but a sourcetype was previously set, the previous value is kept.
If set to null, the sourcetype field is omitted from the forwarded event entirely.
Otherwise, the provided string value is used as the sourcetype.
type [required]Type of the Splunk HTTP Event Collector (HEC) destination.
splunk_hecsplunk_hec<type=elasticsearch>The Elasticsearch destination.
auth [required]Basic access authentication.
<any-key>Basic access authentication.
endpoint [required]The destination for which logs will be forwarded to. Must have HTTPS scheme and forwarding back to Datadog is not allowed.
index_rotationDate pattern with US locale and UTC timezone to be appended to the index name after adding -
(that is, ${index_name}-${indexPattern}).
You can customize the index rotation naming pattern by choosing one of these options:
- Hourly:
yyyy-MM-dd-HH(as an example, it would render:2022-10-19-09) - Daily:
yyyy-MM-dd(as an example, it would render:2022-10-19) - Weekly:
yyyy-'W'ww(as an example, it would render:2022-W42) - Monthly:
yyyy-MM(as an example, it would render:2022-10)
If this field is missing or is blank, it means that the index name will always be the same (that is, no rotation).
type [required]Type of the Elasticsearch destination.
elasticsearchelasticsearch<type=microsoft_sentinel>The Microsoft Sentinel destination.
client_id [required]Client ID from the Datadog Azure integration.
data_collection_endpoint [required]Azure data collection endpoint.
data_collection_rule_id [required]Azure data collection rule ID.
tenant_id [required]Tenant ID from the Datadog Azure integration.
type [required]Type of the Microsoft Sentinel destination.
microsoft_sentinelmicrosoft_sentinelnameThe custom destination name.
queryThe custom destination query filter. Logs matching this query are forwarded to the destination.
""idThe custom destination ID.
typeThe type of the resource. The value should always be custom_destination.
custom_destinationcustom_destination{
"data": {
"attributes": {
"enabled": true,
"forward_tags": true,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"type": "basic"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"id": "be5d7a69-d0c8-4d4d-8ee8-bba292d98139",
"type": "custom_destination"
}
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Forbidden
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Conflict
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
Create a Basic HTTP custom destination returns "OK" response
# 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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"password": "datadog-custom-destination-password",
"type": "basic",
"username": "datadog-custom-destination-username"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"password": "datadog-custom-destination-password",
"type": "basic",
"username": "datadog-custom-destination-username"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"password": "datadog-custom-destination-password",
"type": "basic",
"username": "datadog-custom-destination-username"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"password": "datadog-custom-destination-password",
"type": "basic",
"username": "datadog-custom-destination-username"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"password": "datadog-custom-destination-password",
"type": "basic",
"username": "datadog-custom-destination-username"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"password": "datadog-custom-destination-password",
"type": "basic",
"username": "datadog-custom-destination-username"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"password": "datadog-custom-destination-password",
"type": "basic",
"username": "datadog-custom-destination-username"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"password": "datadog-custom-destination-password",
"type": "basic",
"username": "datadog-custom-destination-username"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"password": "datadog-custom-destination-password",
"type": "basic",
"username": "datadog-custom-destination-username"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
EOFCreate a Custom Header HTTP custom destination returns "OK" response
# 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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"header_value": "my-secret",
"type": "custom_header",
"header_name": "MY-AUTHENTICATION-HEADER"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"header_value": "my-secret",
"type": "custom_header",
"header_name": "MY-AUTHENTICATION-HEADER"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"header_value": "my-secret",
"type": "custom_header",
"header_name": "MY-AUTHENTICATION-HEADER"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"header_value": "my-secret",
"type": "custom_header",
"header_name": "MY-AUTHENTICATION-HEADER"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"header_value": "my-secret",
"type": "custom_header",
"header_name": "MY-AUTHENTICATION-HEADER"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"header_value": "my-secret",
"type": "custom_header",
"header_name": "MY-AUTHENTICATION-HEADER"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"header_value": "my-secret",
"type": "custom_header",
"header_name": "MY-AUTHENTICATION-HEADER"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"header_value": "my-secret",
"type": "custom_header",
"header_name": "MY-AUTHENTICATION-HEADER"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"auth": {
"header_value": "my-secret",
"type": "custom_header",
"header_name": "MY-AUTHENTICATION-HEADER"
},
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
EOFCreate a Microsoft Sentinel custom destination returns "OK" response
# 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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"type": "microsoft_sentinel",
"tenant_id": "f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2",
"client_id": "9a2f4d83-2b5e-429e-a35a-2b3c4182db71",
"data_collection_endpoint": "https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com",
"data_collection_rule_id": "dcr-000a00a000a00000a000000aa000a0aa",
"stream_name": "Custom-MyTable"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"type": "microsoft_sentinel",
"tenant_id": "f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2",
"client_id": "9a2f4d83-2b5e-429e-a35a-2b3c4182db71",
"data_collection_endpoint": "https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com",
"data_collection_rule_id": "dcr-000a00a000a00000a000000aa000a0aa",
"stream_name": "Custom-MyTable"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"type": "microsoft_sentinel",
"tenant_id": "f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2",
"client_id": "9a2f4d83-2b5e-429e-a35a-2b3c4182db71",
"data_collection_endpoint": "https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com",
"data_collection_rule_id": "dcr-000a00a000a00000a000000aa000a0aa",
"stream_name": "Custom-MyTable"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"type": "microsoft_sentinel",
"tenant_id": "f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2",
"client_id": "9a2f4d83-2b5e-429e-a35a-2b3c4182db71",
"data_collection_endpoint": "https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com",
"data_collection_rule_id": "dcr-000a00a000a00000a000000aa000a0aa",
"stream_name": "Custom-MyTable"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"type": "microsoft_sentinel",
"tenant_id": "f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2",
"client_id": "9a2f4d83-2b5e-429e-a35a-2b3c4182db71",
"data_collection_endpoint": "https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com",
"data_collection_rule_id": "dcr-000a00a000a00000a000000aa000a0aa",
"stream_name": "Custom-MyTable"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"type": "microsoft_sentinel",
"tenant_id": "f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2",
"client_id": "9a2f4d83-2b5e-429e-a35a-2b3c4182db71",
"data_collection_endpoint": "https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com",
"data_collection_rule_id": "dcr-000a00a000a00000a000000aa000a0aa",
"stream_name": "Custom-MyTable"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"type": "microsoft_sentinel",
"tenant_id": "f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2",
"client_id": "9a2f4d83-2b5e-429e-a35a-2b3c4182db71",
"data_collection_endpoint": "https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com",
"data_collection_rule_id": "dcr-000a00a000a00000a000000aa000a0aa",
"stream_name": "Custom-MyTable"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"type": "microsoft_sentinel",
"tenant_id": "f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2",
"client_id": "9a2f4d83-2b5e-429e-a35a-2b3c4182db71",
"data_collection_endpoint": "https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com",
"data_collection_rule_id": "dcr-000a00a000a00000a000000aa000a0aa",
"stream_name": "Custom-MyTable"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
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/logs/config/custom-destinations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": false,
"forward_tags": false,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"type": "microsoft_sentinel",
"tenant_id": "f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2",
"client_id": "9a2f4d83-2b5e-429e-a35a-2b3c4182db71",
"data_collection_endpoint": "https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com",
"data_collection_rule_id": "dcr-000a00a000a00000a000000aa000a0aa",
"stream_name": "Custom-MyTable"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"type": "custom_destination"
}
}
EOFCreate a Basic HTTP custom destination returns "OK" response
// Create a Basic HTTP custom destination 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.CustomDestinationCreateRequest{
Data: &datadogV2.CustomDestinationCreateRequestDefinition{
Attributes: datadogV2.CustomDestinationCreateRequestAttributes{
Enabled: datadog.PtrBool(false),
ForwardTags: datadog.PtrBool(false),
ForwardTagsRestrictionList: []string{
"datacenter",
"host",
},
ForwardTagsRestrictionListType: datadogV2.CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST.Ptr(),
ForwarderDestination: datadogV2.CustomDestinationForwardDestination{
CustomDestinationForwardDestinationHttp: &datadogV2.CustomDestinationForwardDestinationHttp{
Auth: datadogV2.CustomDestinationHttpDestinationAuth{
CustomDestinationHttpDestinationAuthBasic: &datadogV2.CustomDestinationHttpDestinationAuthBasic{
Password: "datadog-custom-destination-password",
Type: datadogV2.CUSTOMDESTINATIONHTTPDESTINATIONAUTHBASICTYPE_BASIC,
Username: "datadog-custom-destination-username",
}},
Endpoint: "https://example.com",
Type: datadogV2.CUSTOMDESTINATIONFORWARDDESTINATIONHTTPTYPE_HTTP,
}},
Name: "Nginx logs",
Query: datadog.PtrString("source:nginx"),
},
Type: datadogV2.CUSTOMDESTINATIONTYPE_CUSTOM_DESTINATION,
},
}
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.NewLogsCustomDestinationsApi(apiClient)
resp, r, err := api.CreateLogsCustomDestination(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `LogsCustomDestinationsApi.CreateLogsCustomDestination`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `LogsCustomDestinationsApi.CreateLogsCustomDestination`:\n%s\n", responseContent)
}
Create a Custom Header HTTP custom destination returns "OK" response
// Create a Custom Header HTTP custom destination 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.CustomDestinationCreateRequest{
Data: &datadogV2.CustomDestinationCreateRequestDefinition{
Attributes: datadogV2.CustomDestinationCreateRequestAttributes{
Enabled: datadog.PtrBool(false),
ForwardTags: datadog.PtrBool(false),
ForwardTagsRestrictionList: []string{
"datacenter",
"host",
},
ForwardTagsRestrictionListType: datadogV2.CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST.Ptr(),
ForwarderDestination: datadogV2.CustomDestinationForwardDestination{
CustomDestinationForwardDestinationHttp: &datadogV2.CustomDestinationForwardDestinationHttp{
Auth: datadogV2.CustomDestinationHttpDestinationAuth{
CustomDestinationHttpDestinationAuthCustomHeader: &datadogV2.CustomDestinationHttpDestinationAuthCustomHeader{
HeaderValue: "my-secret",
Type: datadogV2.CUSTOMDESTINATIONHTTPDESTINATIONAUTHCUSTOMHEADERTYPE_CUSTOM_HEADER,
HeaderName: "MY-AUTHENTICATION-HEADER",
}},
Endpoint: "https://example.com",
Type: datadogV2.CUSTOMDESTINATIONFORWARDDESTINATIONHTTPTYPE_HTTP,
}},
Name: "Nginx logs",
Query: datadog.PtrString("source:nginx"),
},
Type: datadogV2.CUSTOMDESTINATIONTYPE_CUSTOM_DESTINATION,
},
}
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.NewLogsCustomDestinationsApi(apiClient)
resp, r, err := api.CreateLogsCustomDestination(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `LogsCustomDestinationsApi.CreateLogsCustomDestination`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `LogsCustomDestinationsApi.CreateLogsCustomDestination`:\n%s\n", responseContent)
}
Create a Microsoft Sentinel custom destination returns "OK" response
// Create a Microsoft Sentinel custom destination 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.CustomDestinationCreateRequest{
Data: &datadogV2.CustomDestinationCreateRequestDefinition{
Attributes: datadogV2.CustomDestinationCreateRequestAttributes{
Enabled: datadog.PtrBool(false),
ForwardTags: datadog.PtrBool(false),
ForwardTagsRestrictionList: []string{
"datacenter",
"host",
},
ForwardTagsRestrictionListType: datadogV2.CUSTOMDESTINATIONATTRIBUTETAGSRESTRICTIONLISTTYPE_ALLOW_LIST.Ptr(),
ForwarderDestination: datadogV2.CustomDestinationForwardDestination{
CustomDestinationForwardDestinationMicrosoftSentinel: &datadogV2.CustomDestinationForwardDestinationMicrosoftSentinel{
Type: datadogV2.CUSTOMDESTINATIONFORWARDDESTINATIONMICROSOFTSENTINELTYPE_MICROSOFT_SENTINEL,
TenantId: "f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2",
ClientId: "9a2f4d83-2b5e-429e-a35a-2b3c4182db71",
DataCollectionEndpoint: "https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com",
DataCollectionRuleId: "dcr-000a00a000a00000a000000aa000a0aa",
StreamName: "Custom-MyTable",
}},
Name: "Nginx logs",
Query: datadog.PtrString("source:nginx"),
},
Type: datadogV2.CUSTOMDESTINATIONTYPE_CUSTOM_DESTINATION,
},
}
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.NewLogsCustomDestinationsApi(apiClient)
resp, r, err := api.CreateLogsCustomDestination(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `LogsCustomDestinationsApi.CreateLogsCustomDestination`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `LogsCustomDestinationsApi.CreateLogsCustomDestination`:\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 Basic HTTP custom destination returns "OK" response
// Create a Basic HTTP custom destination returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.LogsCustomDestinationsApi;
import com.datadog.api.client.v2.model.CustomDestinationAttributeTagsRestrictionListType;
import com.datadog.api.client.v2.model.CustomDestinationCreateRequest;
import com.datadog.api.client.v2.model.CustomDestinationCreateRequestAttributes;
import com.datadog.api.client.v2.model.CustomDestinationCreateRequestDefinition;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestination;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationHttp;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationHttpType;
import com.datadog.api.client.v2.model.CustomDestinationHttpDestinationAuth;
import com.datadog.api.client.v2.model.CustomDestinationHttpDestinationAuthBasic;
import com.datadog.api.client.v2.model.CustomDestinationHttpDestinationAuthBasicType;
import com.datadog.api.client.v2.model.CustomDestinationResponse;
import com.datadog.api.client.v2.model.CustomDestinationType;
import java.util.Arrays;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
LogsCustomDestinationsApi apiInstance = new LogsCustomDestinationsApi(defaultClient);
CustomDestinationCreateRequest body =
new CustomDestinationCreateRequest()
.data(
new CustomDestinationCreateRequestDefinition()
.attributes(
new CustomDestinationCreateRequestAttributes()
.enabled(false)
.forwardTags(false)
.forwardTagsRestrictionList(Arrays.asList("datacenter", "host"))
.forwardTagsRestrictionListType(
CustomDestinationAttributeTagsRestrictionListType.ALLOW_LIST)
.forwarderDestination(
new CustomDestinationForwardDestination(
new CustomDestinationForwardDestinationHttp()
.auth(
new CustomDestinationHttpDestinationAuth(
new CustomDestinationHttpDestinationAuthBasic()
.password("datadog-custom-destination-password")
.type(
CustomDestinationHttpDestinationAuthBasicType
.BASIC)
.username(
"datadog-custom-destination-username")))
.endpoint("https://example.com")
.type(CustomDestinationForwardDestinationHttpType.HTTP)))
.name("Nginx logs")
.query("source:nginx"))
.type(CustomDestinationType.CUSTOM_DESTINATION));
try {
CustomDestinationResponse result = apiInstance.createLogsCustomDestination(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling LogsCustomDestinationsApi#createLogsCustomDestination");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Create a Custom Header HTTP custom destination returns "OK" response
// Create a Custom Header HTTP custom destination returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.LogsCustomDestinationsApi;
import com.datadog.api.client.v2.model.CustomDestinationAttributeTagsRestrictionListType;
import com.datadog.api.client.v2.model.CustomDestinationCreateRequest;
import com.datadog.api.client.v2.model.CustomDestinationCreateRequestAttributes;
import com.datadog.api.client.v2.model.CustomDestinationCreateRequestDefinition;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestination;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationHttp;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationHttpType;
import com.datadog.api.client.v2.model.CustomDestinationHttpDestinationAuth;
import com.datadog.api.client.v2.model.CustomDestinationHttpDestinationAuthCustomHeader;
import com.datadog.api.client.v2.model.CustomDestinationHttpDestinationAuthCustomHeaderType;
import com.datadog.api.client.v2.model.CustomDestinationResponse;
import com.datadog.api.client.v2.model.CustomDestinationType;
import java.util.Arrays;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
LogsCustomDestinationsApi apiInstance = new LogsCustomDestinationsApi(defaultClient);
CustomDestinationCreateRequest body =
new CustomDestinationCreateRequest()
.data(
new CustomDestinationCreateRequestDefinition()
.attributes(
new CustomDestinationCreateRequestAttributes()
.enabled(false)
.forwardTags(false)
.forwardTagsRestrictionList(Arrays.asList("datacenter", "host"))
.forwardTagsRestrictionListType(
CustomDestinationAttributeTagsRestrictionListType.ALLOW_LIST)
.forwarderDestination(
new CustomDestinationForwardDestination(
new CustomDestinationForwardDestinationHttp()
.auth(
new CustomDestinationHttpDestinationAuth(
new CustomDestinationHttpDestinationAuthCustomHeader()
.headerValue("my-secret")
.type(
CustomDestinationHttpDestinationAuthCustomHeaderType
.CUSTOM_HEADER)
.headerName("MY-AUTHENTICATION-HEADER")))
.endpoint("https://example.com")
.type(CustomDestinationForwardDestinationHttpType.HTTP)))
.name("Nginx logs")
.query("source:nginx"))
.type(CustomDestinationType.CUSTOM_DESTINATION));
try {
CustomDestinationResponse result = apiInstance.createLogsCustomDestination(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling LogsCustomDestinationsApi#createLogsCustomDestination");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Create a Microsoft Sentinel custom destination returns "OK" response
// Create a Microsoft Sentinel custom destination returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.LogsCustomDestinationsApi;
import com.datadog.api.client.v2.model.CustomDestinationAttributeTagsRestrictionListType;
import com.datadog.api.client.v2.model.CustomDestinationCreateRequest;
import com.datadog.api.client.v2.model.CustomDestinationCreateRequestAttributes;
import com.datadog.api.client.v2.model.CustomDestinationCreateRequestDefinition;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestination;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationMicrosoftSentinel;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationMicrosoftSentinelType;
import com.datadog.api.client.v2.model.CustomDestinationResponse;
import com.datadog.api.client.v2.model.CustomDestinationType;
import java.util.Arrays;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
LogsCustomDestinationsApi apiInstance = new LogsCustomDestinationsApi(defaultClient);
CustomDestinationCreateRequest body =
new CustomDestinationCreateRequest()
.data(
new CustomDestinationCreateRequestDefinition()
.attributes(
new CustomDestinationCreateRequestAttributes()
.enabled(false)
.forwardTags(false)
.forwardTagsRestrictionList(Arrays.asList("datacenter", "host"))
.forwardTagsRestrictionListType(
CustomDestinationAttributeTagsRestrictionListType.ALLOW_LIST)
.forwarderDestination(
new CustomDestinationForwardDestination(
new CustomDestinationForwardDestinationMicrosoftSentinel()
.type(
CustomDestinationForwardDestinationMicrosoftSentinelType
.MICROSOFT_SENTINEL)
.tenantId("f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2")
.clientId("9a2f4d83-2b5e-429e-a35a-2b3c4182db71")
.dataCollectionEndpoint(
"https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com")
.dataCollectionRuleId(
"dcr-000a00a000a00000a000000aa000a0aa")
.streamName("Custom-MyTable")))
.name("Nginx logs")
.query("source:nginx"))
.type(CustomDestinationType.CUSTOM_DESTINATION));
try {
CustomDestinationResponse result = apiInstance.createLogsCustomDestination(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling LogsCustomDestinationsApi#createLogsCustomDestination");
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 Basic HTTP custom destination returns "OK" response
"""
Create a Basic HTTP custom destination returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.logs_custom_destinations_api import LogsCustomDestinationsApi
from datadog_api_client.v2.model.custom_destination_attribute_tags_restriction_list_type import (
CustomDestinationAttributeTagsRestrictionListType,
)
from datadog_api_client.v2.model.custom_destination_create_request import CustomDestinationCreateRequest
from datadog_api_client.v2.model.custom_destination_create_request_attributes import (
CustomDestinationCreateRequestAttributes,
)
from datadog_api_client.v2.model.custom_destination_create_request_definition import (
CustomDestinationCreateRequestDefinition,
)
from datadog_api_client.v2.model.custom_destination_forward_destination_http import (
CustomDestinationForwardDestinationHttp,
)
from datadog_api_client.v2.model.custom_destination_forward_destination_http_type import (
CustomDestinationForwardDestinationHttpType,
)
from datadog_api_client.v2.model.custom_destination_http_destination_auth_basic import (
CustomDestinationHttpDestinationAuthBasic,
)
from datadog_api_client.v2.model.custom_destination_http_destination_auth_basic_type import (
CustomDestinationHttpDestinationAuthBasicType,
)
from datadog_api_client.v2.model.custom_destination_type import CustomDestinationType
body = CustomDestinationCreateRequest(
data=CustomDestinationCreateRequestDefinition(
attributes=CustomDestinationCreateRequestAttributes(
enabled=False,
forward_tags=False,
forward_tags_restriction_list=[
"datacenter",
"host",
],
forward_tags_restriction_list_type=CustomDestinationAttributeTagsRestrictionListType.ALLOW_LIST,
forwarder_destination=CustomDestinationForwardDestinationHttp(
auth=CustomDestinationHttpDestinationAuthBasic(
password="datadog-custom-destination-password",
type=CustomDestinationHttpDestinationAuthBasicType.BASIC,
username="datadog-custom-destination-username",
),
endpoint="https://example.com",
type=CustomDestinationForwardDestinationHttpType.HTTP,
),
name="Nginx logs",
query="source:nginx",
),
type=CustomDestinationType.CUSTOM_DESTINATION,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = LogsCustomDestinationsApi(api_client)
response = api_instance.create_logs_custom_destination(body=body)
print(response)
Create a Custom Header HTTP custom destination returns "OK" response
"""
Create a Custom Header HTTP custom destination returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.logs_custom_destinations_api import LogsCustomDestinationsApi
from datadog_api_client.v2.model.custom_destination_attribute_tags_restriction_list_type import (
CustomDestinationAttributeTagsRestrictionListType,
)
from datadog_api_client.v2.model.custom_destination_create_request import CustomDestinationCreateRequest
from datadog_api_client.v2.model.custom_destination_create_request_attributes import (
CustomDestinationCreateRequestAttributes,
)
from datadog_api_client.v2.model.custom_destination_create_request_definition import (
CustomDestinationCreateRequestDefinition,
)
from datadog_api_client.v2.model.custom_destination_forward_destination_http import (
CustomDestinationForwardDestinationHttp,
)
from datadog_api_client.v2.model.custom_destination_forward_destination_http_type import (
CustomDestinationForwardDestinationHttpType,
)
from datadog_api_client.v2.model.custom_destination_http_destination_auth_custom_header import (
CustomDestinationHttpDestinationAuthCustomHeader,
)
from datadog_api_client.v2.model.custom_destination_http_destination_auth_custom_header_type import (
CustomDestinationHttpDestinationAuthCustomHeaderType,
)
from datadog_api_client.v2.model.custom_destination_type import CustomDestinationType
body = CustomDestinationCreateRequest(
data=CustomDestinationCreateRequestDefinition(
attributes=CustomDestinationCreateRequestAttributes(
enabled=False,
forward_tags=False,
forward_tags_restriction_list=[
"datacenter",
"host",
],
forward_tags_restriction_list_type=CustomDestinationAttributeTagsRestrictionListType.ALLOW_LIST,
forwarder_destination=CustomDestinationForwardDestinationHttp(
auth=CustomDestinationHttpDestinationAuthCustomHeader(
header_value="my-secret",
type=CustomDestinationHttpDestinationAuthCustomHeaderType.CUSTOM_HEADER,
header_name="MY-AUTHENTICATION-HEADER",
),
endpoint="https://example.com",
type=CustomDestinationForwardDestinationHttpType.HTTP,
),
name="Nginx logs",
query="source:nginx",
),
type=CustomDestinationType.CUSTOM_DESTINATION,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = LogsCustomDestinationsApi(api_client)
response = api_instance.create_logs_custom_destination(body=body)
print(response)
Create a Microsoft Sentinel custom destination returns "OK" response
"""
Create a Microsoft Sentinel custom destination returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.logs_custom_destinations_api import LogsCustomDestinationsApi
from datadog_api_client.v2.model.custom_destination_attribute_tags_restriction_list_type import (
CustomDestinationAttributeTagsRestrictionListType,
)
from datadog_api_client.v2.model.custom_destination_create_request import CustomDestinationCreateRequest
from datadog_api_client.v2.model.custom_destination_create_request_attributes import (
CustomDestinationCreateRequestAttributes,
)
from datadog_api_client.v2.model.custom_destination_create_request_definition import (
CustomDestinationCreateRequestDefinition,
)
from datadog_api_client.v2.model.custom_destination_forward_destination_microsoft_sentinel import (
CustomDestinationForwardDestinationMicrosoftSentinel,
)
from datadog_api_client.v2.model.custom_destination_forward_destination_microsoft_sentinel_type import (
CustomDestinationForwardDestinationMicrosoftSentinelType,
)
from datadog_api_client.v2.model.custom_destination_type import CustomDestinationType
body = CustomDestinationCreateRequest(
data=CustomDestinationCreateRequestDefinition(
attributes=CustomDestinationCreateRequestAttributes(
enabled=False,
forward_tags=False,
forward_tags_restriction_list=[
"datacenter",
"host",
],
forward_tags_restriction_list_type=CustomDestinationAttributeTagsRestrictionListType.ALLOW_LIST,
forwarder_destination=CustomDestinationForwardDestinationMicrosoftSentinel(
type=CustomDestinationForwardDestinationMicrosoftSentinelType.MICROSOFT_SENTINEL,
tenant_id="f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2",
client_id="9a2f4d83-2b5e-429e-a35a-2b3c4182db71",
data_collection_endpoint="https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com",
data_collection_rule_id="dcr-000a00a000a00000a000000aa000a0aa",
stream_name="Custom-MyTable",
),
name="Nginx logs",
query="source:nginx",
),
type=CustomDestinationType.CUSTOM_DESTINATION,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = LogsCustomDestinationsApi(api_client)
response = api_instance.create_logs_custom_destination(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 Basic HTTP custom destination returns "OK" response
# Create a Basic HTTP custom destination returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::LogsCustomDestinationsAPI.new
body = DatadogAPIClient::V2::CustomDestinationCreateRequest.new({
data: DatadogAPIClient::V2::CustomDestinationCreateRequestDefinition.new({
attributes: DatadogAPIClient::V2::CustomDestinationCreateRequestAttributes.new({
enabled: false,
forward_tags: false,
forward_tags_restriction_list: [
"datacenter",
"host",
],
forward_tags_restriction_list_type: DatadogAPIClient::V2::CustomDestinationAttributeTagsRestrictionListType::ALLOW_LIST,
forwarder_destination: DatadogAPIClient::V2::CustomDestinationForwardDestinationHttp.new({
auth: DatadogAPIClient::V2::CustomDestinationHttpDestinationAuthBasic.new({
password: "datadog-custom-destination-password",
type: DatadogAPIClient::V2::CustomDestinationHttpDestinationAuthBasicType::BASIC,
username: "datadog-custom-destination-username",
}),
endpoint: "https://example.com",
type: DatadogAPIClient::V2::CustomDestinationForwardDestinationHttpType::HTTP,
}),
name: "Nginx logs",
query: "source:nginx",
}),
type: DatadogAPIClient::V2::CustomDestinationType::CUSTOM_DESTINATION,
}),
})
p api_instance.create_logs_custom_destination(body)
Create a Custom Header HTTP custom destination returns "OK" response
# Create a Custom Header HTTP custom destination returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::LogsCustomDestinationsAPI.new
body = DatadogAPIClient::V2::CustomDestinationCreateRequest.new({
data: DatadogAPIClient::V2::CustomDestinationCreateRequestDefinition.new({
attributes: DatadogAPIClient::V2::CustomDestinationCreateRequestAttributes.new({
enabled: false,
forward_tags: false,
forward_tags_restriction_list: [
"datacenter",
"host",
],
forward_tags_restriction_list_type: DatadogAPIClient::V2::CustomDestinationAttributeTagsRestrictionListType::ALLOW_LIST,
forwarder_destination: DatadogAPIClient::V2::CustomDestinationForwardDestinationHttp.new({
auth: DatadogAPIClient::V2::CustomDestinationHttpDestinationAuthCustomHeader.new({
header_value: "my-secret",
type: DatadogAPIClient::V2::CustomDestinationHttpDestinationAuthCustomHeaderType::CUSTOM_HEADER,
header_name: "MY-AUTHENTICATION-HEADER",
}),
endpoint: "https://example.com",
type: DatadogAPIClient::V2::CustomDestinationForwardDestinationHttpType::HTTP,
}),
name: "Nginx logs",
query: "source:nginx",
}),
type: DatadogAPIClient::V2::CustomDestinationType::CUSTOM_DESTINATION,
}),
})
p api_instance.create_logs_custom_destination(body)
Create a Microsoft Sentinel custom destination returns "OK" response
# Create a Microsoft Sentinel custom destination returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::LogsCustomDestinationsAPI.new
body = DatadogAPIClient::V2::CustomDestinationCreateRequest.new({
data: DatadogAPIClient::V2::CustomDestinationCreateRequestDefinition.new({
attributes: DatadogAPIClient::V2::CustomDestinationCreateRequestAttributes.new({
enabled: false,
forward_tags: false,
forward_tags_restriction_list: [
"datacenter",
"host",
],
forward_tags_restriction_list_type: DatadogAPIClient::V2::CustomDestinationAttributeTagsRestrictionListType::ALLOW_LIST,
forwarder_destination: DatadogAPIClient::V2::CustomDestinationForwardDestinationMicrosoftSentinel.new({
type: DatadogAPIClient::V2::CustomDestinationForwardDestinationMicrosoftSentinelType::MICROSOFT_SENTINEL,
tenant_id: "f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2",
client_id: "9a2f4d83-2b5e-429e-a35a-2b3c4182db71",
data_collection_endpoint: "https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com",
data_collection_rule_id: "dcr-000a00a000a00000a000000aa000a0aa",
stream_name: "Custom-MyTable",
}),
name: "Nginx logs",
query: "source:nginx",
}),
type: DatadogAPIClient::V2::CustomDestinationType::CUSTOM_DESTINATION,
}),
})
p api_instance.create_logs_custom_destination(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 Basic HTTP custom destination returns "OK" response
// Create a Basic HTTP custom destination returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_logs_custom_destinations::LogsCustomDestinationsAPI;
use datadog_api_client::datadogV2::model::CustomDestinationAttributeTagsRestrictionListType;
use datadog_api_client::datadogV2::model::CustomDestinationCreateRequest;
use datadog_api_client::datadogV2::model::CustomDestinationCreateRequestAttributes;
use datadog_api_client::datadogV2::model::CustomDestinationCreateRequestDefinition;
use datadog_api_client::datadogV2::model::CustomDestinationForwardDestination;
use datadog_api_client::datadogV2::model::CustomDestinationForwardDestinationHttp;
use datadog_api_client::datadogV2::model::CustomDestinationForwardDestinationHttpType;
use datadog_api_client::datadogV2::model::CustomDestinationHttpDestinationAuth;
use datadog_api_client::datadogV2::model::CustomDestinationHttpDestinationAuthBasic;
use datadog_api_client::datadogV2::model::CustomDestinationHttpDestinationAuthBasicType;
use datadog_api_client::datadogV2::model::CustomDestinationType;
#[tokio::main]
async fn main() {
let body = CustomDestinationCreateRequest::new()
.data(CustomDestinationCreateRequestDefinition::new(
CustomDestinationCreateRequestAttributes::new(
CustomDestinationForwardDestination::CustomDestinationForwardDestinationHttp(Box::new(
CustomDestinationForwardDestinationHttp::new(
CustomDestinationHttpDestinationAuth::CustomDestinationHttpDestinationAuthBasic(
Box::new(CustomDestinationHttpDestinationAuthBasic::new(
"datadog-custom-destination-password".to_string(),
CustomDestinationHttpDestinationAuthBasicType::BASIC,
"datadog-custom-destination-username".to_string(),
)),
),
"https://example.com".to_string(),
CustomDestinationForwardDestinationHttpType::HTTP,
),
)),
"Nginx logs".to_string(),
)
.enabled(false)
.forward_tags(false)
.forward_tags_restriction_list(vec!["datacenter".to_string(), "host".to_string()])
.forward_tags_restriction_list_type(
CustomDestinationAttributeTagsRestrictionListType::ALLOW_LIST,
)
.query("source:nginx".to_string()),
CustomDestinationType::CUSTOM_DESTINATION,
));
let configuration = datadog::Configuration::new();
let api = LogsCustomDestinationsAPI::with_config(configuration);
let resp = api.create_logs_custom_destination(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Create a Custom Header HTTP custom destination returns "OK" response
// Create a Custom Header HTTP custom destination returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_logs_custom_destinations::LogsCustomDestinationsAPI;
use datadog_api_client::datadogV2::model::CustomDestinationAttributeTagsRestrictionListType;
use datadog_api_client::datadogV2::model::CustomDestinationCreateRequest;
use datadog_api_client::datadogV2::model::CustomDestinationCreateRequestAttributes;
use datadog_api_client::datadogV2::model::CustomDestinationCreateRequestDefinition;
use datadog_api_client::datadogV2::model::CustomDestinationForwardDestination;
use datadog_api_client::datadogV2::model::CustomDestinationForwardDestinationHttp;
use datadog_api_client::datadogV2::model::CustomDestinationForwardDestinationHttpType;
use datadog_api_client::datadogV2::model::CustomDestinationHttpDestinationAuth;
use datadog_api_client::datadogV2::model::CustomDestinationHttpDestinationAuthCustomHeader;
use datadog_api_client::datadogV2::model::CustomDestinationHttpDestinationAuthCustomHeaderType;
use datadog_api_client::datadogV2::model::CustomDestinationType;
#[tokio::main]
async fn main() {
let body =
CustomDestinationCreateRequest
::new().data(
CustomDestinationCreateRequestDefinition::new(
CustomDestinationCreateRequestAttributes::new(
CustomDestinationForwardDestination::CustomDestinationForwardDestinationHttp(
Box::new(
CustomDestinationForwardDestinationHttp::new(
CustomDestinationHttpDestinationAuth::CustomDestinationHttpDestinationAuthCustomHeader(
Box::new(
CustomDestinationHttpDestinationAuthCustomHeader::new(
"MY-AUTHENTICATION-HEADER".to_string(),
"my-secret".to_string(),
CustomDestinationHttpDestinationAuthCustomHeaderType::CUSTOM_HEADER,
),
),
),
"https://example.com".to_string(),
CustomDestinationForwardDestinationHttpType::HTTP,
),
),
),
"Nginx logs".to_string(),
)
.enabled(false)
.forward_tags(false)
.forward_tags_restriction_list(vec!["datacenter".to_string(), "host".to_string()])
.forward_tags_restriction_list_type(CustomDestinationAttributeTagsRestrictionListType::ALLOW_LIST)
.query("source:nginx".to_string()),
CustomDestinationType::CUSTOM_DESTINATION,
),
);
let configuration = datadog::Configuration::new();
let api = LogsCustomDestinationsAPI::with_config(configuration);
let resp = api.create_logs_custom_destination(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Create a Microsoft Sentinel custom destination returns "OK" response
// Create a Microsoft Sentinel custom destination returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_logs_custom_destinations::LogsCustomDestinationsAPI;
use datadog_api_client::datadogV2::model::CustomDestinationAttributeTagsRestrictionListType;
use datadog_api_client::datadogV2::model::CustomDestinationCreateRequest;
use datadog_api_client::datadogV2::model::CustomDestinationCreateRequestAttributes;
use datadog_api_client::datadogV2::model::CustomDestinationCreateRequestDefinition;
use datadog_api_client::datadogV2::model::CustomDestinationForwardDestination;
use datadog_api_client::datadogV2::model::CustomDestinationForwardDestinationMicrosoftSentinel;
use datadog_api_client::datadogV2::model::CustomDestinationForwardDestinationMicrosoftSentinelType;
use datadog_api_client::datadogV2::model::CustomDestinationType;
#[tokio::main]
async fn main() {
let body =
CustomDestinationCreateRequest
::new().data(
CustomDestinationCreateRequestDefinition::new(
CustomDestinationCreateRequestAttributes::new(
CustomDestinationForwardDestination::CustomDestinationForwardDestinationMicrosoftSentinel(
Box::new(
CustomDestinationForwardDestinationMicrosoftSentinel::new(
"9a2f4d83-2b5e-429e-a35a-2b3c4182db71".to_string(),
"https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com".to_string(),
"dcr-000a00a000a00000a000000aa000a0aa".to_string(),
"Custom-MyTable".to_string(),
"f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2".to_string(),
CustomDestinationForwardDestinationMicrosoftSentinelType::MICROSOFT_SENTINEL,
),
),
),
"Nginx logs".to_string(),
)
.enabled(false)
.forward_tags(false)
.forward_tags_restriction_list(vec!["datacenter".to_string(), "host".to_string()])
.forward_tags_restriction_list_type(CustomDestinationAttributeTagsRestrictionListType::ALLOW_LIST)
.query("source:nginx".to_string()),
CustomDestinationType::CUSTOM_DESTINATION,
),
);
let configuration = datadog::Configuration::new();
let api = LogsCustomDestinationsAPI::with_config(configuration);
let resp = api.create_logs_custom_destination(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 runCreate a Basic HTTP custom destination returns "OK" response
/**
* Create a Basic HTTP custom destination 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.LogsCustomDestinationsApi(configuration);
const params: v2.LogsCustomDestinationsApiCreateLogsCustomDestinationRequest = {
body: {
data: {
attributes: {
enabled: false,
forwardTags: false,
forwardTagsRestrictionList: ["datacenter", "host"],
forwardTagsRestrictionListType: "ALLOW_LIST",
forwarderDestination: {
auth: {
password: "datadog-custom-destination-password",
type: "basic",
username: "datadog-custom-destination-username",
},
endpoint: "https://example.com",
type: "http",
},
name: "Nginx logs",
query: "source:nginx",
},
type: "custom_destination",
},
},
};
apiInstance
.createLogsCustomDestination(params)
.then((data: v2.CustomDestinationResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Create a Custom Header HTTP custom destination returns "OK" response
/**
* Create a Custom Header HTTP custom destination 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.LogsCustomDestinationsApi(configuration);
const params: v2.LogsCustomDestinationsApiCreateLogsCustomDestinationRequest = {
body: {
data: {
attributes: {
enabled: false,
forwardTags: false,
forwardTagsRestrictionList: ["datacenter", "host"],
forwardTagsRestrictionListType: "ALLOW_LIST",
forwarderDestination: {
auth: {
headerValue: "my-secret",
type: "custom_header",
headerName: "MY-AUTHENTICATION-HEADER",
},
endpoint: "https://example.com",
type: "http",
},
name: "Nginx logs",
query: "source:nginx",
},
type: "custom_destination",
},
},
};
apiInstance
.createLogsCustomDestination(params)
.then((data: v2.CustomDestinationResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Create a Microsoft Sentinel custom destination returns "OK" response
/**
* Create a Microsoft Sentinel custom destination 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.LogsCustomDestinationsApi(configuration);
const params: v2.LogsCustomDestinationsApiCreateLogsCustomDestinationRequest = {
body: {
data: {
attributes: {
enabled: false,
forwardTags: false,
forwardTagsRestrictionList: ["datacenter", "host"],
forwardTagsRestrictionListType: "ALLOW_LIST",
forwarderDestination: {
type: "microsoft_sentinel",
tenantId: "f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2",
clientId: "9a2f4d83-2b5e-429e-a35a-2b3c4182db71",
dataCollectionEndpoint:
"https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com",
dataCollectionRuleId: "dcr-000a00a000a00000a000000aa000a0aa",
streamName: "Custom-MyTable",
},
name: "Nginx logs",
query: "source:nginx",
},
type: "custom_destination",
},
},
};
apiInstance
.createLogsCustomDestination(params)
.then((data: v2.CustomDestinationResponse) => {
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"