Terraform: How to use the reduce functions in alert condition

Replying to this from the other thread, because the context in this thread is helpful:

@jangaraj, as we can see in my TF resource (or in @pepecano’s second screenshot), at least two queries are involved in the definition of an alert rule: the data source query and the alert condition query, to quote the docs:

The alert condition is the query or expression that determines whether the alert fires or not […].

Now whether you read the documentation or look at the code generated by default (using the export button), it feels like the reduce function is meant to be used on the alert condition query¹. And I don’t understand the point of doing that if you are not allowed to have a time series with more than one value in your alert condition.

It may just be that the generated code you can export is slightly nonsensical, that the documentation is confusing, and that the reduce functions are in fact not meant to be used on the alert condition queries, but on the data source queries only.

I’ve not talked with Grot about this, but I did talk with Sonnet 4.5, and the (low) quality of the response, as well as “classical search engines” results for the error message in my original post being for a different issue/context is why I made this thread in the first place.

edit: to be clear, I understand the alert condition can only be evaluated on a single value, I am not asking or arguing about that.


¹ And the Terraform resource in my original post had this attribute under model.conditions.0 in the second data block:

reducer = {
  params = [],
  type   = "last"
},

Which I removed because I didn’t understand how it made any sense.