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.
This endpoint requires
all
of the following permissions:
timeseries_query
metrics_read
OAuth apps require the timeseries_query, metrics_read authorization scope to access this endpoint.
Request
Body Data (required)
Metrics timeseries request to investigate. The request body must not exceed 2 MiB.
JSON:API resource containing an anomaly investigation request.
attributes [required]
object
Attributes of an anomaly investigation request.
requests [required]
[object]
Timeseries requests to investigate. This API version accepts exactly one request.
formulas [required]
[object]
Formulas to evaluate. Each formula may contain an explicit anomalies() call or a supported metrics expression.
formula [required]
string
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.
limit
object
Optional formula limit accepted for compatibility with Timeseries API requests. Formula limits have no effect on timeseries queries.
count
int64
Requested result limit. This field has no effect on a timeseries anomaly investigation.
order
enum
Sort order used when applying a formula series limit.
Allowed enum values: asc,desc
from [required]
int64
Start of the investigation time window in milliseconds since the Unix epoch.
interval
int64
Optional requested aggregation interval in milliseconds.
queries [required]
[object]
Metrics queries referenced by the formulas.
aggregator
string
Optional scalar aggregator accepted for request compatibility. This field is ignored for timeseries queries.
cross_org_uuids
[string]
Optional 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]
enum
Data source for an anomaly investigation query.
Allowed enum values: metrics
name [required]
string
Name used to reference this query from formulas.
query [required]
string
Datadog metrics query expression.
to [required]
int64
End of the investigation time window in milliseconds since the Unix epoch. Must be later than from.
type [required]
enum
Resource type for a timeseries anomaly investigation.
Allowed enum values: 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"}}
Results returned in the same order as the submitted requests. This API version returns exactly one result.
anomalies [required]
[object]
Detected anomalies, ordered by significance. This API version returns at most
three anomalies across the submitted request.
anomaly_detection [required]
object
Anomaly detection configuration used for the result.
configuration_source [required]
enum
Source of the anomaly detection configuration.
Allowed enum values: request_formula,watchdog_explains_default
profile [required]
string
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]
object
Inclusive time interval in milliseconds since the Unix epoch.
end [required]
int64
Timestamp of the final point in the interval.
start [required]
int64
Inclusive start of the interval.
display_interval [required]
object
Inclusive time interval in milliseconds since the Unix epoch.
end [required]
int64
Timestamp of the final point in the interval.
start [required]
int64
Inclusive start of the interval.
findings [required]
[ <oneOf>]
Deterministic explanations for the anomaly, ordered by importance.
<type=influential_tag>
object
Finding that attributes an anomaly to an influential tag.
description [required]
string
Deterministic explanation of the finding.
headline [required]
string
Concise, deterministic finding title.
tag [required]
object
Structured tag evidence for an influential-tag finding.
influence_type [required]
enum
Kind of influence a tag has on a series.
Allowed enum values: shape,value
key [required]
string
Influential tag key.
rating [required]
double
Influence rating from 1 through 5.
synonyms [required]
[object]
Tags grouped with this tag by Variation of Influence synonym analysis.
key [required]
string
Synonymous tag key.
values [required]
[string]
Values associated with the synonymous tag.
values [required]
[string]
Influential values for the tag key.
type [required]
enum
Finding category for an influential tag.
Allowed enum values: influential_tag
<type=anomaly>
object
Finding that describes the anomaly when completed analysis produces no displayable influential tags.
description [required]
string
Deterministic explanation of the finding.
headline [required]
string
Concise, deterministic finding title.
type [required]
enum
Finding category for an anomaly without a displayable influential tag.
Allowed enum values: anomaly
maximum_deviation [required]
object
Most anomalous point within the detected interval.
delta_from_boundary [required]
double
Absolute distance between the observed value and the nearest anomaly boundary.
timestamp [required]
int64
Point timestamp in milliseconds since the Unix epoch.
value [required]
double
Observed value at the point.
series [required]
object
Logical series on which the anomaly was detected.
group_tags [required]
[string]
Tags identifying the selected group. Empty for a query without grouping.
label [required]
string
Display label for the selected series.
query_index [required]
int64
Zero-based index of the caller's formula that produced the series.
tag_analysis [required]
object
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_keys
[string]
Tag keys analyzed. Present only when analysis completes.
status [required]
enum
Outcome of optional influential-tag enrichment.
Allowed enum values: complete,unsupported,failed
tag_keys_analyzed
int64
Number of tag keys analyzed. Present only when analysis completes.
tag_values_analyzed
int64
Number of tag values analyzed. Present only when analysis completes.
type [required]
enum
Direction of an anomaly relative to its expected range.
Allowed enum values: spike,dip
status [required]
enum
Status value indicating successful completion.
Allowed enum values: complete
id [required]
enum
Stable identifier for an anomaly investigation response resource.
Allowed enum values: 0
type [required]
enum
Resource type for a timeseries anomaly investigation.
Allowed enum values: timeseries_anomaly_investigation
meta [required]
object
Timeseries execution metadata for the single request accepted by this API version.
from_date [required]
int64
Effective start of the timeseries query in milliseconds since the Unix epoch.
interval [required]
int64
Effective timeseries interval in milliseconds.
queries [required]
[object]
Execution status for the request's queries.
name [required]
string
Query name from the request.
status [required]
enum
Current execution status for a named query.
Allowed enum values: running,done
res_type [required]
enum
Response metadata type for a timeseries anomaly investigation.
Allowed enum values: timeseries_anomaly_investigation
results_warnings [required]
[object]
Non-fatal warnings produced while executing the investigation.
message [required]
string
Human-readable warning message.
name [required]
string
Machine-readable warning name.
to_date [required]
int64
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}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"python3"example.py"
# Investigate a timeseries anomaly returns "OK" responserequire"datadog_api_client"DatadogAPIClient.configuredo|config|config.access_token=ENV["DD_BEARER_TOKEN"]config.unstable_operations["v2.create_timeseries_anomaly_investigation".to_sym]=trueendapi_instance=DatadogAPIClient::V2::TimeseriesAnomalyInvestigationsAPI.newbody=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,}),})papi_instance.create_timeseries_anomaly_investigation(body)
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"rb"example.rb"
// Investigate a timeseries anomaly returns "OK" responsepackagemainimport("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")funcmain(){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)iferr!=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)}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"go run"main.go"
// Investigate a timeseries anomaly returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.TimeseriesAnomalyInvestigationsApi;importcom.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationDataSource;importcom.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationFormula;importcom.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationMetricQuery;importcom.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationRequest;importcom.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationRequestAttributes;importcom.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationRequestData;importcom.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationResponse;importcom.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationTimeseriesRequest;importcom.datadog.api.client.v2.model.TimeseriesAnomalyInvestigationType;importjava.util.Collections;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));defaultClient.setUnstableOperationEnabled("v2.createTimeseriesAnomalyInvestigation",true);TimeseriesAnomalyInvestigationsApiapiInstance=newTimeseriesAnomalyInvestigationsApi(defaultClient);TimeseriesAnomalyInvestigationRequestbody=newTimeseriesAnomalyInvestigationRequest().data(newTimeseriesAnomalyInvestigationRequestData().attributes(newTimeseriesAnomalyInvestigationRequestAttributes().requests(Collections.singletonList(newTimeseriesAnomalyInvestigationTimeseriesRequest().formulas(Collections.singletonList(newTimeseriesAnomalyInvestigationFormula().formula("query1"))).from(1754406000000L).queries(Collections.singletonList(newTimeseriesAnomalyInvestigationMetricQuery().dataSource(TimeseriesAnomalyInvestigationDataSource.METRICS).name("query1").query("avg:system.cpu.user{env:prod} by"+" {service}"))).to(1754423940000L)))).type(TimeseriesAnomalyInvestigationType.TIMESERIES_ANOMALY_INVESTIGATION));try{TimeseriesAnomalyInvestigationResponseresult=apiInstance.createTimeseriesAnomalyInvestigation(body);System.out.println(result);}catch(ApiExceptione){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();}}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"java"Example.java"
// Investigate a timeseries anomaly returns "OK" response
usedatadog_api_client::datadog;usedatadog_api_client::datadogV2::api_timeseries_anomaly_investigations::TimeseriesAnomalyInvestigationsAPI;usedatadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationDataSource;usedatadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationFormula;usedatadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationMetricQuery;usedatadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationRequest;usedatadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationRequestAttributes;usedatadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationRequestData;usedatadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationTimeseriesRequest;usedatadog_api_client::datadogV2::model::TimeseriesAnomalyInvestigationType;#[tokio::main]asyncfnmain(){letbody=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,));letmutconfiguration=datadog::Configuration::new();configuration.set_unstable_operation_enabled("v2.CreateTimeseriesAnomalyInvestigation",true);letapi=TimeseriesAnomalyInvestigationsAPI::with_config(configuration);letresp=api.create_timeseries_anomaly_investigation(body).await;ifletOk(value)=resp{println!("{:#?}",value);}else{println!("{:#?}",resp.unwrap_err());}}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.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";constconfiguration=client.createConfiguration({authMethods:{AuthZ:{accessToken: process.env.DD_BEARER_TOKENasstring,},},});configuration.unstableOperations["v2.createTimeseriesAnomalyInvestigation"]=true;constapiInstance=newv2.TimeseriesAnomalyInvestigationsApi(configuration);constparams: 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));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"tsc"example.ts"
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.