Archives de logs
Rapport de recherche Datadog : Bilan sur l'adoption de l'informatique sans serveur Rapport : Bilan sur l'adoption de l'informatique sans serveur

Archives de logs

Les archives permettent de transférer tous les logs ingérés vers un système de stockage sur le cloud.

Consultez la page Archives pour obtenir la liste des archives actuellement configurées dans notre interface utilisateur.

Créer une archive

POST https://api.datadoghq.eu/api/v2/logs/config/archiveshttps://api.datadoghq.com/api/v2/logs/config/archives

Présentation

Créez une archive dans votre organisation.

Requête

Body Data (required)

La définition de la nouvelle archive.

Expand All

Champ

Type

Description

data

object

The definition of an archive.

attributes

object

The attributes associated with the archive.

destination [required]

object <oneOf>

An archive's destination.

Option 1

object

The Azure archive destination.

container [required]

string

The container where the archive will be stored.

integration [required]

object

The Azure archive's integration destination.

client_id [required]

string

A client ID.

tenant_id [required]

string

A tenant ID.

path

string

The archive path.

region

string

The region where the archive will be stored.

storage_account [required]

string

The associated storage account.

type [required]

enum

Type of the Azure archive destination. Allowed enum values: azure

Option 2

object

The GCS archive destination.

bucket [required]

string

The bucket where the archive will be stored.

integration [required]

object

The GCS archive's integration destination.

client_email [required]

string

A client email.

project_id [required]

string

A project ID.

path

string

The archive path.

type [required]

enum

Type of the GCS archive destination. Allowed enum values: gcs

Option 3

object

The S3 archive destination.

bucket [required]

string

The bucket where the archive will be stored.

integration [required]

object

The S3 Archive's integration destination.

account_id [required]

string

The account ID for the integration.

role_name [required]

string

The path of the integration.

path

string

The archive path.

type [required]

enum

Type of the S3 archive destination. Allowed enum values: s3

include_tags

boolean

To 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.

name [required]

string

The archive name.

query [required]

string

The archive query/filter. Logs matching this query are included in the archive.

rehydration_tags

[string]

An array of tags to add to rehydrated logs from an archive.

type [required]

string

The type of the resource. The value should always be archives.

{
  "data": {
    "attributes": {
      "destination": {},
      "include_tags": false,
      "name": "Nginx Archive",
      "query": "source:nginx",
      "rehydration_tags": [
        "team:intake",
        "team:app"
      ]
    },
    "type": "archives"
  }
}

Réponse

OK

The logs archive.

Expand All

Champ

Type

Description

data

object

The definition of an archive.

attributes

object

The attributes associated with the archive.

destination [required]

object <oneOf>

An archive's destination.

Option 1

object

The Azure archive destination.

container [required]

string

The container where the archive will be stored.

integration [required]

object

The Azure archive's integration destination.

client_id [required]

string

A client ID.

tenant_id [required]

string

A tenant ID.

path

string

The archive path.

region

string

The region where the archive will be stored.

storage_account [required]

string

The associated storage account.

type [required]

enum

Type of the Azure archive destination. Allowed enum values: azure

Option 2

object

The GCS archive destination.

bucket [required]

string

The bucket where the archive will be stored.

integration [required]

object

The GCS archive's integration destination.

client_email [required]

string

A client email.

project_id [required]

string

A project ID.

path

string

The archive path.

type [required]

enum

Type of the GCS archive destination. Allowed enum values: gcs

Option 3

object

The S3 archive destination.

bucket [required]

string

The bucket where the archive will be stored.

integration [required]

object

The S3 Archive's integration destination.

account_id [required]

string

The account ID for the integration.

role_name [required]

string

The path of the integration.

path

string

The archive path.

type [required]

enum

Type of the S3 archive destination. Allowed enum values: s3

include_tags

boolean

To 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.

name [required]

string

The archive name.

query [required]

string

The archive query/filter. Logs matching this query are included in the archive.

rehydration_tags

[string]

An array of tags to add to rehydrated logs from an archive.

state

enum

The state of the archive. Allowed enum values: UNKNOWN,WORKING,FAILING,WORKING_AUTH_LEGACY

id

string

The archive ID.

type [required]

string

The type of the resource. The value should always be archives.

{
  "data": {
    "attributes": {
      "destination": {},
      "include_tags": false,
      "name": "Nginx Archive",
      "query": "source:nginx",
      "rehydration_tags": [
        "team:intake",
        "team:app"
      ],
      "state": "WORKING"
    },
    "id": "a2zcMylnM4OCHpYusxIi3g",
    "type": "archives"
  }
}

Bad Request

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Curl command
curl -X POST "https://api.datadoghq.eu"https://api.datadoghq.com/api/v2/logs/config/archives" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "destination": null,
      "name": "Nginx Archive",
      "query": "source:nginx"
    },
    "type": "archives"
  }
}
EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v2/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    body := *datadog.NewLogsArchiveCreateRequest() // LogsArchiveCreateRequest | The definition of the new archive.

    configuration := datadog.NewConfiguration()

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.LogsArchivesApi.CreateLogsArchive(ctx).Body(body).Execute()
    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)
    }
    // response from `CreateLogsArchive`: LogsArchive
    response_content, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from LogsArchivesApi.CreateLogsArchive:\n%s\n", response_content)
}
// Import classes:
import java.util.*;
import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.auth.*;
import com.datadog.api.v2.client.model.*;
import com.datadog.api.v2.client.api.LogsArchivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        LogsArchivesApi apiInstance = new LogsArchivesApi(defaultClient);
        LogsArchiveCreateRequest body = new LogsArchiveCreateRequest(); // LogsArchiveCreateRequest | The definition of the new archive.
        try {
            LogsArchive result = apiInstance.createLogsArchive()
                .body(body)
                .execute();
            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();
        }
    }
}
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v2
from datadog_api_client.v2.api import logs_archives_api
from datadog_api_client.v2.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v2.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v2.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = logs_archives_api.LogsArchivesApi(api_client)
    body = LogsArchiveCreateRequest(
        data=LogsArchiveCreateRequestDefinition(
            attributes=LogsArchiveCreateRequestAttributes(
                destination=LogsArchiveCreateRequestDestination(),
                include_tags=False,
                name="Nginx Archive",
                query="source:nginx",
                rehydration_tags=["team:intake","team:app"],
            ),
            type="archives",
        ),
    ) # LogsArchiveCreateRequest | The definition of the new archive.

    # example passing only required values which don't have defaults set
    try:
        # Create an archive
        api_response = api_instance.create_logs_archive(body)
        pprint(api_response)
    except datadog_api_client.v2.ApiException as e:
        print("Exception when calling LogsArchivesApi->create_logs_archive: %s\n" % e)
