Investigate a timeseries anomaly
https://api.datadoghq.com/api/v2/timeseries-anomaly-investigationshttps://api.us3.datadoghq.com/api/v2/timeseries-anomaly-investigationshttps://api.us5.datadoghq.com/api/v2/timeseries-anomaly-investigationshttps://api.datadoghq.eu/api/v2/timeseries-anomaly-investigationshttps://api.ap1.datadoghq.com/api/v2/timeseries-anomaly-investigationshttps://api.ap2.datadoghq.com/api/v2/timeseries-anomaly-investigationshttps://api.uk1.datadoghq.com/api/v2/timeseries-anomaly-investigationshttps://api.ddog-gov.com/api/v2/timeseries-anomaly-investigationshttps://api.us2.ddog-gov.com/api/v2/timeseries-anomaly-investigations概要
Investigates a metrics timeseries request for its most significant anomalies and returns deterministic findings. Metrics queries with or without grouping are supported. This API version accepts exactly one request and returns at most three anomalies.
OAuth apps require the timeseries_query, metrics_read authorization scope to access this endpoint.
リクエスト
Body Data (required)
Metrics timeseries request to investigate. The request body must not exceed 2 MiB.
data [required]JSON:API resource containing an anomaly investigation request.
attributes [required]Attributes of an anomaly investigation request.
requests [required]Timeseries requests to investigate. This API version accepts exactly one request.
formulas [required]Formulas to evaluate. Each formula may contain an explicit anomalies() call or a supported metrics expression.
formula [required]Formula expression referencing one or more named queries.
When the expression does not contain an explicit anomalies() call,
the endpoint applies the default Watchdog Explains anomaly detection configuration.
limitOptional formula limit accepted for compatibility with Timeseries API requests. Formula limits have no effect on timeseries queries.
countRequested result limit. This field has no effect on a timeseries anomaly investigation.
orderSort order used when applying a formula series limit.
asc, descfrom [required]Start of the investigation time window in milliseconds since the Unix epoch.
intervalOptional requested aggregation interval in milliseconds.
queries [required]Metrics queries referenced by the formulas.
aggregatorOptional scalar aggregator accepted for request compatibility. This field is ignored for timeseries queries.
cross_org_uuidsOptional organization UUID used for a cross-organization query. Each query accepts at most one UUID; use separate queries for separate organizations. Influential-tag analysis is currently unsupported for cross-organization queries, but anomaly detection still runs.
data_source [required]Data source for an anomaly investigation query.
metricsname [required]Name used to reference this query from formulas.
query [required]Datadog metrics query expression.
to [required]End of the investigation time window in milliseconds since the Unix epoch. Must be later than from.
type [required]Resource type for a timeseries anomaly investigation.
timeseries_anomaly_investigation{
"data": {
"attributes": {
"requests": [
{
"formulas": [
{
"formula": "query1",
"limit": {
"count": 10,
"order": "desc"
}
}
],
"from": 1754406000000,
"interval": 60000,
"queries": [
{
"aggregator": "avg",
"cross_org_uuids": [
"00000000-0000-0000-0000-000000000000"
],
"data_source": "metrics",
"name": "query1",
"query": "avg:system.cpu.user{env:prod} by {service}"
}
],
"to": 1754423940000
}
]
},
"type": "timeseries_anomaly_investigation"
}
}応答
OK
Response containing the anomaly investigation results and timeseries metadata.
data [required]JSON:API resource containing anomaly investigation results.
attributes [required]Attributes of an anomaly investigation response.
results [required]Results returned in the same order as the submitted requests. This API version returns exactly one result.
anomalies [required]Detected anomalies, ordered by significance. This API version returns at most three anomalies across the submitted request.
anomaly_detection [required]Anomaly detection configuration used for the result.
configuration_source [required]Source of the anomaly detection configuration.
request_formula, watchdog_explains_defaultprofile [required]Applied Watchdog Explains profile, or null when the request supplied an explicit anomalies() formula. The current Watchdog profile is watchdog_explains_v1.
detected_interval [required]Inclusive time interval in milliseconds since the Unix epoch.
end [required]Timestamp of the final point in the interval.
start [required]Inclusive start of the interval.
display_interval [required]Inclusive time interval in milliseconds since the Unix epoch.
end [required]Timestamp of the final point in the interval.
start [required]Inclusive start of the interval.
findings [required]Deterministic explanations for the anomaly, ordered by importance.
<type=influential_tag>Finding that attributes an anomaly to an influential tag.
description [required]Deterministic explanation of the finding.
headline [required]Concise, deterministic finding title.
tag [required]Structured tag evidence for an influential-tag finding.
influence_type [required]Kind of influence a tag has on a series.
shape, valuekey [required]Influential tag key.
rating [required]Influence rating from 1 through 5.
synonyms [required]Tags grouped with this tag by Variation of Influence synonym analysis.
key [required]Synonymous tag key.
values [required]Values associated with the synonymous tag.
values [required]Influential values for the tag key.
type [required]Finding category for an influential tag.
influential_tag<type=anomaly>Finding that describes the anomaly when completed analysis produces no displayable influential tags.
description [required]Deterministic explanation of the finding.
headline [required]Concise, deterministic finding title.
type [required]Finding category for an anomaly without a displayable influential tag.
anomalymaximum_deviation [required]Most anomalous point within the detected interval.
delta_from_boundary [required]Absolute distance between the observed value and the nearest anomaly boundary.
timestamp [required]Point timestamp in milliseconds since the Unix epoch.
value [required]Observed value at the point.
series [required]Logical series on which the anomaly was detected.
group_tags [required]Tags identifying the selected group. Empty for a query without grouping.
label [required]Display label for the selected series.
query_index [required]Zero-based index of the caller's formula that produced the series.
tag_analysis [required]Summary of optional influential-tag enrichment. Count and key fields are present only when analysis completes; enrichment availability does not affect completion of the investigation result.
analyzed_tag_keysTag keys analyzed. Present only when analysis completes.
status [required]Outcome of optional influential-tag enrichment.
complete, unsupported, failedtag_keys_analyzedNumber of tag keys analyzed. Present only when analysis completes.
tag_values_analyzedNumber of tag values analyzed. Present only when analysis completes.
type [required]Direction of an anomaly relative to its expected range.
spike, dipstatus [required]Status value indicating successful completion.
completeid [required]Stable identifier for an anomaly investigation response resource.
0type [required]Resource type for a timeseries anomaly investigation.
timeseries_anomaly_investigationmeta [required]Timeseries execution metadata for the single request accepted by this API version.
from_date [required]Effective start of the timeseries query in milliseconds since the Unix epoch.
interval [required]Effective timeseries interval in milliseconds.
queries [required]Execution status for the request's queries.
name [required]Query name from the request.
status [required]Current execution status for a named query.
running, doneres_type [required]Response metadata type for a timeseries anomaly investigation.
timeseries_anomaly_investigationresults_warnings [required]Non-fatal warnings produced while executing the investigation.
message [required]Human-readable warning message.
name [required]Machine-readable warning name.
to_date [required]Effective end of the timeseries query in milliseconds since the Unix epoch.
{
"data": {
"attributes": {
"results": [
{
"anomalies": [
{
"anomaly_detection": {
"configuration_source": "request_formula",
"profile": null
},
"detected_interval": {
"end": 1754406120000,
"start": 1754406060000
},
"display_interval": {
"end": 1754406120000,
"start": 1754406060000
},
"findings": [
[]
],
"maximum_deviation": {
"delta_from_boundary": 7,
"timestamp": 1754406090000,
"value": 42
},
"series": {
"group_tags": [
"service:api"
],
"label": "api",
"query_index": 0
},
"tag_analysis": {
"analyzed_tag_keys": [
"service",
"env"
],
"status": "complete",
"tag_keys_analyzed": 2,
"tag_values_analyzed": 4
},
"type": "spike"
}
],
"status": "complete"
}
]
},
"id": "0",
"type": "timeseries_anomaly_investigation"
},
"meta": {
"from_date": 1754406000000,
"interval": 60000,
"queries": [
{
"name": "query1",
"status": "done"
}
],
"res_type": "timeseries_anomaly_investigation",
"results_warnings": [
{
"message": "Influential tag analysis failed for at least one detected anomaly.",
"name": "tag_analysis_failed"
}
],
"to_date": 1754423940000
}
}Bad Request
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Unauthorized
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Forbidden
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Payload Too Large
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Unprocessable Entity
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}コード例
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/timeseries-anomaly-investigations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"from": 1754406000000,
"queries": [
{
"data_source": "metrics",
"name": "query1",
"query": "avg:system.cpu.user{env:prod} by {service}"
}
],
"to": 1754423940000
}
]
},
"type": "timeseries_anomaly_investigation"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/timeseries-anomaly-investigations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"from": 1754406000000,
"queries": [
{
"data_source": "metrics",
"name": "query1",
"query": "avg:system.cpu.user{env:prod} by {service}"
}
],
"to": 1754423940000
}
]
},
"type": "timeseries_anomaly_investigation"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/timeseries-anomaly-investigations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"from": 1754406000000,
"queries": [
{
"data_source": "metrics",
"name": "query1",
"query": "avg:system.cpu.user{env:prod} by {service}"
}
],
"to": 1754423940000
}
]
},
"type": "timeseries_anomaly_investigation"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/timeseries-anomaly-investigations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"from": 1754406000000,
"queries": [
{
"data_source": "metrics",
"name": "query1",
"query": "avg:system.cpu.user{env:prod} by {service}"
}
],
"to": 1754423940000
}
]
},
"type": "timeseries_anomaly_investigation"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/timeseries-anomaly-investigations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"from": 1754406000000,
"queries": [
{
"data_source": "metrics",
"name": "query1",
"query": "avg:system.cpu.user{env:prod} by {service}"
}
],
"to": 1754423940000
}
]
},
"type": "timeseries_anomaly_investigation"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/timeseries-anomaly-investigations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"from": 1754406000000,
"queries": [
{
"data_source": "metrics",
"name": "query1",
"query": "avg:system.cpu.user{env:prod} by {service}"
}
],
"to": 1754423940000
}
]
},
"type": "timeseries_anomaly_investigation"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/timeseries-anomaly-investigations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"from": 1754406000000,
"queries": [
{
"data_source": "metrics",
"name": "query1",
"query": "avg:system.cpu.user{env:prod} by {service}"
}
],
"to": 1754423940000
}
]
},
"type": "timeseries_anomaly_investigation"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/timeseries-anomaly-investigations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"from": 1754406000000,
"queries": [
{
"data_source": "metrics",
"name": "query1",
"query": "avg:system.cpu.user{env:prod} by {service}"
}
],
"to": 1754423940000
}
]
},
"type": "timeseries_anomaly_investigation"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/timeseries-anomaly-investigations" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"requests": [
{
"formulas": [
{
"formula": "query1"
}
],
"from": 1754406000000,
"queries": [
{
"data_source": "metrics",
"name": "query1",
"query": "avg:system.cpu.user{env:prod} by {service}"
}
],
"to": 1754423940000
}
]
},
"type": "timeseries_anomaly_investigation"
}
}
EOF// Investigate a timeseries anomaly returns "OK" response
package main
import (
"context"
"encoding/json"
"fmt"
"os"
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)
func main() {
body := datadogV2.TimeseriesAnomalyInvestigationRequest{
Data: datadogV2.TimeseriesAnomalyInvestigationRequestData{
Attributes: datadogV2.TimeseriesAnomalyInvestigationRequestAttributes{
Requests: []datadogV2.TimeseriesAnomalyInvestigationTimeseriesRequest{
{
Formulas: []datadogV2.TimeseriesAnomalyInvestigationFormula{
{
Formula: "query1",
},
},
From: 1754406000000,
Queries: []datadogV2.TimeseriesAnomalyInvestigationMetricQuery{
{
DataSource: datadogV2.TIMESERIESANOMALYINVESTIGATIONDATASOURCE_METRICS,
Name: "query1",
Query: "avg:system.cpu.user{env:prod} by {service}",
},
},
To: 1754423940000,
},
},
},
Type: datadogV2.TIMESERIESANOMALYINVESTIGATIONTYPE_TIMESERIES_ANOMALY_INVESTIGATION,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
configuration.SetUnstableOperationEnabled("v2.CreateTimeseriesAnomalyInvestigation", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewTimeseriesAnomalyInvestigationsApi(apiClient)
resp, r, err := api.CreateTimeseriesAnomalyInvestigation(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `TimeseriesAnomalyInvestigationsApi.CreateTimeseriesAnomalyInvestigation`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `TimeseriesAnomalyInvestigationsApi.CreateTimeseriesAnomalyInvestigation`:\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"// Investigate a timeseries anomaly returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.TimeseriesAnomalyInvestigationsApi;
import com.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationDataSource;
import com.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationFormula;
import com.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationMetricQuery;
import com.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationRequest;
import com.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationRequestAttributes;
import com.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationRequestData;
import com.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationResponse;
import com.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationTimeseriesRequest;
import com.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationType;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
defaultClient.setUnstableOperationEnabled("v2.createTimeseriesAnomalyInvestigation", true);
TimeseriesAnomalyInvestigationsApi apiInstance =
new TimeseriesAnomalyInvestigationsApi(defaultClient);
TimeseriesAnomalyInvestigationRequest body =
new TimeseriesAnomalyInvestigationRequest()
.data(
new TimeseriesAnomalyInvestigationRequestData()
.attributes(
new TimeseriesAnomalyInvestigationRequestAttributes()
.requests(
Collections.singletonList(
new TimeseriesAnomalyInvestigationTimeseriesRequest()
.formulas(
Collections.singletonList(
new TimeseriesAnomalyInvestigationFormula()
.formula("query1")))
.from(1754406000000L)
.queries(
Collections.singletonList(
new TimeseriesAnomalyInvestigationMetricQuery()
.dataSource(
TimeseriesAnomalyInvestigationDataSource
.METRICS)
.name("query1")
.query(
"avg:system.cpu.user{env:prod} by"
+ " {service}")))
.to(1754423940000L))))
.type(TimeseriesAnomalyInvestigationType.TIMESERIES_ANOMALY_INVESTIGATION));
try {
TimeseriesAnomalyInvestigationResponse result =
apiInstance.createTimeseriesAnomalyInvestigation(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling"
+ " TimeseriesAnomalyInvestigationsApi#createTimeseriesAnomalyInvestigation");
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""""
Investigate a timeseries anomaly returns "OK" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.timeseries_anomaly_investigations_api import TimeseriesAnomalyInvestigationsApi
from datadog_api_client.v2.model.timeseries_anomaly_investigation_data_source import (
TimeseriesAnomalyInvestigationDataSource,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_formula import TimeseriesAnomalyInvestigationFormula
from datadog_api_client.v2.model.timeseries_anomaly_investigation_metric_query import (
TimeseriesAnomalyInvestigationMetricQuery,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_request import TimeseriesAnomalyInvestigationRequest
from datadog_api_client.v2.model.timeseries_anomaly_investigation_request_attributes import (
TimeseriesAnomalyInvestigationRequestAttributes,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_request_data import (
TimeseriesAnomalyInvestigationRequestData,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_timeseries_request import (
TimeseriesAnomalyInvestigationTimeseriesRequest,
)
from datadog_api_client.v2.model.timeseries_anomaly_investigation_type import TimeseriesAnomalyInvestigationType
body = TimeseriesAnomalyInvestigationRequest(
data=TimeseriesAnomalyInvestigationRequestData(
attributes=TimeseriesAnomalyInvestigationRequestAttributes(
requests=[
TimeseriesAnomalyInvestigationTimeseriesRequest(
formulas=[
TimeseriesAnomalyInvestigationFormula(
formula="query1",
),
],
_from=1754406000000,
queries=[
TimeseriesAnomalyInvestigationMetricQuery(
data_source=TimeseriesAnomalyInvestigationDataSource.METRICS,
name="query1",
query="avg:system.cpu.user{env:prod} by {service}",
),
],
to=1754423940000,
),
],
),
type=TimeseriesAnomalyInvestigationType.TIMESERIES_ANOMALY_INVESTIGATION,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["create_timeseries_anomaly_investigation"] = True
with ApiClient(configuration) as api_client:
api_instance = TimeseriesAnomalyInvestigationsApi(api_client)
response = api_instance.create_timeseries_anomaly_investigation(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"# Investigate a timeseries anomaly returns "OK" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
config.unstable_operations["v2.create_timeseries_anomaly_investigation".to_sym] = true
end
api_instance = DatadogAPIClient::V2::TimeseriesAnomalyInvestigationsAPI.new
body = DatadogAPIClient::V2::TimeseriesAnomalyInvestigationRequest.new({
data: DatadogAPIClient::V2::TimeseriesAnomalyInvestigationRequestData.new({
attributes: DatadogAPIClient::V2::TimeseriesAnomalyInvestigationRequestAttributes.new({
requests: [
DatadogAPIClient::V2::TimeseriesAnomalyInvestigationTimeseriesRequest.new({
formulas: [
DatadogAPIClient::V2::TimeseriesAnomalyInvestigationFormula.new({
formula: "query1",
}),
],
from: 1754406000000,
queries: [
DatadogAPIClient::V2::TimeseriesAnomalyInvestigationMetricQuery.new({
data_source: DatadogAPIClient::V2::TimeseriesAnomalyInvestigationDataSource::METRICS,
name: "query1",
query: "avg:system.cpu.user{env:prod} by {service}",
}),
],
to: 1754423940000,
}),
],
}),
type: DatadogAPIClient::V2::TimeseriesAnomalyInvestigationType::TIMESERIES_ANOMALY_INVESTIGATION,
}),
})
p api_instance.create_timeseries_anomaly_investigation(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"// Investigate a timeseries anomaly returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_timeseries_anomaly_investigations::TimeseriesAnomalyInvestigationsAPI;
use datadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationDataSource;
use datadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationFormula;
use datadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationMetricQuery;
use datadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationRequest;
use datadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationRequestAttributes;
use datadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationRequestData;
use datadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationTimeseriesRequest;
use datadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationType;
#[tokio::main]
async fn main() {
let body =
TimeseriesAnomalyInvestigationRequest::new(TimeseriesAnomalyInvestigationRequestData::new(
TimeseriesAnomalyInvestigationRequestAttributes::new(vec![
TimeseriesAnomalyInvestigationTimeseriesRequest::new(
vec![TimeseriesAnomalyInvestigationFormula::new(
"query1".to_string(),
)],
1754406000000,
vec![TimeseriesAnomalyInvestigationMetricQuery::new(
TimeseriesAnomalyInvestigationDataSource::METRICS,
"query1".to_string(),
"avg:system.cpu.user{env:prod} by {service}".to_string(),
)],
1754423940000,
),
]),
TimeseriesAnomalyInvestigationType::TIMESERIES_ANOMALY_INVESTIGATION,
));
let mut configuration = datadog::Configuration::new();
configuration
.set_unstable_operation_enabled("v2.create_timeseries_anomaly_investigation", true);
let api = TimeseriesAnomalyInvestigationsAPI::with_config(configuration);
let resp = api.create_timeseries_anomaly_investigation(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="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Investigate a timeseries anomaly returns "OK" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
configuration.unstableOperations["v2.createTimeseriesAnomalyInvestigation"] =
true;
const apiInstance = new v2.TimeseriesAnomalyInvestigationsApi(configuration);
const params: v2.TimeseriesAnomalyInvestigationsApiCreateTimeseriesAnomalyInvestigationRequest =
{
body: {
data: {
attributes: {
requests: [
{
formulas: [
{
formula: "query1",
},
],
from: 1754406000000,
queries: [
{
dataSource: "metrics",
name: "query1",
query: "avg:system.cpu.user{env:prod} by {service}",
},
],
to: 1754423940000,
},
],
},
type: "timeseries_anomaly_investigation",
},
},
};
apiInstance
.createTimeseriesAnomalyInvestigation(params)
.then((data: v2.TimeseriesAnomalyInvestigationResponse) => {
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"