How to aggregate bool values

  • What Grafana version and what operating system are you using?
    Grafana cloud

  • What are you trying to achieve?

I have a loki query that returns three values: timestamp, grafanaInstance, and a boolean value anyFailures. I can’t (easily) change this query because is used by multiple panels in the dashboard.

I want to aggregate this data by hour.

As shown in the image, there are many values for each hour.

I want the aggregated anyFailures field to be true if at least one value in the hour was true. I haven’t found any way to accomplish this.

I tried to convert it to a number (0,1) and then use min (to get 0 if there was at least one 0) But I couldn’t find a way to make this transformation from bool to number.

Neither could I find a way to reduce the multiple values I get into a single value using some aggregation other than mathematical functions (min, max, avg) that doesn’t apply to boolean values.

Thanks in advance