require 'time'
require 'datadog_api_client/v2'
# setup authorization
DatadogAPIClient::V2.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V2::LogsArchivesApi.new
body = DatadogAPIClient::V2::LogsArchiveCreateRequest.new # LogsArchiveCreateRequest | The definition of the new archive.

begin
  # Create an archive
  result = api_instance.create_logs_archive(body)
  p result
rescue DatadogAPIClient::V2::ApiError => e
  puts "Error when calling LogsArchivesApi->create_logs_archive: #{e}"
end

Supprimer une archive

DELETE https://api.datadoghq.eu/api/v2/logs/config/archives/{archive_id}https://api.datadoghq.com/api/v2/logs/config/archives/{archive_id}

Présentation

Supprimez une archive spécifique de votre organisation.

Arguments

Paramètres du chemin

Nom

Type

Description

archive_id [required]

string

The ID of the archive.

Réponse

OK

Bad Request

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Not found

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Path parameters
export archive_id="CHANGE_ME"
# Curl command curl -X DELETE "https://api.datadoghq.eu"https://api.datadoghq.com/api/v2/logs/config/archives/${archive_id}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v2/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    archiveId := "archiveId_example" // string | The ID of the archive.

    configuration := datadog.NewConfiguration()

    api_client := datadog.NewAPIClient(configuration)
    r, err := api_client.LogsArchivesApi.DeleteLogsArchive(ctx, archiveId).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `LogsArchivesApi.DeleteLogsArchive``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
}
// Import classes:
import java.util.*;
import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.auth.*;
import com.datadog.api.v2.client.model.*;
import com.datadog.api.v2.client.api.LogsArchivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        LogsArchivesApi apiInstance = new LogsArchivesApi(defaultClient);
        String archiveId = "archiveId_example"; // String | The ID of the archive.
        try {
            apiInstance.deleteLogsArchive(archiveId)
                .execute();
        } catch (ApiException e) {
            System.err.println("Exception when calling LogsArchivesApi#deleteLogsArchive");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v2
from datadog_api_client.v2.api import logs_archives_api
from datadog_api_client.v2.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v2.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v2.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = logs_archives_api.LogsArchivesApi(api_client)
    archive_id = "archive_id_example" # str | The ID of the archive.

    # example passing only required values which don't have defaults set
    try:
        # Delete an archive
        api_instance.delete_logs_archive(archive_id)
    except datadog_api_client.v2.ApiException as e:
        print("Exception when calling LogsArchivesApi->delete_logs_archive: %s\n" % e)
require 'time'
require 'datadog_api_client/v2'
# setup authorization
DatadogAPIClient::V2.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V2::LogsArchivesApi.new
archive_id = 'archive_id_example' # String | The ID of the archive.

begin
  # Delete an archive
  api_instance.delete_logs_archive(archive_id)
rescue DatadogAPIClient::V2::ApiError => e
  puts "Error when calling LogsArchivesApi->delete_logs_archive: #{e}"
end

Récupérer toutes les archives

GET https://api.datadoghq.eu/api/v2/logs/config/archiveshttps://api.datadoghq.com/api/v2/logs/config/archives

Présentation

Récupérez la liste des archives de logs configurées avec leurs définitions.

Réponse

OK

The available archives.

Expand All

Champ

Type

Description

data

[object]

A list of archives.

attributes

object

The attributes associated with the archive.

destination [required]

object <oneOf>

An archive's destination.

Option 1

object

The Azure archive destination.

container [required]

string

The container where the archive will be stored.

integration [required]

object

The Azure archive's integration destination.

client_id [required]

string

A client ID.

tenant_id [required]

string

A tenant ID.

path

string

The archive path.

region

string

The region where the archive will be stored.

storage_account [required]

string

The associated storage account.

type [required]

enum

Type of the Azure archive destination. Allowed enum values: azure

Option 2

object

The GCS archive destination.

bucket [required]

string

The bucket where the archive will be stored.

integration [required]

object

The GCS archive's integration destination.

client_email [required]

string

A client email.

project_id [required]

string

A project ID.

path

string

The archive path.

type [required]

enum

Type of the GCS archive destination. Allowed enum values: gcs

Option 3

object

The S3 archive destination.

bucket [required]

string

The bucket where the archive will be stored.

integration [required]

object

The S3 Archive's integration destination.

account_id [required]

string

The account ID for the integration.

role_name [required]

string

The path of the integration.

path

string

The archive path.

type [required]

enum

Type of the S3 archive destination. Allowed enum values: s3

include_tags

boolean

To 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.

name [required]

string

The archive name.

query [required]

string

The archive query/filter. Logs matching this query are included in the archive.

rehydration_tags

[string]

An array of tags to add to rehydrated logs from an archive.

state

enum

The state of the archive. Allowed enum values: UNKNOWN,WORKING,FAILING,WORKING_AUTH_LEGACY

id

string

The archive ID.

type [required]

string

The type of the resource. The value should always be archives.

{
  "data": [
    {
      "attributes": {
        "destination": {},
        "include_tags": false,
        "name": "Nginx Archive",
        "query": "source:nginx",
        "rehydration_tags": [
          "team:intake",
          "team:app"
        ],
        "state": "WORKING"
      },
      "id": "a2zcMylnM4OCHpYusxIi3g",
      "type": "archives"
    }
  ]
}

Forbidden

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Curl command
curl -X GET "https://api.datadoghq.eu"https://api.datadoghq.com/api/v2/logs/config/archives" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v2/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )


    configuration := datadog.NewConfiguration()

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.LogsArchivesApi.ListLogsArchives(ctx).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `LogsArchivesApi.ListLogsArchives``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `ListLogsArchives`: LogsArchives
    response_content, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from LogsArchivesApi.ListLogsArchives:\n%s\n", response_content)
}
// Import classes:
import java.util.*;
import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.auth.*;
import com.datadog.api.v2.client.model.*;
import com.datadog.api.v2.client.api.LogsArchivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        LogsArchivesApi apiInstance = new LogsArchivesApi(defaultClient);
        try {
            LogsArchives result = apiInstance.listLogsArchives()
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling LogsArchivesApi#listLogsArchives");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v2
from datadog_api_client.v2.api import logs_archives_api
from datadog_api_client.v2.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v2.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v2.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = logs_archives_api.LogsArchivesApi(api_client)

    # example, this endpoint has no required or optional parameters
    try:
        # Get all archives
        api_response = api_instance.list_logs_archives()
        pprint(api_response)
    except datadog_api_client.v2.ApiException as e:
        print("Exception when calling LogsArchivesApi->list_logs_archives: %s\n" % e)
require 'time'
require 'datadog_api_client/v2'
# setup authorization
DatadogAPIClient::V2.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V2::LogsArchivesApi.new

begin
  # Get all archives
  result = api_instance.list_logs_archives
  p result
rescue DatadogAPIClient::V2::ApiError => e
  puts "Error when calling LogsArchivesApi->list_logs_archives: #{e}"
end

Récupérer une archive

GET https://api.datadoghq.eu/api/v2/logs/config/archives/{archive_id}https://api.datadoghq.com/api/v2/logs/config/archives/{archive_id}

Présentation

Récupérez une archive spécifique de votre organisation.

Arguments

Paramètres du chemin

Nom

Type

Description

archive_id [required]

string

The ID of the archive.

Réponse

OK

The logs archive.

Expand All

Champ

Type

Description

data

object

The definition of an archive.

attributes

object

The attributes associated with the archive.

destination [required]

object <oneOf>

An archive's destination.

Option 1

object

The Azure archive destination.

container [required]

string

The container where the archive will be stored.

integration [required]

object

The Azure archive's integration destination.

client_id [required]

string

A client ID.

tenant_id [required]

string

A tenant ID.

path

string

The archive path.

region

string

The region where the archive will be stored.

storage_account [required]

string

The associated storage account.

type [required]

enum

Type of the Azure archive destination. Allowed enum values: azure

Option 2

object

The GCS archive destination.

bucket [required]

string

The bucket where the archive will be stored.

integration [required]

object

The GCS archive's integration destination.

client_email [required]

string

A client email.

project_id [required]

string

A project ID.

path

string

The archive path.

type [required]

enum

Type of the GCS archive destination. Allowed enum values: gcs

Option 3

object

The S3 archive destination.

bucket [required]

string

The bucket where the archive will be stored.

integration [required]

object

The S3 Archive's integration destination.

account_id [required]

string

The account ID for the integration.

role_name [required]

string

The path of the integration.

path

string

The archive path.

type [required]

enum

Type of the S3 archive destination. Allowed enum values: s3

include_tags

boolean

To 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.

name [required]

string

The archive name.

query [required]

string

The archive query/filter. Logs matching this query are included in the archive.

rehydration_tags

[string]

An array of tags to add to rehydrated logs from an archive.

state

enum

The state of the archive. Allowed enum values: UNKNOWN,WORKING,FAILING,WORKING_AUTH_LEGACY

id

string

The archive ID.

type [required]

string

The type of the resource. The value should always be archives.

{
  "data": {
    "attributes": {
      "destination": {},
      "include_tags": false,
      "name": "Nginx Archive",
      "query": "source:nginx",
      "rehydration_tags": [
        "team:intake",
        "team:app"
      ],
      "state": "WORKING"
    },
    "id": "a2zcMylnM4OCHpYusxIi3g",
    "type": "archives"
  }
}

Bad Request

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Not found

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Path parameters
export archive_id="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.datadoghq.com/api/v2/logs/config/archives/${archive_id}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v2/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    archiveId := "archiveId_example" // string | The ID of the archive.

    configuration := datadog.NewConfiguration()

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.LogsArchivesApi.GetLogsArchive(ctx, archiveId).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `LogsArchivesApi.GetLogsArchive``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetLogsArchive`: LogsArchive
    response_content, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from LogsArchivesApi.GetLogsArchive:\n%s\n", response_content)
}
// Import classes:
import java.util.*;
import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.auth.*;
import com.datadog.api.v2.client.model.*;
import com.datadog.api.v2.client.api.LogsArchivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        LogsArchivesApi apiInstance = new LogsArchivesApi(defaultClient);
        String archiveId = "archiveId_example"; // String | The ID of the archive.
        try {
            LogsArchive result = apiInstance.getLogsArchive(archiveId)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling LogsArchivesApi#getLogsArchive");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v2
from datadog_api_client.v2.api import logs_archives_api
from datadog_api_client.v2.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v2.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v2.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = logs_archives_api.LogsArchivesApi(api_client)
    archive_id = "archive_id_example" # str | The ID of the archive.

    # example passing only required values which don't have defaults set
    try:
        # Get an archive
        api_response = api_instance.get_logs_archive(archive_id)
        pprint(api_response)
    except datadog_api_client.v2.ApiException as e:
        print("Exception when calling LogsArchivesApi->get_logs_archive: %s\n" % e)
require 'time'
require 'datadog_api_client/v2'
# setup authorization
DatadogAPIClient::V2.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V2::LogsArchivesApi.new
archive_id = 'archive_id_example' # String | The ID of the archive.

begin
  # Get an archive
  result = api_instance.get_logs_archive(archive_id)
  p result
rescue DatadogAPIClient::V2::ApiError => e
  puts "Error when calling LogsArchivesApi->get_logs_archive: #{e}"
end

Récupérer la séquence des archives

GET https://api.datadoghq.eu/api/v2/logs/config/archive-orderhttps://api.datadoghq.com/api/v2/logs/config/archive-order

Présentation

Récupérez la séquence actuelle de vos archives. Ce endpoint ne prend aucun argument JSON.

Réponse

OK

A ordered list of archive IDs.

Expand All

Champ

Type

Description

data

object

The definition of an archive order.

attributes [required]

object

The attributes associated with the archive order.

archive_ids [required]

[string]

An ordered array of <ARCHIVE_ID> strings, the order of archive IDs in the array define the overall archives order for Datadog.

type [required]

enum

Type of the archive order definition. Allowed enum values: archive_order

{
  "data": {
    "attributes": {
      "archive_ids": [
        "a2zcMylnM4OCHpYusxIi1g",
        "a2zcMylnM4OCHpYusxIi2g",
        "a2zcMylnM4OCHpYusxIi3g"
      ]
    },
    "type": "archive_order"
  }
}

Forbidden

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Curl command
curl -X GET "https://api.datadoghq.eu"https://api.datadoghq.com/api/v2/logs/config/archive-order" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v2/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )


    configuration := datadog.NewConfiguration()

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.LogsArchivesApi.GetLogsArchiveOrder(ctx).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `LogsArchivesApi.GetLogsArchiveOrder``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetLogsArchiveOrder`: LogsArchiveOrder
    response_content, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from LogsArchivesApi.GetLogsArchiveOrder:\n%s\n", response_content)
}
// Import classes:
import java.util.*;
import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.auth.*;
import com.datadog.api.v2.client.model.*;
import com.datadog.api.v2.client.api.LogsArchivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        LogsArchivesApi apiInstance = new LogsArchivesApi(defaultClient);
        try {
            LogsArchiveOrder result = apiInstance.getLogsArchiveOrder()
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling LogsArchivesApi#getLogsArchiveOrder");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v2
from datadog_api_client.v2.api import logs_archives_api
from datadog_api_client.v2.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v2.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v2.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = logs_archives_api.LogsArchivesApi(api_client)

    # example, this endpoint has no required or optional parameters
    try:
        # Get archive order
        api_response = api_instance.get_logs_archive_order()
        pprint(api_response)
    except datadog_api_client.v2.ApiException as e:
        print("Exception when calling LogsArchivesApi->get_logs_archive_order: %s\n" % e)
require 'time'
require 'datadog_api_client/v2'
# setup authorization
DatadogAPIClient::V2.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V2::LogsArchivesApi.new

begin
  # Get archive order
  result = api_instance.get_logs_archive_order
  p result
rescue DatadogAPIClient::V2::ApiError => e
  puts "Error when calling LogsArchivesApi->get_logs_archive_order: #{e}"
end

Accorder un rôle à une archive

Note: This endpoint is in public beta. If you have any feedback, contact Datadog support.

POST https://api.datadoghq.eu/api/v2/logs/config/archives/{archive_id}/readershttps://api.datadoghq.com/api/v2/logs/config/archives/{archive_id}/readers

Présentation

Ajoute un rôle de lecture à une archive (API Roles)

Arguments

Paramètres du chemin

Nom

Type

Description

archive_id [required]

string

The ID of the archive.

Requête

Body Data (required)

Expand All

Champ

Type

Description

data

object

Relationship to role object.

id

string

ID of the role.

type

enum

Roles type. Allowed enum values: roles

{
  "data": {
    "id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
    "type": "roles"
  }
}

Réponse

OK

Bad Request

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Not found

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Path parameters
export archive_id="CHANGE_ME"
# Curl command curl -X POST "https://api.datadoghq.eu"https://api.datadoghq.com/api/v2/logs/config/archives/${archive_id}/readers" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \ -d @- << EOF {} EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v2/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    archiveId := "archiveId_example" // string | The ID of the archive.
    body := *datadog.NewRelationshipToRole() // RelationshipToRole | 

    configuration := datadog.NewConfiguration()
    configuration.SetUnstableOperationEnabled("AddReadRoleToArchive", true)

    api_client := datadog.NewAPIClient(configuration)
    r, err := api_client.LogsArchivesApi.AddReadRoleToArchive(ctx, archiveId).Body(body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `LogsArchivesApi.AddReadRoleToArchive``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
}
// Import classes:
import java.util.*;
import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.auth.*;
import com.datadog.api.v2.client.model.*;
import com.datadog.api.v2.client.api.LogsArchivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        LogsArchivesApi apiInstance = new LogsArchivesApi(defaultClient);
        String archiveId = "archiveId_example"; // String | The ID of the archive.
        RelationshipToRole body = new RelationshipToRole(); // RelationshipToRole | 
        try {
            apiInstance.addReadRoleToArchive(archiveId)
                .body(body)
                .execute();
        } catch (ApiException e) {
            System.err.println("Exception when calling LogsArchivesApi#addReadRoleToArchive");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v2
from datadog_api_client.v2.api import logs_archives_api
from datadog_api_client.v2.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v2.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'
configuration.unstable_operations["add_read_role_to_archive"] = True

# Enter a context with an instance of the API client
with datadog_api_client.v2.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = logs_archives_api.LogsArchivesApi(api_client)
    archive_id = "archive_id_example" # str | The ID of the archive.
    body = RelationshipToRole(
        data=RelationshipToRoleData(
            id="3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
            type=RolesType("roles"),
        ),
    ) # RelationshipToRole | 

    # example passing only required values which don't have defaults set
    try:
        # Grant role to an archive
        api_instance.add_read_role_to_archive(archive_id, body)
    except datadog_api_client.v2.ApiException as e:
        print("Exception when calling LogsArchivesApi->add_read_role_to_archive: %s\n" % e)
require 'time'
require 'datadog_api_client/v2'
# setup authorization
DatadogAPIClient::V2.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['appKeyAuth'] = 'Bearer'

  config.unstable_operations[:add_read_role_to_archive] = true
end

api_instance = DatadogAPIClient::V2::LogsArchivesApi.new
archive_id = 'archive_id_example' # String | The ID of the archive.
body = DatadogAPIClient::V2::RelationshipToRole.new # RelationshipToRole | 

begin
  # Grant role to an archive
  api_instance.add_read_role_to_archive(archive_id, body)
rescue DatadogAPIClient::V2::ApiError => e
  puts "Error when calling LogsArchivesApi->add_read_role_to_archive: #{e}"
end

Énumérer les rôles de lecture pour une archive

Note: This endpoint is in public beta. If you have any feedback, contact Datadog support.

GET https://api.datadoghq.eu/api/v2/logs/config/archives/{archive_id}/readershttps://api.datadoghq.com/api/v2/logs/config/archives/{archive_id}/readers

Présentation

Renvoie tous les rôles de lecture auxquels une archive spécifique est limitée.

Arguments

Paramètres du chemin

Nom

Type

Description

archive_id [required]

string

The ID of the archive.

Réponse

OK

Response containing information about multiple roles.

Expand All

Champ

Type

Description

data

[object]

Array of returned roles.

attributes

object

Attributes of the role.

created_at

date-time

Creation time of the role.

modified_at

date-time

Time of last role modification.

name

string

Name of the role.

user_count

int64

Number of users with that role.

id

string

ID of the role.

relationships

object

Relationships of the role object returned by the API.

permissions

object

Relationship to multiple permissions objects.

data

[object]

Relationships to permission objects.

id

string

ID of the permission.

type [required]

enum

Permissions resource type. Allowed enum values: permissions

type [required]

enum

Roles type. Allowed enum values: roles

meta

object

Object describing meta attributes of response.

page

object

Pagination object.

total_count

int64

Total count.

total_filtered_count

int64

Total count of elements matched by the filter.

{
  "data": [
    {
      "attributes": {
        "created_at": "2019-09-19T10:00:00.000Z",
        "modified_at": "2019-09-19T10:00:00.000Z",
        "name": "string",
        "user_count": "integer"
      },
      "id": "string",
      "relationships": {
        "permissions": {
          "data": [
            {
              "id": "string",
              "type": "permissions"
            }
          ]
        }
      },
      "type": "roles"
    }
  ],
  "meta": {
    "page": {
      "total_count": "integer",
      "total_filtered_count": "integer"
    }
  }
}

Bad Request

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Not found

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Path parameters
export archive_id="CHANGE_ME"
# Curl command curl -X GET "https://api.datadoghq.eu"https://api.datadoghq.com/api/v2/logs/config/archives/${archive_id}/readers" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}"
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v2/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    archiveId := "archiveId_example" // string | The ID of the archive.

    configuration := datadog.NewConfiguration()
    configuration.SetUnstableOperationEnabled("ListArchiveReadRoles", true)

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.LogsArchivesApi.ListArchiveReadRoles(ctx, archiveId).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `LogsArchivesApi.ListArchiveReadRoles``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `ListArchiveReadRoles`: RolesResponse
    response_content, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from LogsArchivesApi.ListArchiveReadRoles:\n%s\n", response_content)
}
// Import classes:
import java.util.*;
import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.auth.*;
import com.datadog.api.v2.client.model.*;
import com.datadog.api.v2.client.api.LogsArchivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        LogsArchivesApi apiInstance = new LogsArchivesApi(defaultClient);
        String archiveId = "archiveId_example"; // String | The ID of the archive.
        try {
            RolesResponse result = apiInstance.listArchiveReadRoles(archiveId)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling LogsArchivesApi#listArchiveReadRoles");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v2
from datadog_api_client.v2.api import logs_archives_api
from datadog_api_client.v2.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v2.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'
configuration.unstable_operations["list_archive_read_roles"] = True

# Enter a context with an instance of the API client
with datadog_api_client.v2.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = logs_archives_api.LogsArchivesApi(api_client)
    archive_id = "archive_id_example" # str | The ID of the archive.

    # example passing only required values which don't have defaults set
    try:
        # List read roles for an archive
        api_response = api_instance.list_archive_read_roles(archive_id)
        pprint(api_response)
    except datadog_api_client.v2.ApiException as e:
        print("Exception when calling LogsArchivesApi->list_archive_read_roles: %s\n" % e)
require 'time'
require 'datadog_api_client/v2'
# setup authorization
DatadogAPIClient::V2.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['appKeyAuth'] = 'Bearer'

  config.unstable_operations[:list_archive_read_roles] = true
end

api_instance = DatadogAPIClient::V2::LogsArchivesApi.new
archive_id = 'archive_id_example' # String | The ID of the archive.

begin
  # List read roles for an archive
  result = api_instance.list_archive_read_roles(archive_id)
  p result
rescue DatadogAPIClient::V2::ApiError => e
  puts "Error when calling LogsArchivesApi->list_archive_read_roles: #{e}"
end

Révoquer le rôle d'une archive

Note: This endpoint is in public beta. If you have any feedback, contact Datadog support.

DELETE https://api.datadoghq.eu/api/v2/logs/config/archives/{archive_id}/readershttps://api.datadoghq.com/api/v2/logs/config/archives/{archive_id}/readers

Présentation

Supprime un rôle d’une archive. (API Roles)

Arguments

Paramètres du chemin

Nom

Type

Description

archive_id [required]

string

The ID of the archive.

Requête

Body Data (required)

Expand All

Champ

Type

Description

data

object

Relationship to role object.

id

string

ID of the role.

type

enum

Roles type. Allowed enum values: roles

{
  "data": {
    "id": "3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
    "type": "roles"
  }
}

Réponse

OK

Bad Request

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Not found

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Path parameters
export archive_id="CHANGE_ME"
# Curl command curl -X DELETE "https://api.datadoghq.eu"https://api.datadoghq.com/api/v2/logs/config/archives/${archive_id}/readers" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \ -d @- << EOF {} EOF
package main

import (
    "context"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v2/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    archiveId := "archiveId_example" // string | The ID of the archive.
    body := *datadog.NewRelationshipToRole() // RelationshipToRole | 

    configuration := datadog.NewConfiguration()
    configuration.SetUnstableOperationEnabled("RemoveRoleFromArchive", true)

    api_client := datadog.NewAPIClient(configuration)
    r, err := api_client.LogsArchivesApi.RemoveRoleFromArchive(ctx, archiveId).Body(body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `LogsArchivesApi.RemoveRoleFromArchive``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
}
// Import classes:
import java.util.*;
import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.auth.*;
import com.datadog.api.v2.client.model.*;
import com.datadog.api.v2.client.api.LogsArchivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        LogsArchivesApi apiInstance = new LogsArchivesApi(defaultClient);
        String archiveId = "archiveId_example"; // String | The ID of the archive.
        RelationshipToRole body = new RelationshipToRole(); // RelationshipToRole | 
        try {
            apiInstance.removeRoleFromArchive(archiveId)
                .body(body)
                .execute();
        } catch (ApiException e) {
            System.err.println("Exception when calling LogsArchivesApi#removeRoleFromArchive");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v2
from datadog_api_client.v2.api import logs_archives_api
from datadog_api_client.v2.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v2.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'
configuration.unstable_operations["remove_role_from_archive"] = True

# Enter a context with an instance of the API client
with datadog_api_client.v2.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = logs_archives_api.LogsArchivesApi(api_client)
    archive_id = "archive_id_example" # str | The ID of the archive.
    body = RelationshipToRole(
        data=RelationshipToRoleData(
            id="3653d3c6-0c75-11ea-ad28-fb5701eabc7d",
            type=RolesType("roles"),
        ),
    ) # RelationshipToRole | 

    # example passing only required values which don't have defaults set
    try:
        # Revoke role from an archive
        api_instance.remove_role_from_archive(archive_id, body)
    except datadog_api_client.v2.ApiException as e:
        print("Exception when calling LogsArchivesApi->remove_role_from_archive: %s\n" % e)
require 'time'
require 'datadog_api_client/v2'
# setup authorization
DatadogAPIClient::V2.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['appKeyAuth'] = 'Bearer'

  config.unstable_operations[:remove_role_from_archive] = true
end

api_instance = DatadogAPIClient::V2::LogsArchivesApi.new
archive_id = 'archive_id_example' # String | The ID of the archive.
body = DatadogAPIClient::V2::RelationshipToRole.new # RelationshipToRole | 

begin
  # Revoke role from an archive
  api_instance.remove_role_from_archive(archive_id, body)
rescue DatadogAPIClient::V2::ApiError => e
  puts "Error when calling LogsArchivesApi->remove_role_from_archive: #{e}"
end

Mettre à jour une archive

PUT https://api.datadoghq.eu/api/v2/logs/config/archives/{archive_id}https://api.datadoghq.com/api/v2/logs/config/archives/{archive_id}

Présentation

Mettez à jour une configuration d’archive donnée.

Remarque : cette méthode permet de mettre à jour la configuration de votre archive en remplaçant votre configuration actuelle par la nouvelle, envoyée à votre organisation Datadog.

Arguments

Paramètres du chemin

Nom

Type

Description

archive_id [required]

string

The ID of the archive.

Requête

Body Data (required)

Nouvelle définition de l’archive.

Expand All

Champ

Type

Description

data

object

The definition of an archive.

attributes

object

The attributes associated with the archive.

destination [required]

object <oneOf>

An archive's destination.

Option 1

object

The Azure archive destination.

container [required]

string

The container where the archive will be stored.

integration [required]

object

The Azure archive's integration destination.

client_id [required]

string

A client ID.

tenant_id [required]

string

A tenant ID.

path

string

The archive path.

region

string

The region where the archive will be stored.

storage_account [required]

string

The associated storage account.

type [required]

enum

Type of the Azure archive destination. Allowed enum values: azure

Option 2

object

The GCS archive destination.

bucket [required]

string

The bucket where the archive will be stored.

integration [required]

object

The GCS archive's integration destination.

client_email [required]

string

A client email.

project_id [required]

string

A project ID.

path

string

The archive path.

type [required]

enum

Type of the GCS archive destination. Allowed enum values: gcs

Option 3

object

The S3 archive destination.

bucket [required]

string

The bucket where the archive will be stored.

integration [required]

object

The S3 Archive's integration destination.

account_id [required]

string

The account ID for the integration.

role_name [required]

string

The path of the integration.

path

string

The archive path.

type [required]

enum

Type of the S3 archive destination. Allowed enum values: s3

include_tags

boolean

To 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.

name [required]

string

The archive name.

query [required]

string

The archive query/filter. Logs matching this query are included in the archive.

rehydration_tags

[string]

An array of tags to add to rehydrated logs from an archive.

type [required]

string

The type of the resource. The value should always be archives.

{
  "data": {
    "attributes": {
      "destination": {},
      "include_tags": false,
      "name": "Nginx Archive",
      "query": "source:nginx",
      "rehydration_tags": [
        "team:intake",
        "team:app"
      ]
    },
    "type": "archives"
  }
}

Réponse

OK

The logs archive.

Expand All

Champ

Type

Description

data

object

The definition of an archive.

attributes

object

The attributes associated with the archive.

destination [required]

object <oneOf>

An archive's destination.

Option 1

object

The Azure archive destination.

container [required]

string

The container where the archive will be stored.

integration [required]

object

The Azure archive's integration destination.

client_id [required]

string

A client ID.

tenant_id [required]

string

A tenant ID.

path

string

The archive path.

region

string

The region where the archive will be stored.

storage_account [required]

string

The associated storage account.

type [required]

enum

Type of the Azure archive destination. Allowed enum values: azure

Option 2

object

The GCS archive destination.

bucket [required]

string

The bucket where the archive will be stored.

integration [required]

object

The GCS archive's integration destination.

client_email [required]

string

A client email.

project_id [required]

string

A project ID.

path

string

The archive path.

type [required]

enum

Type of the GCS archive destination. Allowed enum values: gcs

Option 3

object

The S3 archive destination.

bucket [required]

string

The bucket where the archive will be stored.

integration [required]

object

The S3 Archive's integration destination.

account_id [required]

string

The account ID for the integration.

role_name [required]

string

The path of the integration.

path

string

The archive path.

type [required]

enum

Type of the S3 archive destination. Allowed enum values: s3

include_tags

boolean

To 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.

name [required]

string

The archive name.

query [required]

string

The archive query/filter. Logs matching this query are included in the archive.

rehydration_tags

[string]

An array of tags to add to rehydrated logs from an archive.

state

enum

The state of the archive. Allowed enum values: UNKNOWN,WORKING,FAILING,WORKING_AUTH_LEGACY

id

string

The archive ID.

type [required]

string

The type of the resource. The value should always be archives.

{
  "data": {
    "attributes": {
      "destination": {},
      "include_tags": false,
      "name": "Nginx Archive",
      "query": "source:nginx",
      "rehydration_tags": [
        "team:intake",
        "team:app"
      ],
      "state": "WORKING"
    },
    "id": "a2zcMylnM4OCHpYusxIi3g",
    "type": "archives"
  }
}

Bad Request

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Not found

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Path parameters
export archive_id="CHANGE_ME"
# Curl command curl -X PUT "https://api.datadoghq.eu"https://api.datadoghq.com/api/v2/logs/config/archives/${archive_id}" \ -H "Content-Type: application/json" \ -H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \ -d @- << EOF { "data": { "attributes": { "destination": null, "name": "Nginx Archive", "query": "source:nginx" }, "type": "archives" } } EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v2/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    archiveId := "archiveId_example" // string | The ID of the archive.
    body := *datadog.NewLogsArchiveCreateRequest() // LogsArchiveCreateRequest | New definition of the archive.

    configuration := datadog.NewConfiguration()

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.LogsArchivesApi.UpdateLogsArchive(ctx, archiveId).Body(body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `LogsArchivesApi.UpdateLogsArchive``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `UpdateLogsArchive`: LogsArchive
    response_content, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from LogsArchivesApi.UpdateLogsArchive:\n%s\n", response_content)
}
// Import classes:
import java.util.*;
import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.auth.*;
import com.datadog.api.v2.client.model.*;
import com.datadog.api.v2.client.api.LogsArchivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        LogsArchivesApi apiInstance = new LogsArchivesApi(defaultClient);
        String archiveId = "archiveId_example"; // String | The ID of the archive.
        LogsArchiveCreateRequest body = new LogsArchiveCreateRequest(); // LogsArchiveCreateRequest | New definition of the archive.
        try {
            LogsArchive result = apiInstance.updateLogsArchive(archiveId)
                .body(body)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling LogsArchivesApi#updateLogsArchive");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v2
from datadog_api_client.v2.api import logs_archives_api
from datadog_api_client.v2.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v2.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v2.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = logs_archives_api.LogsArchivesApi(api_client)
    archive_id = "archive_id_example" # str | The ID of the archive.
    body = LogsArchiveCreateRequest(
        data=LogsArchiveCreateRequestDefinition(
            attributes=LogsArchiveCreateRequestAttributes(
                destination=LogsArchiveCreateRequestDestination(),
                include_tags=False,
                name="Nginx Archive",
                query="source:nginx",
                rehydration_tags=["team:intake","team:app"],
            ),
            type="archives",
        ),
    ) # LogsArchiveCreateRequest | New definition of the archive.

    # example passing only required values which don't have defaults set
    try:
        # Update an archive
        api_response = api_instance.update_logs_archive(archive_id, body)
        pprint(api_response)
    except datadog_api_client.v2.ApiException as e:
        print("Exception when calling LogsArchivesApi->update_logs_archive: %s\n" % e)
require 'time'
require 'datadog_api_client/v2'
# setup authorization
DatadogAPIClient::V2.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V2::LogsArchivesApi.new
archive_id = 'archive_id_example' # String | The ID of the archive.
body = DatadogAPIClient::V2::LogsArchiveCreateRequest.new # LogsArchiveCreateRequest | New definition of the archive.

begin
  # Update an archive
  result = api_instance.update_logs_archive(archive_id, body)
  p result
rescue DatadogAPIClient::V2::ApiError => e
  puts "Error when calling LogsArchivesApi->update_logs_archive: #{e}"
end

Mettre à jour la séquence des archives

PUT https://api.datadoghq.eu/api/v2/logs/config/archive-orderhttps://api.datadoghq.com/api/v2/logs/config/archive-order

Présentation

Mettez à jour la séquence de vos archives. Les logs étant traités de manière séquentielle, la réorganisation d’une archive peut changer la structure et le contenu des données traitées par les autres archives.

Remarque : la méthode PUT permet de mettre à jour la séquence des archives en remplaçant la séquence actuelle actuelle par la nouvelle.

Requête

Body Data (required)

Un objet contenant la nouvelle liste triée des ID d’archive.

Expand All

Champ

Type

Description

data

object

The definition of an archive order.

attributes [required]

object

The attributes associated with the archive order.

archive_ids [required]

[string]

An ordered array of <ARCHIVE_ID> strings, the order of archive IDs in the array define the overall archives order for Datadog.

type [required]

enum

Type of the archive order definition. Allowed enum values: archive_order

{
  "data": {
    "attributes": {
      "archive_ids": [
        "a2zcMylnM4OCHpYusxIi1g",
        "a2zcMylnM4OCHpYusxIi2g",
        "a2zcMylnM4OCHpYusxIi3g"
      ]
    },
    "type": "archive_order"
  }
}

Réponse

OK

A ordered list of archive IDs.

Expand All

Champ

Type

Description

data

object

The definition of an archive order.

attributes [required]

object

The attributes associated with the archive order.

archive_ids [required]

[string]

An ordered array of <ARCHIVE_ID> strings, the order of archive IDs in the array define the overall archives order for Datadog.

type [required]

enum

Type of the archive order definition. Allowed enum values: archive_order

{
  "data": {
    "attributes": {
      "archive_ids": [
        "a2zcMylnM4OCHpYusxIi1g",
        "a2zcMylnM4OCHpYusxIi2g",
        "a2zcMylnM4OCHpYusxIi3g"
      ]
    },
    "type": "archive_order"
  }
}

Bad Request

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Forbidden

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Unprocessable Entity

API error response.

Expand All

Champ

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "Bad Request"
  ]
}

Exemple de code


                                        # Curl command
curl -X PUT "https://api.datadoghq.eu"https://api.datadoghq.com/api/v2/logs/config/archive-order" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_CLIENT_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_CLIENT_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "archive_ids": [
        "a2zcMylnM4OCHpYusxIi1g",
        "a2zcMylnM4OCHpYusxIi2g",
        "a2zcMylnM4OCHpYusxIi3g"
      ]
    },
    "type": "archive_order"
  }
}
EOF
package main

