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

Logs Archives

Archives forward all the logs ingested to a cloud storage system.

See the Archives Page for a list of the archives currently configured in our UI.

Create an archive

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

Overview

Create an archive in your organization.

Request

Body Data (required)

The definition of the new archive.

Expand All

Field

Type

Description

data

object

The definition of an archive.

attributes

object

The attributes associated with the archive.

destination [required]

object

An archive's destination.

name [required]

string

The archive name.

query [required]

string

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

type [required]

string

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

{
  "data": {
    "attributes": {
      "destination": {},
      "name": "Nginx Archive",
      "query": "source:nginx"
    },
    "type": "archives"
  }
}

Response

OK

The logs archive.

Expand All

Field

Type

Description

data

object

The definition of an archive.

attributes

object

The attributes associated with the archive.

destination [required]

object

An archive's destination.

name [required]

string

The archive name.

query [required]

string

The archive query/filter. Logs matching this query are included in the 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": {},
      "name": "Nginx Archive",
      "query": "source:nginx",
      "state": "WORKING"
    },
    "id": "a2zcMylnM4OCHpYusxIi3g",
    "type": "archives"
  }
}

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


                                        # Curl command
curl -X POST https://api.datadoghq.comhttps://api.datadoghq.eu/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"
    "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.LogsArchiveCreateRequest{Data: datadog.LogsArchiveCreateRequestDefinition{Attributes: datadog.LogsArchiveCreateRequestAttributes{Destination: datadog.LogsArchiveCreateRequestDestination{Container: "Container_example", Integration: datadog.LogsArchiveIntegrationS3{AccountId: "AccountId_example", RoleName: "RoleName_example"}, Path: "Path_example", Region: "Region_example", StorageAccount: "StorageAccount_example", Type: datadog.LogsArchiveDestinationS3Type{}, Bucket: "Bucket_example"}, Name: "Name_example", Query: "Query_example"}, Type: "Type_example"}} // LogsArchiveCreateRequest | The definition of the new archive.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.LogsArchivesApi.CreateLogsArchive(ctx, 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
    fmt.Fprintf(os.Stdout, "Response from `LogsArchivesApi.CreateLogsArchive`: %v\n", resp)
}
// Import classes:
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 = api.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();
        }
    }
}

Delete an archive

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

Overview

Delete a given archive from your organization.

Arguments

Path Parameters

Name

Type

Description

archive_id [required]

string

The ID of the archive.

Response

OK

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Not found

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


                                        # Path parameters
export archive_id="CHANGE_ME"
# Curl command curl -X DELETE https://api.datadoghq.comhttps://api.datadoghq.eu/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)
    resp, 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 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 {
            api.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();
        }
    }
}

Get all archives

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

Overview

Get the list of configured logs archives with their definitions.

Response

OK

The available archives.

Expand All

Field

Type

Description

data

[object]

A list of archives.

attributes

object

The attributes associated with the archive.

destination [required]

object

An archive's destination.

name [required]

string

The archive name.

query [required]

string

The archive query/filter. Logs matching this query are included in the 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": {},
        "name": "Nginx Archive",
        "query": "source:nginx",
        "state": "WORKING"
      },
      "id": "a2zcMylnM4OCHpYusxIi3g",
      "type": "archives"
    }
  ]
}

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


                                        # Curl command
curl -X GET https://api.datadoghq.comhttps://api.datadoghq.eu/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"
    "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
    fmt.Fprintf(os.Stdout, "Response from `LogsArchivesApi.ListLogsArchives`: %v\n", resp)
}
// Import classes:
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 = api.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();
        }
    }
}

Get an archive

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

Overview

Get a specific archive from your organization.

Arguments

Path Parameters

Name

Type

Description

archive_id [required]

string

The ID of the archive.

Response

OK

The logs archive.

Expand All

Field

Type

Description

data

object

The definition of an archive.

attributes

object

The attributes associated with the archive.

destination [required]

object

An archive's destination.

name [required]

string

The archive name.

query [required]

string

The archive query/filter. Logs matching this query are included in the 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": {},
      "name": "Nginx Archive",
      "query": "source:nginx",
      "state": "WORKING"
    },
    "id": "a2zcMylnM4OCHpYusxIi3g",
    "type": "archives"
  }
}

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Not found

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


                                        # Path parameters
export archive_id="CHANGE_ME"
# Curl command curl -X GET https://api.datadoghq.comhttps://api.datadoghq.eu/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)
    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
    fmt.Fprintf(os.Stdout, "Response from `LogsArchivesApi.GetLogsArchive`: %v\n", resp)
}
// Import classes:
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 = api.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();
        }
    }
}

