아카이브 생성
https://api.datadoghq.com/api/v2/logs/config/archiveshttps://api.us3.datadoghq.com/api/v2/logs/config/archiveshttps://api.us5.datadoghq.com/api/v2/logs/config/archiveshttps://api.datadoghq.eu/api/v2/logs/config/archiveshttps://api.ap1.datadoghq.com/api/v2/logs/config/archiveshttps://api.ap2.datadoghq.com/api/v2/logs/config/archiveshttps://api.uk1.datadoghq.com/api/v2/logs/config/archiveshttps://api.ddog-gov.com/api/v2/logs/config/archiveshttps://api.us2.ddog-gov.com/api/v2/logs/config/archives개요
소속 조직 내 아카이브를 생성합니다.
요청
Body Data (required)
새로운 아카이브의 정의.
data로그 아카이브.
attributesThe attributes associated with the archive.
compression_methodThe type of compression for the archive.
ZSTDGZIP, ZSTDdestination [required]An archive's destination.
<type=azure>The Azure archive destination.
container [required]The container where the archive will be stored.
integration [required]The Azure archive's integration destination.
client_id [required]A client ID.
tenant_id [required]A tenant ID.
pathThe archive path.
regionThe region where the archive will be stored.
storage_account [required]The associated storage account.
type [required]Type of the Azure archive destination.
azureazure<type=gcs>The GCS archive destination.
bucket [required]The bucket where the archive will be stored.
integration [required]The GCS archive's integration destination.
client_email [required]A client email.
project_idA project ID.
pathThe archive path.
type [required]Type of the GCS archive destination.
gcsgcs<type=s3>The S3 archive destination.
bucket [required]The bucket where the archive will be stored.
encryptionThe S3 encryption settings.
keyAn Amazon Resource Name (ARN) used to identify an AWS KMS key.
type [required]Type of S3 encryption for a destination.
NO_OVERRIDE, SSE_S3, SSE_KMSintegration [required]The S3 Archive's integration destination. You must provide one of the following: access_key_id alone, or both account_id and role_name together.
Object 1The S3 Archive's integration destination using an access key.
access_key_id [required]The access key ID for the integration.
Object 2The S3 Archive's integration destination using an IAM role.
account_id [required]The account ID for the integration.
role_name [required]The name of the role to assume for the integration.
pathThe archive path.
storage_classThe storage class where the archive will be stored.
STANDARDSTANDARD, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER_IRtype [required]Type of the S3 archive destination.
s3s3include_tagsTo store the tags in the archive, set the value "true". If it is set to "false", the tags will be deleted when the logs are sent to the archive.
falselookup_attributesAn array of attributes to use as lookup keys for the archive.
name [required]The archive name.
partitioning_attributesAn array of attributes to use as partition keys for the archive. The attribute used most frequently for querying should be first.
query [required]The archive query/filter. Logs matching this query are included in the archive.
rehydration_max_scan_size_in_gbMaximum scan size for rehydration from this archive.
rehydration_tagsAn array of tags to add to rehydrated logs from an archive.
type [required]The type of the resource. The value should always be archives.
archives{
"data": {
"attributes": {
"compression_method": "ZSTD",
"destination": {
"container": "container-name",
"integration": {
"client_id": "aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa",
"tenant_id": "aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa"
},
"path": "string",
"region": "string",
"storage_account": "account-name",
"type": "azure"
},
"include_tags": false,
"lookup_attributes": [
"trace_id",
"user_id"
],
"name": "Nginx Archive",
"partitioning_attributes": [
"service",
"status"
],
"query": "source:nginx",
"rehydration_max_scan_size_in_gb": 100,
"rehydration_tags": [
"team:intake",
"team:app"
]
},
"type": "archives"
}
}응답
OK
The logs archive.
dataThe definition of an archive.
attributesThe attributes associated with the archive.
compression_methodThe type of compression for the archive.
ZSTDGZIP, ZSTDdestination [required]An archive's destination.
<type=azure>The Azure archive destination.
container [required]The container where the archive will be stored.
integration [required]The Azure archive's integration destination.
client_id [required]A client ID.
tenant_id [required]A tenant ID.
pathThe archive path.
regionThe region where the archive will be stored.
storage_account [required]The associated storage account.
type [required]Type of the Azure archive destination.
azureazure<type=gcs>The GCS archive destination.
bucket [required]The bucket where the archive will be stored.
integration [required]The GCS archive's integration destination.
client_email [required]A client email.
project_idA project ID.
pathThe archive path.
type [required]Type of the GCS archive destination.
gcsgcs<type=s3>The S3 archive destination.
bucket [required]The bucket where the archive will be stored.
encryptionThe S3 encryption settings.
keyAn Amazon Resource Name (ARN) used to identify an AWS KMS key.
type [required]Type of S3 encryption for a destination.
NO_OVERRIDE, SSE_S3, SSE_KMSintegration [required]The S3 Archive's integration destination. You must provide one of the following: access_key_id alone, or both account_id and role_name together.
Object 1The S3 Archive's integration destination using an access key.
access_key_id [required]The access key ID for the integration.
Object 2The S3 Archive's integration destination using an IAM role.
account_id [required]The account ID for the integration.
role_name [required]The name of the role to assume for the integration.
pathThe archive path.
storage_classThe storage class where the archive will be stored.
STANDARDSTANDARD, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER_IRtype [required]Type of the S3 archive destination.
s3s3include_tagsTo store the tags in the archive, set the value "true". If it is set to "false", the tags will be deleted when the logs are sent to the archive.
falselookup_attributesAn array of attributes to use as lookup keys for the archive.
name [required]The archive name.
partitioning_attributesAn array of attributes to use as partition keys for the archive. The attribute used most frequently for querying should be first.
query [required]The archive query/filter. Logs matching this query are included in the archive.
rehydration_max_scan_size_in_gbMaximum scan size for rehydration from this archive.
rehydration_tagsAn array of tags to add to rehydrated logs from an archive.
stateThe state of the archive.
UNKNOWN, WORKING, FAILING, WORKING_AUTH_LEGACYidThe archive ID.
type [required]The type of the resource. The value should always be archives.
archives{
"data": {
"attributes": {
"compression_method": "ZSTD",
"destination": {
"container": "container-name",
"integration": {
"client_id": "aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa",
"tenant_id": "aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa"
},
"path": "string",
"region": "string",
"storage_account": "account-name",
"type": "azure"
},
"include_tags": false,
"lookup_attributes": [
"trace_id",
"user_id"
],
"name": "Nginx Archive",
"partitioning_attributes": [
"service",
"status"
],
"query": "source:nginx",
"rehydration_max_scan_size_in_gb": 100,
"rehydration_tags": [
"team:intake",
"team:app"
],
"state": "WORKING"
},
"id": "a2zcMylnM4OCHpYusxIi3g",
"type": "archives"
}
}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"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}코드 예시
## default
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"compression_method": "ZSTD",
"destination": {
"container": "container-name",
"storage_account": "account-name",
"type": "azure"
},
"include_tags": false,
"name": "Nginx Archive",
"query": "source:nginx",
"rehydration_max_scan_size_in_gb": 100,
"rehydration_tags": [
"team:intake",
"team:app"
]
},
"type": "archives"
}
}
EOF
## s3_access_key_id
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"destination": {
"bucket": "my-bucket",
"integration": {
"access_key_id": "AKIAIOSFODNN7EXAMPLE"
},
"type": "s3"
},
"name": "Nginx Archive",
"query": "source:nginx"
},
"type": "archives"
}
}
EOF## default
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"compression_method": "ZSTD",
"destination": {
"container": "container-name",
"storage_account": "account-name",
"type": "azure"
},
"include_tags": false,
"name": "Nginx Archive",
"query": "source:nginx",
"rehydration_max_scan_size_in_gb": 100,
"rehydration_tags": [
"team:intake",
"team:app"
]
},
"type": "archives"
}
}
EOF
## s3_access_key_id
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"destination": {
"bucket": "my-bucket",
"integration": {
"access_key_id": "AKIAIOSFODNN7EXAMPLE"
},
"type": "s3"
},
"name": "Nginx Archive",
"query": "source:nginx"
},
"type": "archives"
}
}
EOF## default
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"compression_method": "ZSTD",
"destination": {
"container": "container-name",
"storage_account": "account-name",
"type": "azure"
},
"include_tags": false,
"name": "Nginx Archive",
"query": "source:nginx",
"rehydration_max_scan_size_in_gb": 100,
"rehydration_tags": [
"team:intake",
"team:app"
]
},
"type": "archives"
}
}
EOF
## s3_access_key_id
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"destination": {
"bucket": "my-bucket",
"integration": {
"access_key_id": "AKIAIOSFODNN7EXAMPLE"
},
"type": "s3"
},
"name": "Nginx Archive",
"query": "source:nginx"
},
"type": "archives"
}
}
EOF## default
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"compression_method": "ZSTD",
"destination": {
"container": "container-name",
"storage_account": "account-name",
"type": "azure"
},
"include_tags": false,
"name": "Nginx Archive",
"query": "source:nginx",
"rehydration_max_scan_size_in_gb": 100,
"rehydration_tags": [
"team:intake",
"team:app"
]
},
"type": "archives"
}
}
EOF
## s3_access_key_id
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"destination": {
"bucket": "my-bucket",
"integration": {
"access_key_id": "AKIAIOSFODNN7EXAMPLE"
},
"type": "s3"
},
"name": "Nginx Archive",
"query": "source:nginx"
},
"type": "archives"
}
}
EOF## default
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"compression_method": "ZSTD",
"destination": {
"container": "container-name",
"storage_account": "account-name",
"type": "azure"
},
"include_tags": false,
"name": "Nginx Archive",
"query": "source:nginx",
"rehydration_max_scan_size_in_gb": 100,
"rehydration_tags": [
"team:intake",
"team:app"
]
},
"type": "archives"
}
}
EOF
## s3_access_key_id
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"destination": {
"bucket": "my-bucket",
"integration": {
"access_key_id": "AKIAIOSFODNN7EXAMPLE"
},
"type": "s3"
},
"name": "Nginx Archive",
"query": "source:nginx"
},
"type": "archives"
}
}
EOF## default
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"compression_method": "ZSTD",
"destination": {
"container": "container-name",
"storage_account": "account-name",
"type": "azure"
},
"include_tags": false,
"name": "Nginx Archive",
"query": "source:nginx",
"rehydration_max_scan_size_in_gb": 100,
"rehydration_tags": [
"team:intake",
"team:app"
]
},
"type": "archives"
}
}
EOF
## s3_access_key_id
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"destination": {
"bucket": "my-bucket",
"integration": {
"access_key_id": "AKIAIOSFODNN7EXAMPLE"
},
"type": "s3"
},
"name": "Nginx Archive",
"query": "source:nginx"
},
"type": "archives"
}
}
EOF## default
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"compression_method": "ZSTD",
"destination": {
"container": "container-name",
"storage_account": "account-name",
"type": "azure"
},
"include_tags": false,
"name": "Nginx Archive",
"query": "source:nginx",
"rehydration_max_scan_size_in_gb": 100,
"rehydration_tags": [
"team:intake",
"team:app"
]
},
"type": "archives"
}
}
EOF
## s3_access_key_id
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"destination": {
"bucket": "my-bucket",
"integration": {
"access_key_id": "AKIAIOSFODNN7EXAMPLE"
},
"type": "s3"
},
"name": "Nginx Archive",
"query": "source:nginx"
},
"type": "archives"
}
}
EOF## default
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"compression_method": "ZSTD",
"destination": {
"container": "container-name",
"storage_account": "account-name",
"type": "azure"
},
"include_tags": false,
"name": "Nginx Archive",
"query": "source:nginx",
"rehydration_max_scan_size_in_gb": 100,
"rehydration_tags": [
"team:intake",
"team:app"
]
},
"type": "archives"
}
}
EOF
## s3_access_key_id
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"destination": {
"bucket": "my-bucket",
"integration": {
"access_key_id": "AKIAIOSFODNN7EXAMPLE"
},
"type": "s3"
},
"name": "Nginx Archive",
"query": "source:nginx"
},
"type": "archives"
}
}
EOF## default
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"compression_method": "ZSTD",
"destination": {
"container": "container-name",
"storage_account": "account-name",
"type": "azure"
},
"include_tags": false,
"name": "Nginx Archive",
"query": "source:nginx",
"rehydration_max_scan_size_in_gb": 100,
"rehydration_tags": [
"team:intake",
"team:app"
]
},
"type": "archives"
}
}
EOF
## s3_access_key_id
# 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/archives" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"destination": {
"bucket": "my-bucket",
"integration": {
"access_key_id": "AKIAIOSFODNN7EXAMPLE"
},
"type": "s3"
},
"name": "Nginx Archive",
"query": "source:nginx"
},
"type": "archives"
}
}
EOF// Create an archive 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.LogsArchiveCreateRequest{
Data: &datadogV2.LogsArchiveCreateRequestDefinition{
Attributes: &datadogV2.LogsArchiveCreateRequestAttributes{
CompressionMethod: datadogV2.LOGSARCHIVEATTRIBUTESCOMPRESSIONMETHOD_GZIP.Ptr(),
Destination: datadogV2.LogsArchiveCreateRequestDestination{
LogsArchiveDestinationAzure: &datadogV2.LogsArchiveDestinationAzure{
Container: "container-name",
Integration: datadogV2.LogsArchiveIntegrationAzure{
ClientId: "aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa",
TenantId: "aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa",
},
StorageAccount: "account-name",
Type: datadogV2.LOGSARCHIVEDESTINATIONAZURETYPE_AZURE,
}},
IncludeTags: datadog.PtrBool(false),
LookupAttributes: []string{
"trace_id",
"user_id",
},
Name: "Nginx Archive",
PartitioningAttributes: []string{
"service",
"status",
},
Query: "source:nginx",
RehydrationMaxScanSizeInGb: *datadog.NewNullableInt64(datadog.PtrInt64(100)),
RehydrationTags: []string{
"team:intake",
"team:app",
},
},
Type: "archives",
},
}
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.NewLogsArchivesApi(apiClient)
resp, r, err := api.CreateLogsArchive(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `LogsArchivesApi.CreateLogsArchive`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `LogsArchivesApi.CreateLogsArchive`:\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 an archive returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.LogsArchivesApi;
import com.datadog.api.client.v2.model.LogsArchive;
import com.datadog.api.client.v2.model.LogsArchiveAttributesCompressionMethod;
import com.datadog.api.client.v2.model.LogsArchiveCreateRequest;
import com.datadog.api.client.v2.model.LogsArchiveCreateRequestAttributes;
import com.datadog.api.client.v2.model.LogsArchiveCreateRequestDefinition;
import com.datadog.api.client.v2.model.LogsArchiveCreateRequestDestination;
import com.datadog.api.client.v2.model.LogsArchiveDestinationAzure;
import com.datadog.api.client.v2.model.LogsArchiveDestinationAzureType;
import com.datadog.api.client.v2.model.LogsArchiveIntegrationAzure;
import java.util.Arrays;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
LogsArchivesApi apiInstance = new LogsArchivesApi(defaultClient);
LogsArchiveCreateRequest body =
new LogsArchiveCreateRequest()
.data(
new LogsArchiveCreateRequestDefinition()
.attributes(
new LogsArchiveCreateRequestAttributes()
.compressionMethod(LogsArchiveAttributesCompressionMethod.GZIP)
.destination(
new LogsArchiveCreateRequestDestination(
new LogsArchiveDestinationAzure()
.container("container-name")
.integration(
new LogsArchiveIntegrationAzure()
.clientId("aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa")
.tenantId("aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa"))
.storageAccount("account-name")
.type(LogsArchiveDestinationAzureType.AZURE)))
.includeTags(false)
.lookupAttributes(Arrays.asList("trace_id", "user_id"))
.name("Nginx Archive")
.partitioningAttributes(Arrays.asList("service", "status"))
.query("source:nginx")
.rehydrationMaxScanSizeInGb(100L)
.rehydrationTags(Arrays.asList("team:intake", "team:app")))
.type("archives"));
try {
LogsArchive result = apiInstance.createLogsArchive(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling LogsArchivesApi#createLogsArchive");
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 an archive returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.logs_archives_api import LogsArchivesApi
from datadog_api_client.v2.model.logs_archive_attributes_compression_method import (
LogsArchiveAttributesCompressionMethod,
)
from datadog_api_client.v2.model.logs_archive_create_request import LogsArchiveCreateRequest
from datadog_api_client.v2.model.logs_archive_create_request_attributes import LogsArchiveCreateRequestAttributes
from datadog_api_client.v2.model.logs_archive_create_request_definition import LogsArchiveCreateRequestDefinition
from datadog_api_client.v2.model.logs_archive_destination_azure import LogsArchiveDestinationAzure
from datadog_api_client.v2.model.logs_archive_destination_azure_type import LogsArchiveDestinationAzureType
from datadog_api_client.v2.model.logs_archive_integration_azure import LogsArchiveIntegrationAzure
body = LogsArchiveCreateRequest(
data=LogsArchiveCreateRequestDefinition(
attributes=LogsArchiveCreateRequestAttributes(
compression_method=LogsArchiveAttributesCompressionMethod.GZIP,
destination=LogsArchiveDestinationAzure(
container="container-name",
integration=LogsArchiveIntegrationAzure(
client_id="aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa",
tenant_id="aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa",
),
storage_account="account-name",
type=LogsArchiveDestinationAzureType.AZURE,
),
include_tags=False,
lookup_attributes=[
"trace_id",
"user_id",
],
name="Nginx Archive",
partitioning_attributes=[
"service",
"status",
],
query="source:nginx",
rehydration_max_scan_size_in_gb=100,
rehydration_tags=[
"team:intake",
"team:app",
],
),
type="archives",
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = LogsArchivesApi(api_client)
response = api_instance.create_logs_archive(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 an archive returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::LogsArchivesAPI.new
body = DatadogAPIClient::V2::LogsArchiveCreateRequest.new({
data: DatadogAPIClient::V2::LogsArchiveCreateRequestDefinition.new({
attributes: DatadogAPIClient::V2::LogsArchiveCreateRequestAttributes.new({
compression_method: DatadogAPIClient::V2::LogsArchiveAttributesCompressionMethod::GZIP,
destination: DatadogAPIClient::V2::LogsArchiveDestinationAzure.new({
container: "container-name",
integration: DatadogAPIClient::V2::LogsArchiveIntegrationAzure.new({
client_id: "aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa",
tenant_id: "aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa",
}),
storage_account: "account-name",
type: DatadogAPIClient::V2::LogsArchiveDestinationAzureType::AZURE,
}),
include_tags: false,
lookup_attributes: [
"trace_id",
"user_id",
],
name: "Nginx Archive",
partitioning_attributes: [
"service",
"status",
],
query: "source:nginx",
rehydration_max_scan_size_in_gb: 100,
rehydration_tags: [
"team:intake",
"team:app",
],
}),
type: "archives",
}),
})
p api_instance.create_logs_archive(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 an archive returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_logs_archives::LogsArchivesAPI;
use datadog_api_client::datadogV2::model::LogsArchiveAttributesCompressionMethod;
use datadog_api_client::datadogV2::model::LogsArchiveCreateRequest;
use datadog_api_client::datadogV2::model::LogsArchiveCreateRequestAttributes;
use datadog_api_client::datadogV2::model::LogsArchiveCreateRequestDefinition;
use datadog_api_client::datadogV2::model::LogsArchiveCreateRequestDestination;
use datadog_api_client::datadogV2::model::LogsArchiveDestinationAzure;
use datadog_api_client::datadogV2::model::LogsArchiveDestinationAzureType;
use datadog_api_client::datadogV2::model::LogsArchiveIntegrationAzure;
#[tokio::main]
async fn main() {
let body = LogsArchiveCreateRequest::new().data(
LogsArchiveCreateRequestDefinition::new("archives".to_string()).attributes(
LogsArchiveCreateRequestAttributes::new(
LogsArchiveCreateRequestDestination::LogsArchiveDestinationAzure(Box::new(
LogsArchiveDestinationAzure::new(
"container-name".to_string(),
LogsArchiveIntegrationAzure::new(
"aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa".to_string(),
"aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa".to_string(),
),
"account-name".to_string(),
LogsArchiveDestinationAzureType::AZURE,
),
)),
"Nginx Archive".to_string(),
"source:nginx".to_string(),
)
.compression_method(LogsArchiveAttributesCompressionMethod::GZIP)
.include_tags(false)
.lookup_attributes(vec!["trace_id".to_string(), "user_id".to_string()])
.partitioning_attributes(vec!["service".to_string(), "status".to_string()])
.rehydration_max_scan_size_in_gb(Some(100))
.rehydration_tags(vec!["team:intake".to_string(), "team:app".to_string()]),
),
);
let configuration = datadog::Configuration::new();
let api = LogsArchivesAPI::with_config(configuration);
let resp = api.create_logs_archive(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run/**
* Create an archive 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.LogsArchivesApi(configuration);
const params: v2.LogsArchivesApiCreateLogsArchiveRequest = {
body: {
data: {
attributes: {
compressionMethod: "GZIP",
destination: {
container: "container-name",
integration: {
clientId: "aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa",
tenantId: "aaaaaaaa-1a1a-1a1a-1a1a-aaaaaaaaaaaa",
},
storageAccount: "account-name",
type: "azure",
},
includeTags: false,
lookupAttributes: ["trace_id", "user_id"],
name: "Nginx Archive",
partitioningAttributes: ["service", "status"],
query: "source:nginx",
rehydrationMaxScanSizeInGb: 100,
rehydrationTags: ["team:intake", "team:app"],
},
type: "archives",
},
},
};
apiInstance
.createLogsArchive(params)
.then((data: v2.LogsArchive) => {
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"