import (
    "context"
    "encoding/json"
    "fmt"
    "os"
    datadog "github.com/DataDog/datadog-api-client-go/api/v2/datadog"
)

func main() {
    ctx := context.WithValue(
        context.Background(),
        datadog.ContextAPIKeys,
        map[string]datadog.APIKey{
            "apiKeyAuth": {
                Key: os.Getenv("DD_CLIENT_API_KEY"),
            },
            "appKeyAuth": {
                Key: os.Getenv("DD_CLIENT_APP_KEY"),
            },
        },
    )

    body := *datadog.NewLogsArchiveOrder() // LogsArchiveOrder | An object containing the new ordered list of archive IDs.

    configuration := datadog.NewConfiguration()

    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.LogsArchivesApi.UpdateLogsArchiveOrder(ctx).Body(body).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `LogsArchivesApi.UpdateLogsArchiveOrder``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `UpdateLogsArchiveOrder`: LogsArchiveOrder
    response_content, _ := json.MarshalIndent(resp, "", "  ")
    fmt.Fprintf(os.Stdout, "Response from LogsArchivesApi.UpdateLogsArchiveOrder:\n%s\n", response_content)
}
// Import classes:
import java.util.*;
import com.datadog.api.v2.client.ApiClient;
import com.datadog.api.v2.client.ApiException;
import com.datadog.api.v2.client.Configuration;
import com.datadog.api.v2.client.auth.*;
import com.datadog.api.v2.client.model.*;
import com.datadog.api.v2.client.api.LogsArchivesApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        // Configure the Datadog site to send API calls to
        HashMap<String, String> serverVariables = new HashMap<String, String>();
        String site = System.getenv("DD_SITE");
        if (site != null) {
            serverVariables.put("site", site);
            defaultClient.setServerVariables(serverVariables);
        }
        // Configure API key authorization: 
        HashMap<String, String> secrets = new HashMap<String, String>();
        secrets.put("apiKeyAuth", System.getenv("DD_CLIENT_API_KEY"));
        secrets.put("appKeyAuth", System.getenv("DD_CLIENT_APP_KEY"));
        defaultClient.configureApiKeys(secrets);

        LogsArchivesApi apiInstance = new LogsArchivesApi(defaultClient);
        LogsArchiveOrder body = new LogsArchiveOrder(); // LogsArchiveOrder | An object containing the new ordered list of archive IDs.
        try {
            LogsArchiveOrder result = apiInstance.updateLogsArchiveOrder()
                .body(body)
                .execute();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling LogsArchivesApi#updateLogsArchiveOrder");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}
import os
from dateutil.parser import parse as dateutil_parser
import datadog_api_client.v2
from datadog_api_client.v2.api import logs_archives_api
from datadog_api_client.v2.models import *
from pprint import pprint
# Defining the host is optional and defaults to https://api.datadoghq.com
# See configuration.py for a list of all supported configuration parameters.
configuration = datadog_api_client.v2.Configuration(
    host = "https://api.datadoghq.com"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: apiKeyAuth
configuration.api_key['apiKeyAuth'] = os.getenv('DD_CLIENT_API_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['apiKeyAuth'] = 'Bearer'

# Configure API key authorization: appKeyAuth
configuration.api_key['appKeyAuth'] = os.getenv('DD_CLIENT_APP_KEY')

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['appKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with datadog_api_client.v2.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = logs_archives_api.LogsArchivesApi(api_client)
    body = LogsArchiveOrder(
        data=LogsArchiveOrderDefinition(
            attributes=LogsArchiveOrderAttributes(
                archive_ids=["a2zcMylnM4OCHpYusxIi1g","a2zcMylnM4OCHpYusxIi2g","a2zcMylnM4OCHpYusxIi3g"],
            ),
            type=LogsArchiveOrderDefinitionType("archive_order"),
        ),
    ) # LogsArchiveOrder | An object containing the new ordered list of archive IDs.

    # example passing only required values which don't have defaults set
    try:
        # Update archive order
        api_response = api_instance.update_logs_archive_order(body)
        pprint(api_response)
    except datadog_api_client.v2.ApiException as e:
        print("Exception when calling LogsArchivesApi->update_logs_archive_order: %s\n" % e)
require 'time'
require 'datadog_api_client/v2'
# setup authorization
DatadogAPIClient::V2.configure do |config|
  # Configure API key authorization: apiKeyAuth
  config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['apiKeyAuth'] = 'Bearer'

  # Configure API key authorization: appKeyAuth
  config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"]
  # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
  # config.api_key_prefix['appKeyAuth'] = 'Bearer'
end

api_instance = DatadogAPIClient::V2::LogsArchivesApi.new
body = DatadogAPIClient::V2::LogsArchiveOrder.new # LogsArchiveOrder | An object containing the new ordered list of archive IDs.

begin
  # Update archive order
  result = api_instance.update_logs_archive_order(body)
  p result
rescue DatadogAPIClient::V2::ApiError => e
  puts "Error when calling LogsArchivesApi->update_logs_archive_order: #{e}"
end