Grant role to an archive

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

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

Overview

Adds a read role to an archive. (Roles API)

Arguments

Path Parameters

Name

Type

Description

archive_id [required]

string

The ID of the archive.

Request

Body Data

Expand All

Field

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"
  }
}

Response

OK

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Not found

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


                                        # Path parameters
export archive_id="CHANGE_ME"
# Curl command curl -X POST https://api.datadoghq.comhttps://api.datadoghq.eu/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.RelationshipToRole{Data: datadog.RelationshipToRoleData{Id: "Id_example", Type: datadog.RolesType{}}} // RelationshipToRole |  (optional)

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, 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 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 {
            api.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();
        }
    }
}

List read roles for an archive

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

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

Overview

Returns all read roles a given archive is restricted to.

Arguments

Path Parameters

Name

Type

Description

archive_id [required]

string

The ID of the archive.

Response

OK

Response containing information about multiple roles.

Expand All

Field

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

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Not found

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


                                        # Path parameters
export archive_id="CHANGE_ME"
# Curl command curl -X GET https://api.datadoghq.comhttps://api.datadoghq.eu/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"
    "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.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
    fmt.Fprintf(os.Stdout, "Response from `LogsArchivesApi.ListArchiveReadRoles`: %v\n", resp)
}
// Import classes:
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 = api.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();
        }
    }
}

Revoke role from an archive

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

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

Overview

Removes a role from an archive. (Roles API)

Arguments

Path Parameters

Name

Type

Description

archive_id [required]

string

The ID of the archive.

Request

Body Data

Expand All

Field

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"
  }
}

Response

OK

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Not found

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


                                        # Path parameters
export archive_id="CHANGE_ME"
# Curl command curl -X DELETE https://api.datadoghq.comhttps://api.datadoghq.eu/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.RelationshipToRole{Data: datadog.RelationshipToRoleData{Id: "Id_example", Type: datadog.RolesType{}}} // RelationshipToRole |  (optional)

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, 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 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 {
            api.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();
        }
    }
}

Update an archive

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

Overview

Update a given archive configuration.

Note: Using this method updates your archive configuration by replacing your current configuration with the new one sent to your Datadog organization.

Arguments

Path Parameters

Name

Type

Description

archive_id [required]

string

The ID of the archive.

Request

Body Data (required)

New definition of the archive.

Expand All

Field

Type

Description

data

object

The definition of an archive.

attributes

object

The attributes associated with the archive.

destination [required]

object

An archive's destination.

name [required]

string

The archive name.

query [required]

string

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

type [required]

string

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

{
  "data": {
    "attributes": {
      "destination": {},
      "name": "Nginx Archive",
      "query": "source:nginx"
    },
    "type": "archives"
  }
}

Response

OK

The logs archive.

Expand All

Field

Type

Description

data

object

The definition of an archive.

attributes

object

The attributes associated with the archive.

destination [required]

object

An archive's destination.

name [required]

string

The archive name.

query [required]

string

The archive query/filter. Logs matching this query are included in the 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": {},
      "name": "Nginx Archive",
      "query": "source:nginx",
      "state": "WORKING"
    },
    "id": "a2zcMylnM4OCHpYusxIi3g",
    "type": "archives"
  }
}

Bad Request

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Forbidden

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Not found

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example


                                        # Path parameters
export archive_id="CHANGE_ME"
# Curl command curl -X PUT https://api.datadoghq.comhttps://api.datadoghq.eu/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"
    "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.LogsArchiveCreateRequest{Data: datadog.LogsArchiveCreateRequestDefinition{Attributes: datadog.LogsArchiveCreateRequestAttributes{Destination: datadog.LogsArchiveCreateRequestDestination{Container: "Container_example", Integration: datadog.LogsArchiveIntegrationS3{AccountId: "AccountId_example", RoleName: "RoleName_example"}, Path: "Path_example", Region: "Region_example", StorageAccount: "StorageAccount_example", Type: datadog.LogsArchiveDestinationS3Type{}, Bucket: "Bucket_example"}, Name: "Name_example", Query: "Query_example"}, Type: "Type_example"}} // LogsArchiveCreateRequest | New definition of the archive.

    configuration := datadog.NewConfiguration()
    api_client := datadog.NewAPIClient(configuration)
    resp, r, err := api_client.LogsArchivesApi.UpdateLogsArchive(ctx, archiveId, 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
    fmt.Fprintf(os.Stdout, "Response from `LogsArchivesApi.UpdateLogsArchive`: %v\n", resp)
}
// Import classes:
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 = api.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();
        }
    }
}