Update a custom destination
https://api.datadoghq.com/api/v2/logs/config/custom-destinations/{custom_destination_id}https://api.us3.datadoghq.com/api/v2/logs/config/custom-destinations/{custom_destination_id}https://api.us5.datadoghq.com/api/v2/logs/config/custom-destinations/{custom_destination_id}https://api.datadoghq.eu/api/v2/logs/config/custom-destinations/{custom_destination_id}https://api.ap1.datadoghq.com/api/v2/logs/config/custom-destinations/{custom_destination_id}https://api.ap2.datadoghq.com/api/v2/logs/config/custom-destinations/{custom_destination_id}https://api.uk1.datadoghq.com/api/v2/logs/config/custom-destinations/{custom_destination_id}https://api.ddog-gov.com/api/v2/logs/config/custom-destinations/{custom_destination_id}https://api.us2.ddog-gov.com/api/v2/logs/config/custom-destinations/{custom_destination_id}Overview
Update the given fields of a specific custom destination in your organization.
Arguments
Path Parameters
custom_destination_id [required]The ID of the custom destination.
Request
Body Data (required)
New definition of the custom destination's fields.
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 restricted from being forwarded.
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.
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_sentinelnameThe custom destination name.
queryThe custom destination query and filter. Logs matching this query are forwarded to the destination.
""id [required]The custom destination ID.
type [required]The 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": {
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"id": "be5d7a69-d0c8-4d4d-8ee8-bba292d98139",
"type": "custom_destination"
}
}Response
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"
]
}Not Found
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"
]
}Code Example
# Path parameters
export custom_destination_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/logs/config/custom-destinations/${custom_destination_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": true,
"forward_tags": true,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"id": "be5d7a69-d0c8-4d4d-8ee8-bba292d98139",
"type": "custom_destination"
}
}
EOF# Path parameters
export custom_destination_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/logs/config/custom-destinations/${custom_destination_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": true,
"forward_tags": true,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"id": "be5d7a69-d0c8-4d4d-8ee8-bba292d98139",
"type": "custom_destination"
}
}
EOF# Path parameters
export custom_destination_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/logs/config/custom-destinations/${custom_destination_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": true,
"forward_tags": true,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"id": "be5d7a69-d0c8-4d4d-8ee8-bba292d98139",
"type": "custom_destination"
}
}
EOF# Path parameters
export custom_destination_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/logs/config/custom-destinations/${custom_destination_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": true,
"forward_tags": true,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"id": "be5d7a69-d0c8-4d4d-8ee8-bba292d98139",
"type": "custom_destination"
}
}
EOF# Path parameters
export custom_destination_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/logs/config/custom-destinations/${custom_destination_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": true,
"forward_tags": true,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"id": "be5d7a69-d0c8-4d4d-8ee8-bba292d98139",
"type": "custom_destination"
}
}
EOF# Path parameters
export custom_destination_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/logs/config/custom-destinations/${custom_destination_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": true,
"forward_tags": true,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"id": "be5d7a69-d0c8-4d4d-8ee8-bba292d98139",
"type": "custom_destination"
}
}
EOF# Path parameters
export custom_destination_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/logs/config/custom-destinations/${custom_destination_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": true,
"forward_tags": true,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"id": "be5d7a69-d0c8-4d4d-8ee8-bba292d98139",
"type": "custom_destination"
}
}
EOF# Path parameters
export custom_destination_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/logs/config/custom-destinations/${custom_destination_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": true,
"forward_tags": true,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"id": "be5d7a69-d0c8-4d4d-8ee8-bba292d98139",
"type": "custom_destination"
}
}
EOF# Path parameters
export custom_destination_id="CHANGE_ME"
# 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 PATCH "https://api.${DD_SITE}/api/v2/logs/config/custom-destinations/${custom_destination_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"enabled": true,
"forward_tags": true,
"forward_tags_restriction_list": [
"datacenter",
"host"
],
"forward_tags_restriction_list_type": "ALLOW_LIST",
"forwarder_destination": {
"endpoint": "https://example.com",
"type": "http"
},
"name": "Nginx logs",
"query": "source:nginx"
},
"id": "be5d7a69-d0c8-4d4d-8ee8-bba292d98139",
"type": "custom_destination"
}
}
EOFUpdate a Splunk custom destination with a null sourcetype returns "OK" response
// Update a Splunk custom destination with a null sourcetype 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() {
// there is a valid "custom_destination_splunk_with_sourcetype" in the system
CustomDestinationSplunkWithSourcetypeDataID := os.Getenv("CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID")
body := datadogV2.CustomDestinationUpdateRequest{
Data: &datadogV2.CustomDestinationUpdateRequestDefinition{
Attributes: &datadogV2.CustomDestinationUpdateRequestAttributes{
ForwarderDestination: &datadogV2.CustomDestinationForwardDestination{
CustomDestinationForwardDestinationSplunk: &datadogV2.CustomDestinationForwardDestinationSplunk{
Type: datadogV2.CUSTOMDESTINATIONFORWARDDESTINATIONSPLUNKTYPE_SPLUNK_HEC,
Endpoint: "https://example.com",
AccessToken: "my-access-token",
Sourcetype: *datadog.NewNullableString(nil),
}},
},
Type: datadogV2.CUSTOMDESTINATIONTYPE_CUSTOM_DESTINATION,
Id: CustomDestinationSplunkWithSourcetypeDataID,
},
}
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.UpdateLogsCustomDestination(ctx, CustomDestinationSplunkWithSourcetypeDataID, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `LogsCustomDestinationsApi.UpdateLogsCustomDestination`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `LogsCustomDestinationsApi.UpdateLogsCustomDestination`:\n%s\n", responseContent)
}
Update a Splunk custom destination with a sourcetype returns "OK" response
// Update a Splunk custom destination with a sourcetype 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() {
// there is a valid "custom_destination_splunk" in the system
CustomDestinationSplunkDataID := os.Getenv("CUSTOM_DESTINATION_SPLUNK_DATA_ID")
body := datadogV2.CustomDestinationUpdateRequest{
Data: &datadogV2.CustomDestinationUpdateRequestDefinition{
Attributes: &datadogV2.CustomDestinationUpdateRequestAttributes{
ForwarderDestination: &datadogV2.CustomDestinationForwardDestination{
CustomDestinationForwardDestinationSplunk: &datadogV2.CustomDestinationForwardDestinationSplunk{
Type: datadogV2.CUSTOMDESTINATIONFORWARDDESTINATIONSPLUNKTYPE_SPLUNK_HEC,
Endpoint: "https://example.com",
AccessToken: "my-access-token",
Sourcetype: *datadog.NewNullableString(datadog.PtrString("new-sourcetype")),
}},
},
Type: datadogV2.CUSTOMDESTINATIONTYPE_CUSTOM_DESTINATION,
Id: CustomDestinationSplunkDataID,
},
}
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.UpdateLogsCustomDestination(ctx, CustomDestinationSplunkDataID, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `LogsCustomDestinationsApi.UpdateLogsCustomDestination`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `LogsCustomDestinationsApi.UpdateLogsCustomDestination`:\n%s\n", responseContent)
}
Update a Splunk custom destination's attributes preserves the absent sourcetype returns "OK" response
// Update a Splunk custom destination's attributes preserves the absent sourcetype 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() {
// there is a valid "custom_destination_splunk" in the system
CustomDestinationSplunkDataID := os.Getenv("CUSTOM_DESTINATION_SPLUNK_DATA_ID")
body := datadogV2.CustomDestinationUpdateRequest{
Data: &datadogV2.CustomDestinationUpdateRequestDefinition{
Attributes: &datadogV2.CustomDestinationUpdateRequestAttributes{
Name: datadog.PtrString("Nginx logs (Updated)"),
},
Type: datadogV2.CUSTOMDESTINATIONTYPE_CUSTOM_DESTINATION,
Id: CustomDestinationSplunkDataID,
},
}
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.UpdateLogsCustomDestination(ctx, CustomDestinationSplunkDataID, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `LogsCustomDestinationsApi.UpdateLogsCustomDestination`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `LogsCustomDestinationsApi.UpdateLogsCustomDestination`:\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"Update a Splunk custom destination with a null sourcetype returns "OK" response
// Update a Splunk custom destination with a null sourcetype 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.CustomDestinationForwardDestination;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationSplunk;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationSplunkType;
import com.datadog.api.client.v2.model.CustomDestinationResponse;
import com.datadog.api.client.v2.model.CustomDestinationType;
import com.datadog.api.client.v2.model.CustomDestinationUpdateRequest;
import com.datadog.api.client.v2.model.CustomDestinationUpdateRequestAttributes;
import com.datadog.api.client.v2.model.CustomDestinationUpdateRequestDefinition;
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);
// there is a valid "custom_destination_splunk_with_sourcetype" in the system
String CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID =
System.getenv("CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID");
CustomDestinationUpdateRequest body =
new CustomDestinationUpdateRequest()
.data(
new CustomDestinationUpdateRequestDefinition()
.attributes(
new CustomDestinationUpdateRequestAttributes()
.forwarderDestination(
new CustomDestinationForwardDestination(
new CustomDestinationForwardDestinationSplunk()
.type(
CustomDestinationForwardDestinationSplunkType
.SPLUNK_HEC)
.endpoint("https://example.com")
.accessToken("my-access-token")
.sourcetype(null))))
.type(CustomDestinationType.CUSTOM_DESTINATION)
.id(CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID));
try {
CustomDestinationResponse result =
apiInstance.updateLogsCustomDestination(
CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling LogsCustomDestinationsApi#updateLogsCustomDestination");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Update a Splunk custom destination with a sourcetype returns "OK" response
// Update a Splunk custom destination with a sourcetype 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.CustomDestinationForwardDestination;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationSplunk;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationSplunkType;
import com.datadog.api.client.v2.model.CustomDestinationResponse;
import com.datadog.api.client.v2.model.CustomDestinationType;
import com.datadog.api.client.v2.model.CustomDestinationUpdateRequest;
import com.datadog.api.client.v2.model.CustomDestinationUpdateRequestAttributes;
import com.datadog.api.client.v2.model.CustomDestinationUpdateRequestDefinition;
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);
// there is a valid "custom_destination_splunk" in the system
String CUSTOM_DESTINATION_SPLUNK_DATA_ID = System.getenv("CUSTOM_DESTINATION_SPLUNK_DATA_ID");
CustomDestinationUpdateRequest body =
new CustomDestinationUpdateRequest()
.data(
new CustomDestinationUpdateRequestDefinition()
.attributes(
new CustomDestinationUpdateRequestAttributes()
.forwarderDestination(
new CustomDestinationForwardDestination(
new CustomDestinationForwardDestinationSplunk()
.type(
CustomDestinationForwardDestinationSplunkType
.SPLUNK_HEC)
.endpoint("https://example.com")
.accessToken("my-access-token")
.sourcetype("new-sourcetype"))))
.type(CustomDestinationType.CUSTOM_DESTINATION)
.id(CUSTOM_DESTINATION_SPLUNK_DATA_ID));
try {
CustomDestinationResponse result =
apiInstance.updateLogsCustomDestination(CUSTOM_DESTINATION_SPLUNK_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling LogsCustomDestinationsApi#updateLogsCustomDestination");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Update a Splunk custom destination's attributes preserves the absent sourcetype returns "OK" response
// Update a Splunk custom destination's attributes preserves the absent sourcetype 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.CustomDestinationResponse;
import com.datadog.api.client.v2.model.CustomDestinationType;
import com.datadog.api.client.v2.model.CustomDestinationUpdateRequest;
import com.datadog.api.client.v2.model.CustomDestinationUpdateRequestAttributes;
import com.datadog.api.client.v2.model.CustomDestinationUpdateRequestDefinition;
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);
// there is a valid "custom_destination_splunk" in the system
String CUSTOM_DESTINATION_SPLUNK_DATA_ID = System.getenv("CUSTOM_DESTINATION_SPLUNK_DATA_ID");
CustomDestinationUpdateRequest body =
new CustomDestinationUpdateRequest()
.data(
new CustomDestinationUpdateRequestDefinition()
.attributes(
new CustomDestinationUpdateRequestAttributes().name("Nginx logs (Updated)"))
.type(CustomDestinationType.CUSTOM_DESTINATION)
.id(CUSTOM_DESTINATION_SPLUNK_DATA_ID));
try {
CustomDestinationResponse result =
apiInstance.updateLogsCustomDestination(CUSTOM_DESTINATION_SPLUNK_DATA_ID, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling LogsCustomDestinationsApi#updateLogsCustomDestination");
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"Update a Splunk custom destination with a null sourcetype returns "OK" response
"""
Update a Splunk custom destination with a null sourcetype 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_forward_destination_splunk import (
CustomDestinationForwardDestinationSplunk,
)
from datadog_api_client.v2.model.custom_destination_forward_destination_splunk_type import (
CustomDestinationForwardDestinationSplunkType,
)
from datadog_api_client.v2.model.custom_destination_type import CustomDestinationType
from datadog_api_client.v2.model.custom_destination_update_request import CustomDestinationUpdateRequest
from datadog_api_client.v2.model.custom_destination_update_request_attributes import (
CustomDestinationUpdateRequestAttributes,
)
from datadog_api_client.v2.model.custom_destination_update_request_definition import (
CustomDestinationUpdateRequestDefinition,
)
# there is a valid "custom_destination_splunk_with_sourcetype" in the system
CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID = environ["CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID"]
body = CustomDestinationUpdateRequest(
data=CustomDestinationUpdateRequestDefinition(
attributes=CustomDestinationUpdateRequestAttributes(
forwarder_destination=CustomDestinationForwardDestinationSplunk(
type=CustomDestinationForwardDestinationSplunkType.SPLUNK_HEC,
endpoint="https://example.com",
access_token="my-access-token",
sourcetype=None,
),
),
type=CustomDestinationType.CUSTOM_DESTINATION,
id=CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = LogsCustomDestinationsApi(api_client)
response = api_instance.update_logs_custom_destination(
custom_destination_id=CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID, body=body
)
print(response)
Update a Splunk custom destination with a sourcetype returns "OK" response
"""
Update a Splunk custom destination with a sourcetype 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_forward_destination_splunk import (
CustomDestinationForwardDestinationSplunk,
)
from datadog_api_client.v2.model.custom_destination_forward_destination_splunk_type import (
CustomDestinationForwardDestinationSplunkType,
)
from datadog_api_client.v2.model.custom_destination_type import CustomDestinationType
from datadog_api_client.v2.model.custom_destination_update_request import CustomDestinationUpdateRequest
from datadog_api_client.v2.model.custom_destination_update_request_attributes import (
CustomDestinationUpdateRequestAttributes,
)
from datadog_api_client.v2.model.custom_destination_update_request_definition import (
CustomDestinationUpdateRequestDefinition,
)
# there is a valid "custom_destination_splunk" in the system
CUSTOM_DESTINATION_SPLUNK_DATA_ID = environ["CUSTOM_DESTINATION_SPLUNK_DATA_ID"]
body = CustomDestinationUpdateRequest(
data=CustomDestinationUpdateRequestDefinition(
attributes=CustomDestinationUpdateRequestAttributes(
forwarder_destination=CustomDestinationForwardDestinationSplunk(
type=CustomDestinationForwardDestinationSplunkType.SPLUNK_HEC,
endpoint="https://example.com",
access_token="my-access-token",
sourcetype="new-sourcetype",
),
),
type=CustomDestinationType.CUSTOM_DESTINATION,
id=CUSTOM_DESTINATION_SPLUNK_DATA_ID,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = LogsCustomDestinationsApi(api_client)
response = api_instance.update_logs_custom_destination(
custom_destination_id=CUSTOM_DESTINATION_SPLUNK_DATA_ID, body=body
)
print(response)
Update a Splunk custom destination's attributes preserves the absent sourcetype returns "OK" response
"""
Update a Splunk custom destination's attributes preserves the absent sourcetype 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_type import CustomDestinationType
from datadog_api_client.v2.model.custom_destination_update_request import CustomDestinationUpdateRequest
from datadog_api_client.v2.model.custom_destination_update_request_attributes import (
CustomDestinationUpdateRequestAttributes,
)
from datadog_api_client.v2.model.custom_destination_update_request_definition import (
CustomDestinationUpdateRequestDefinition,
)
# there is a valid "custom_destination_splunk" in the system
CUSTOM_DESTINATION_SPLUNK_DATA_ID = environ["CUSTOM_DESTINATION_SPLUNK_DATA_ID"]
body = CustomDestinationUpdateRequest(
data=CustomDestinationUpdateRequestDefinition(
attributes=CustomDestinationUpdateRequestAttributes(
name="Nginx logs (Updated)",
),
type=CustomDestinationType.CUSTOM_DESTINATION,
id=CUSTOM_DESTINATION_SPLUNK_DATA_ID,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = LogsCustomDestinationsApi(api_client)
response = api_instance.update_logs_custom_destination(
custom_destination_id=CUSTOM_DESTINATION_SPLUNK_DATA_ID, 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"Update a Splunk custom destination with a null sourcetype returns "OK" response
# Update a Splunk custom destination with a null sourcetype 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
# there is a valid "custom_destination_splunk_with_sourcetype" in the system
CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID = ENV["CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID"]
body = DatadogAPIClient::V2::CustomDestinationUpdateRequest.new({
data: DatadogAPIClient::V2::CustomDestinationUpdateRequestDefinition.new({
attributes: DatadogAPIClient::V2::CustomDestinationUpdateRequestAttributes.new({
forwarder_destination: DatadogAPIClient::V2::CustomDestinationForwardDestinationSplunk.new({
type: DatadogAPIClient::V2::CustomDestinationForwardDestinationSplunkType::SPLUNK_HEC,
endpoint: "https://example.com",
access_token: "my-access-token",
sourcetype: nil,
}),
}),
type: DatadogAPIClient::V2::CustomDestinationType::CUSTOM_DESTINATION,
id: CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID,
}),
})
p api_instance.update_logs_custom_destination(CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID, body)
Update a Splunk custom destination with a sourcetype returns "OK" response
# Update a Splunk custom destination with a sourcetype 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
# there is a valid "custom_destination_splunk" in the system
CUSTOM_DESTINATION_SPLUNK_DATA_ID = ENV["CUSTOM_DESTINATION_SPLUNK_DATA_ID"]
body = DatadogAPIClient::V2::CustomDestinationUpdateRequest.new({
data: DatadogAPIClient::V2::CustomDestinationUpdateRequestDefinition.new({
attributes: DatadogAPIClient::V2::CustomDestinationUpdateRequestAttributes.new({
forwarder_destination: DatadogAPIClient::V2::CustomDestinationForwardDestinationSplunk.new({
type: DatadogAPIClient::V2::CustomDestinationForwardDestinationSplunkType::SPLUNK_HEC,
endpoint: "https://example.com",
access_token: "my-access-token",
sourcetype: "new-sourcetype",
}),
}),
type: DatadogAPIClient::V2::CustomDestinationType::CUSTOM_DESTINATION,
id: CUSTOM_DESTINATION_SPLUNK_DATA_ID,
}),
})
p api_instance.update_logs_custom_destination(CUSTOM_DESTINATION_SPLUNK_DATA_ID, body)
Update a Splunk custom destination's attributes preserves the absent sourcetype returns "OK" response
# Update a Splunk custom destination's attributes preserves the absent sourcetype 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
# there is a valid "custom_destination_splunk" in the system
CUSTOM_DESTINATION_SPLUNK_DATA_ID = ENV["CUSTOM_DESTINATION_SPLUNK_DATA_ID"]
body = DatadogAPIClient::V2::CustomDestinationUpdateRequest.new({
data: DatadogAPIClient::V2::CustomDestinationUpdateRequestDefinition.new({
attributes: DatadogAPIClient::V2::CustomDestinationUpdateRequestAttributes.new({
name: "Nginx logs (Updated)",
}),
type: DatadogAPIClient::V2::CustomDestinationType::CUSTOM_DESTINATION,
id: CUSTOM_DESTINATION_SPLUNK_DATA_ID,
}),
})
p api_instance.update_logs_custom_destination(CUSTOM_DESTINATION_SPLUNK_DATA_ID, 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"Update a Splunk custom destination with a null sourcetype returns "OK" response
// Update a Splunk custom destination with a null sourcetype returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_logs_custom_destinations::LogsCustomDestinationsAPI;
use datadog_api_client::datadogV2::model::CustomDestinationForwardDestination;
use datadog_api_client::datadogV2::model::CustomDestinationForwardDestinationSplunk;
use datadog_api_client::datadogV2::model::CustomDestinationForwardDestinationSplunkType;
use datadog_api_client::datadogV2::model::CustomDestinationType;
use datadog_api_client::datadogV2::model::CustomDestinationUpdateRequest;
use datadog_api_client::datadogV2::model::CustomDestinationUpdateRequestAttributes;
use datadog_api_client::datadogV2::model::CustomDestinationUpdateRequestDefinition;
#[tokio::main]
async fn main() {
// there is a valid "custom_destination_splunk_with_sourcetype" in the system
let custom_destination_splunk_with_sourcetype_data_id =
std::env::var("CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID").unwrap();
let body = CustomDestinationUpdateRequest::new().data(
CustomDestinationUpdateRequestDefinition::new(
custom_destination_splunk_with_sourcetype_data_id.clone(),
CustomDestinationType::CUSTOM_DESTINATION,
)
.attributes(
CustomDestinationUpdateRequestAttributes::new().forwarder_destination(
CustomDestinationForwardDestination::CustomDestinationForwardDestinationSplunk(
Box::new(
CustomDestinationForwardDestinationSplunk::new(
"my-access-token".to_string(),
"https://example.com".to_string(),
CustomDestinationForwardDestinationSplunkType::SPLUNK_HEC,
)
.sourcetype(None),
),
),
),
),
);
let configuration = datadog::Configuration::new();
let api = LogsCustomDestinationsAPI::with_config(configuration);
let resp = api
.update_logs_custom_destination(
custom_destination_splunk_with_sourcetype_data_id.clone(),
body,
)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Update a Splunk custom destination with a sourcetype returns "OK" response
// Update a Splunk custom destination with a sourcetype returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_logs_custom_destinations::LogsCustomDestinationsAPI;
use datadog_api_client::datadogV2::model::CustomDestinationForwardDestination;
use datadog_api_client::datadogV2::model::CustomDestinationForwardDestinationSplunk;
use datadog_api_client::datadogV2::model::CustomDestinationForwardDestinationSplunkType;
use datadog_api_client::datadogV2::model::CustomDestinationType;
use datadog_api_client::datadogV2::model::CustomDestinationUpdateRequest;
use datadog_api_client::datadogV2::model::CustomDestinationUpdateRequestAttributes;
use datadog_api_client::datadogV2::model::CustomDestinationUpdateRequestDefinition;
#[tokio::main]
async fn main() {
// there is a valid "custom_destination_splunk" in the system
let custom_destination_splunk_data_id =
std::env::var("CUSTOM_DESTINATION_SPLUNK_DATA_ID").unwrap();
let body = CustomDestinationUpdateRequest::new().data(
CustomDestinationUpdateRequestDefinition::new(
custom_destination_splunk_data_id.clone(),
CustomDestinationType::CUSTOM_DESTINATION,
)
.attributes(
CustomDestinationUpdateRequestAttributes::new().forwarder_destination(
CustomDestinationForwardDestination::CustomDestinationForwardDestinationSplunk(
Box::new(
CustomDestinationForwardDestinationSplunk::new(
"my-access-token".to_string(),
"https://example.com".to_string(),
CustomDestinationForwardDestinationSplunkType::SPLUNK_HEC,
)
.sourcetype(Some("new-sourcetype".to_string())),
),
),
),
),
);
let configuration = datadog::Configuration::new();
let api = LogsCustomDestinationsAPI::with_config(configuration);
let resp = api
.update_logs_custom_destination(custom_destination_splunk_data_id.clone(), body)
.await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Update a Splunk custom destination's attributes preserves the absent sourcetype returns "OK" response
// Update a Splunk custom destination's attributes preserves the absent sourcetype
// returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_logs_custom_destinations::LogsCustomDestinationsAPI;
use datadog_api_client::datadogV2::model::CustomDestinationType;
use datadog_api_client::datadogV2::model::CustomDestinationUpdateRequest;
use datadog_api_client::datadogV2::model::CustomDestinationUpdateRequestAttributes;
use datadog_api_client::datadogV2::model::CustomDestinationUpdateRequestDefinition;
#[tokio::main]
async fn main() {
// there is a valid "custom_destination_splunk" in the system
let custom_destination_splunk_data_id =
std::env::var("CUSTOM_DESTINATION_SPLUNK_DATA_ID").unwrap();
let body = CustomDestinationUpdateRequest::new().data(
CustomDestinationUpdateRequestDefinition::new(
custom_destination_splunk_data_id.clone(),
CustomDestinationType::CUSTOM_DESTINATION,
)
.attributes(
CustomDestinationUpdateRequestAttributes::new()
.name("Nginx logs (Updated)".to_string()),
),
);
let configuration = datadog::Configuration::new();
let api = LogsCustomDestinationsAPI::with_config(configuration);
let resp = api
.update_logs_custom_destination(custom_destination_splunk_data_id.clone(), 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 runUpdate a Splunk custom destination with a null sourcetype returns "OK" response
/**
* Update a Splunk custom destination with a null sourcetype 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);
// there is a valid "custom_destination_splunk_with_sourcetype" in the system
const CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID = process.env
.CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID as string;
const params: v2.LogsCustomDestinationsApiUpdateLogsCustomDestinationRequest = {
body: {
data: {
attributes: {
forwarderDestination: {
type: "splunk_hec",
endpoint: "https://example.com",
accessToken: "my-access-token",
sourcetype: undefined,
},
},
type: "custom_destination",
id: CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID,
},
},
customDestinationId: CUSTOM_DESTINATION_SPLUNK_WITH_SOURCETYPE_DATA_ID,
};
apiInstance
.updateLogsCustomDestination(params)
.then((data: v2.CustomDestinationResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Update a Splunk custom destination with a sourcetype returns "OK" response
/**
* Update a Splunk custom destination with a sourcetype 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);
// there is a valid "custom_destination_splunk" in the system
const CUSTOM_DESTINATION_SPLUNK_DATA_ID = process.env
.CUSTOM_DESTINATION_SPLUNK_DATA_ID as string;
const params: v2.LogsCustomDestinationsApiUpdateLogsCustomDestinationRequest = {
body: {
data: {
attributes: {
forwarderDestination: {
type: "splunk_hec",
endpoint: "https://example.com",
accessToken: "my-access-token",
sourcetype: "new-sourcetype",
},
},
type: "custom_destination",
id: CUSTOM_DESTINATION_SPLUNK_DATA_ID,
},
},
customDestinationId: CUSTOM_DESTINATION_SPLUNK_DATA_ID,
};
apiInstance
.updateLogsCustomDestination(params)
.then((data: v2.CustomDestinationResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Update a Splunk custom destination's attributes preserves the absent sourcetype returns "OK" response
/**
* Update a Splunk custom destination's attributes preserves the absent sourcetype 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);
// there is a valid "custom_destination_splunk" in the system
const CUSTOM_DESTINATION_SPLUNK_DATA_ID = process.env
.CUSTOM_DESTINATION_SPLUNK_DATA_ID as string;
const params: v2.LogsCustomDestinationsApiUpdateLogsCustomDestinationRequest = {
body: {
data: {
attributes: {
name: "Nginx logs (Updated)",
},
type: "custom_destination",
id: CUSTOM_DESTINATION_SPLUNK_DATA_ID,
},
},
customDestinationId: CUSTOM_DESTINATION_SPLUNK_DATA_ID,
};
apiInstance
.updateLogsCustomDestination(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"