Datadog Terraform Timeshift Query

35 Views Asked by At

I am using a datadog terraform to write alert monitors. The query is:

sum(last_30m):sum:my_metric.count{field_1:val_1 AND field_2:val_2 AND field_3:val_3} by {field_1}.as_count() > 100

Now My target is to run this query for 3 day ago. Lets say current datetime is 5-March-2024_10:00AM, so this query will give me the result for the timeperiod of 5-March-2024_09:30AM to 5-March-2024_10:00AM.
Now my target is to write a query which will give me data for 2-March-2024_09:30AM to 2-March-2024_10:00AM (i.e. 3 day ago).
Is there something like timeshift in datadog terraform query?

I have seen timeshift in datadog but while using it in terraform ,it is not working.

1

There are 1 best solutions below

1
On

The below query does what you want. It works as expected when created through terarform.

sum(last_30m):timeshift(sum:my_metric.count{field_1:val_1 , field_2:val_2, field_3:val_3} by {field_1}.as_count(), -259200) > 100

Timeshifted data is primarily used together with the current values to get some useful insights. Why do you need it in a monitor?