インデックスを更新する
https://api.datadoghq.com/api/v1/logs/config/indexes/{name}https://api.us3.datadoghq.com/api/v1/logs/config/indexes/{name}https://api.us5.datadoghq.com/api/v1/logs/config/indexes/{name}https://api.datadoghq.eu/api/v1/logs/config/indexes/{name}https://api.ap1.datadoghq.com/api/v1/logs/config/indexes/{name}https://api.ap2.datadoghq.com/api/v1/logs/config/indexes/{name}https://api.uk1.datadoghq.com/api/v1/logs/config/indexes/{name}https://api.ddog-gov.com/api/v1/logs/config/indexes/{name}https://api.us2.ddog-gov.com/api/v1/logs/config/indexes/{name}概要
名前で指定されたインデックスを更新します。 リクエストが成功した場合、リクエストボディで渡された Index オブジェクトを返します。
PUT メソッドを使用すると、インデックスの構成が更新され、
現在の構成が Datadog 組織に送信された新しい構成に 置き換えられます。
引数
パスパラメーター
name [required]Name of the log index.
リクエスト
Body Data (required)
新しい LogsIndexUpdateRequest を含むオブジェクト。
daily_limitDatadog ログインデックスを更新するためのオブジェクト。
daily_limit_resetObject containing options to override the default daily limit reset time.
reset_timeString in HH:00 format representing the time of day the daily limit should be reset. The hours must be between 00 and 23 (inclusive).
reset_utc_offsetString in (-|+)HH:00 format representing the UTC offset to apply to the given reset time. The hours must be between -12 and +14 (inclusive).
daily_limit_warning_threshold_percentageA percentage threshold of the daily quota at which a Datadog warning event is generated.
disable_daily_limitIf true, sets the daily_limit value to null and the index is not limited on a daily basis (any
specified daily_limit value in the request is ignored). If false or omitted, the index's current
daily_limit is maintained.
exclusion_filtersAn array of exclusion objects. The logs are tested against the query of each filter, following the order of the array. Only the first matching active exclusion matters, others (if any) are ignored.
filterExclusion filter is defined by a query, a sampling rule, and a active/inactive toggle.
queryDefault query is *, meaning all logs flowing in the index would be excluded.
Scope down exclusion filter to only a subset of logs with a log query.
sample_attributeSample attribute to use for the sampling of logs going through this exclusion filter. When set, only the logs with the specified attribute are sampled.
sample_rate [required]Sample rate to apply to logs going through this exclusion filter, a value of 1.0 excludes all logs matching the query.
is_enabledWhether or not the exclusion filter is active.
name [required]Name of the index exclusion filter.
filter [required]Filter for logs.
queryThe filter query.
num_flex_logs_retention_daysThe total number of days logs are stored in Standard and Flex Tier before being deleted from the index.
If Standard Tier is enabled on this index, logs are first retained in Standard Tier for the number of days specified through num_retention_days,
and then stored in Flex Tier until the number of days specified in num_flex_logs_retention_days is reached.
The available values depend on retention plans specified in your organization's contract/subscriptions.
Note: Changing this value affects all logs already in this index. It may also affect billing.
num_retention_daysThe number of days logs are stored in Standard Tier before aging into the Flex Tier or being deleted from the index. The available values depend on retention plans specified in your organization's contract/subscriptions.
Note: Changing this value affects all logs already in this index. It may also affect billing.
tagsA list of tags associated with the index. Tags must be in key:value format.
{
"daily_limit": 300000000,
"daily_limit_reset": {
"reset_time": "14:00",
"reset_utc_offset": "+02:00"
},
"daily_limit_warning_threshold_percentage": 70,
"disable_daily_limit": false,
"exclusion_filters": [
{
"filter": {
"query": "*",
"sample_attribute": "@ci.job_id",
"sample_rate": 1
},
"is_enabled": false,
"name": "payment"
}
],
"filter": {
"query": "source:python"
},
"num_flex_logs_retention_days": 360,
"num_retention_days": 15,
"tags": [
"team:backend",
"env:production"
]
}応答
OK
Object describing a Datadog Log index.
daily_limitThe number of log events you can send in this index per day before you are rate-limited.
daily_limit_resetObject containing options to override the default daily limit reset time.
reset_timeString in HH:00 format representing the time of day the daily limit should be reset. The hours must be between 00 and 23 (inclusive).
reset_utc_offsetString in (-|+)HH:00 format representing the UTC offset to apply to the given reset time. The hours must be between -12 and +14 (inclusive).
daily_limit_warning_threshold_percentageA percentage threshold of the daily quota at which a Datadog warning event is generated.
exclusion_filtersAn array of exclusion objects. The logs are tested against the query of each filter, following the order of the array. Only the first matching active exclusion matters, others (if any) are ignored.
filterExclusion filter is defined by a query, a sampling rule, and a active/inactive toggle.
queryDefault query is *, meaning all logs flowing in the index would be excluded.
Scope down exclusion filter to only a subset of logs with a log query.
sample_attributeSample attribute to use for the sampling of logs going through this exclusion filter. When set, only the logs with the specified attribute are sampled.
sample_rate [required]Sample rate to apply to logs going through this exclusion filter, a value of 1.0 excludes all logs matching the query.
is_enabledWhether or not the exclusion filter is active.
name [required]Name of the index exclusion filter.
filter [required]Filter for logs.
queryThe filter query.
is_rate_limitedA boolean stating if the index is rate limited, meaning more logs than the daily limit have been sent. Rate limit is reset every-day at 2pm UTC.
name [required]The name of the index.
num_flex_logs_retention_daysThe total number of days logs are stored in Standard and Flex Tier before being deleted from the index.
If Standard Tier is enabled on this index, logs are first retained in Standard Tier for the number of days specified through num_retention_days,
and then stored in Flex Tier until the number of days specified in num_flex_logs_retention_days is reached.
The available values depend on retention plans specified in your organization's contract/subscriptions.
num_retention_daysThe number of days logs are stored in Standard Tier before aging into the Flex Tier or being deleted from the index. The available values depend on retention plans specified in your organization's contract/subscriptions.
tagsA list of tags associated with the index. Tags must be in key:value format.
{
"daily_limit": 300000000,
"daily_limit_reset": {
"reset_time": "14:00",
"reset_utc_offset": "+02:00"
},
"daily_limit_warning_threshold_percentage": 70,
"exclusion_filters": [
{
"filter": {
"query": "*",
"sample_attribute": "@ci.job_id",
"sample_rate": 1
},
"is_enabled": false,
"name": "payment"
}
],
"filter": {
"query": "source:python"
},
"is_rate_limited": false,
"name": "main",
"num_flex_logs_retention_days": 360,
"num_retention_days": 15,
"tags": [
"team:backend",
"env:production"
]
}Invalid Parameter Error
Response returned by the Logs API when errors occur.
errorError returned by the Logs API
codeCode identifying the error
detailsAdditional error details
messageError message
{
"error": {
"code": "string",
"details": [],
"message": "string"
}
}Forbidden
Error response object.
errors [required]Array of errors returned by the API.
{
"errors": [
"Bad Request"
]
}Too Many Requests
Response returned by the Logs API when errors occur.
errorError returned by the Logs API
codeCode identifying the error
detailsAdditional error details
messageError message
{
"error": {
"code": "string",
"details": [],
"message": "string"
}
}コード例
# Path parameters
export name="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v1/logs/config/indexes/${name}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"daily_limit": 300000000,
"daily_limit_warning_threshold_percentage": 70,
"disable_daily_limit": false,
"exclusion_filters": [
{
"filter": {
"query": "*",
"sample_rate": 1
},
"is_enabled": true,
"name": "payment"
}
],
"filter": {
"query": "source:python"
},
"num_retention_days": 15
}
EOF# Path parameters
export name="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v1/logs/config/indexes/${name}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"daily_limit": 300000000,
"daily_limit_warning_threshold_percentage": 70,
"disable_daily_limit": false,
"exclusion_filters": [
{
"filter": {
"query": "*",
"sample_rate": 1
},
"is_enabled": true,
"name": "payment"
}
],
"filter": {
"query": "source:python"
},
"num_retention_days": 15
}
EOF# Path parameters
export name="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v1/logs/config/indexes/${name}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"daily_limit": 300000000,
"daily_limit_warning_threshold_percentage": 70,
"disable_daily_limit": false,
"exclusion_filters": [
{
"filter": {
"query": "*",
"sample_rate": 1
},
"is_enabled": true,
"name": "payment"
}
],
"filter": {
"query": "source:python"
},
"num_retention_days": 15
}
EOF# Path parameters
export name="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v1/logs/config/indexes/${name}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"daily_limit": 300000000,
"daily_limit_warning_threshold_percentage": 70,
"disable_daily_limit": false,
"exclusion_filters": [
{
"filter": {
"query": "*",
"sample_rate": 1
},
"is_enabled": true,
"name": "payment"
}
],
"filter": {
"query": "source:python"
},
"num_retention_days": 15
}
EOF# Path parameters
export name="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v1/logs/config/indexes/${name}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"daily_limit": 300000000,
"daily_limit_warning_threshold_percentage": 70,
"disable_daily_limit": false,
"exclusion_filters": [
{
"filter": {
"query": "*",
"sample_rate": 1
},
"is_enabled": true,
"name": "payment"
}
],
"filter": {
"query": "source:python"
},
"num_retention_days": 15
}
EOF# Path parameters
export name="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v1/logs/config/indexes/${name}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"daily_limit": 300000000,
"daily_limit_warning_threshold_percentage": 70,
"disable_daily_limit": false,
"exclusion_filters": [
{
"filter": {
"query": "*",
"sample_rate": 1
},
"is_enabled": true,
"name": "payment"
}
],
"filter": {
"query": "source:python"
},
"num_retention_days": 15
}
EOF# Path parameters
export name="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v1/logs/config/indexes/${name}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"daily_limit": 300000000,
"daily_limit_warning_threshold_percentage": 70,
"disable_daily_limit": false,
"exclusion_filters": [
{
"filter": {
"query": "*",
"sample_rate": 1
},
"is_enabled": true,
"name": "payment"
}
],
"filter": {
"query": "source:python"
},
"num_retention_days": 15
}
EOF# Path parameters
export name="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v1/logs/config/indexes/${name}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"daily_limit": 300000000,
"daily_limit_warning_threshold_percentage": 70,
"disable_daily_limit": false,
"exclusion_filters": [
{
"filter": {
"query": "*",
"sample_rate": 1
},
"is_enabled": true,
"name": "payment"
}
],
"filter": {
"query": "source:python"
},
"num_retention_days": 15
}
EOF# Path parameters
export name="CHANGE_ME"
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X PUT "https://api.${DD_SITE}/api/v1/logs/config/indexes/${name}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"daily_limit": 300000000,
"daily_limit_warning_threshold_percentage": 70,
"disable_daily_limit": false,
"exclusion_filters": [
{
"filter": {
"query": "*",
"sample_rate": 1
},
"is_enabled": true,
"name": "payment"
}
],
"filter": {
"query": "source:python"
},
"num_retention_days": 15
}
EOF// Update an index returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV1"
)
func main() {
body := datadogV1.LogsIndexUpdateRequest{
DailyLimit: datadog.PtrInt64(300000000),
DailyLimitReset: &datadogV1.LogsDailyLimitReset{
ResetTime: datadog.PtrString("14:00"),
ResetUtcOffset: datadog.PtrString("+02:00"),
},
DailyLimitWarningThresholdPercentage: datadog.PtrFloat64(70),
DisableDailyLimit: datadog.PtrBool(false),
ExclusionFilters: []datadogV1.LogsExclusion{
{
Filter: &datadogV1.LogsExclusionFilter{
Query: datadog.PtrString("*"),
SampleAttribute: datadog.PtrString("@ci.job_id"),
SampleRate: 1.0,
},
Name: "payment",
},
},
Filter: datadogV1.LogsFilter{
Query: datadog.PtrString("source:python"),
},
NumFlexLogsRetentionDays: datadog.PtrInt64(360),
NumRetentionDays: datadog.PtrInt64(15),
Tags: []string{
"team:backend",
"env:production",
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV1.NewLogsIndexesApi(apiClient)
resp, r, err := api.UpdateLogsIndex(ctx, "name", body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `LogsIndexesApi.UpdateLogsIndex`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `LogsIndexesApi.UpdateLogsIndex`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Update an index returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.LogsIndexesApi;
import com.datadog.api.client.v1.model.LogsDailyLimitReset;
import com.datadog.api.client.v1.model.LogsExclusion;
import com.datadog.api.client.v1.model.LogsExclusionFilter;
import com.datadog.api.client.v1.model.LogsFilter;
import com.datadog.api.client.v1.model.LogsIndex;
import com.datadog.api.client.v1.model.LogsIndexUpdateRequest;
import java.util.Arrays;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
LogsIndexesApi apiInstance = new LogsIndexesApi(defaultClient);
LogsIndexUpdateRequest body =
new LogsIndexUpdateRequest()
.dailyLimit(300000000L)
.dailyLimitReset(new LogsDailyLimitReset().resetTime("14:00").resetUtcOffset("+02:00"))
.dailyLimitWarningThresholdPercentage(70.0)
.disableDailyLimit(false)
.exclusionFilters(
Collections.singletonList(
new LogsExclusion()
.filter(
new LogsExclusionFilter()
.query("*")
.sampleAttribute("@ci.job_id")
.sampleRate(1.0))
.name("payment")))
.filter(new LogsFilter().query("source:python"))
.numFlexLogsRetentionDays(360L)
.numRetentionDays(15L)
.tags(Arrays.asList("team:backend", "env:production"));
try {
LogsIndex result = apiInstance.updateLogsIndex("name", body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling LogsIndexesApi#updateLogsIndex");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Instructions
First install the library and its dependencies and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Update an index returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.logs_indexes_api import LogsIndexesApi
from datadog_api_client.v1.model.logs_daily_limit_reset import LogsDailyLimitReset
from datadog_api_client.v1.model.logs_exclusion import LogsExclusion
from datadog_api_client.v1.model.logs_exclusion_filter import LogsExclusionFilter
from datadog_api_client.v1.model.logs_filter import LogsFilter
from datadog_api_client.v1.model.logs_index_update_request import LogsIndexUpdateRequest
body = LogsIndexUpdateRequest(
daily_limit=300000000,
daily_limit_reset=LogsDailyLimitReset(
reset_time="14:00",
reset_utc_offset="+02:00",
),
daily_limit_warning_threshold_percentage=70.0,
disable_daily_limit=False,
exclusion_filters=[
LogsExclusion(
filter=LogsExclusionFilter(
query="*",
sample_attribute="@ci.job_id",
sample_rate=1.0,
),
name="payment",
),
],
filter=LogsFilter(
query="source:python",
),
num_flex_logs_retention_days=360,
num_retention_days=15,
tags=[
"team:backend",
"env:production",
],
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = LogsIndexesApi(api_client)
response = api_instance.update_logs_index(name="name", body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Update an index returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V1::LogsIndexesAPI.new
body = DatadogAPIClient::V1::LogsIndexUpdateRequest.new({
daily_limit: 300000000,
daily_limit_reset: DatadogAPIClient::V1::LogsDailyLimitReset.new({
reset_time: "14:00",
reset_utc_offset: "+02:00",
}),
daily_limit_warning_threshold_percentage: 70,
disable_daily_limit: false,
exclusion_filters: [
DatadogAPIClient::V1::LogsExclusion.new({
filter: DatadogAPIClient::V1::LogsExclusionFilter.new({
query: "*",
sample_attribute: "@ci.job_id",
sample_rate: 1.0,
}),
name: "payment",
}),
],
filter: DatadogAPIClient::V1::LogsFilter.new({
query: "source:python",
}),
num_flex_logs_retention_days: 360,
num_retention_days: 15,
tags: [
"team:backend",
"env:production",
],
})
p api_instance.update_logs_index("name", body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Update an index returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV1::api_logs_indexes::LogsIndexesAPI;
use datadog_api_client::datadogV1::model::LogsDailyLimitReset;
use datadog_api_client::datadogV1::model::LogsExclusion;
use datadog_api_client::datadogV1::model::LogsExclusionFilter;
use datadog_api_client::datadogV1::model::LogsFilter;
use datadog_api_client::datadogV1::model::LogsIndexUpdateRequest;
#[tokio::main]
async fn main() {
let body = LogsIndexUpdateRequest::new(LogsFilter::new().query("source:python".to_string()))
.daily_limit(300000000)
.daily_limit_reset(
LogsDailyLimitReset::new()
.reset_time("14:00".to_string())
.reset_utc_offset("+02:00".to_string()),
)
.daily_limit_warning_threshold_percentage(70.0 as f64)
.disable_daily_limit(false)
.exclusion_filters(vec![LogsExclusion::new("payment".to_string()).filter(
LogsExclusionFilter::new(1.0)
.query("*".to_string())
.sample_attribute("@ci.job_id".to_string()),
)])
.num_flex_logs_retention_days(360)
.num_retention_days(15)
.tags(vec![
"team:backend".to_string(),
"env:production".to_string(),
]);
let configuration = datadog::Configuration::new();
let api = LogsIndexesAPI::with_config(configuration);
let resp = api.update_logs_index("name".to_string(), body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies and then save the example to src/main.rs and run following commands:
DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run/**
* Update an index returns "OK" response
*/
import { client, v1 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v1.LogsIndexesApi(configuration);
const params: v1.LogsIndexesApiUpdateLogsIndexRequest = {
body: {
dailyLimit: 300000000,
dailyLimitReset: {
resetTime: "14:00",
resetUtcOffset: "+02:00",
},
dailyLimitWarningThresholdPercentage: 70,
disableDailyLimit: false,
exclusionFilters: [
{
filter: {
query: "*",
sampleAttribute: "@ci.job_id",
sampleRate: 1.0,
},
name: "payment",
},
],
filter: {
query: "source:python",
},
numFlexLogsRetentionDays: 360,
numRetentionDays: 15,
tags: ["team:backend", "env:production"],
},
name: "name",
};
apiInstance
.updateLogsIndex(params)
.then((data: v1.LogsIndex) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"