Once before: yes, I found some topics nearly related but all of them didn’t solve my problem.
I’m collecting data of a cluster about current state of a node in a specific cluster. (idle,drain,down,alloc)
So with help of this forum I ended up here:
But this is not what I want. At the end I want to the count of each distinct value as the new table value so I can generate a graph how the cluster is used. This script above gives me the count of each value in whole timerange.
So, I have a query where I filtered out all not needed elements
start | end | timeframe | _value | count-of-state-in-timeframe
So I can get a nice graphical overview over time about state of cluster-nodes? Eg, for lines, one for each of the distinct values possible listed in the beginning.
@ra-albrecht This is a case where you want to use aggregateWindow() to calculate the count. It returns a stream of tables with aggregate values per window of time. And because you want a count of each distinct value, you could group by _value, but this will cause aggregateWindow() to fail because you can’t aggregate a column that’s in the group key. So to accomplish the same thing, duplicate the _value column into a new column and add the new column to the group key. This will give you unique tables for each distinct value without losing the rows with those values.
Eg, I had to set the aggregation window to one minute (interval of measurement), because using windowPeriod would result in a strange behavior of result data.
And looks like I have to skip the very first column because the count there is always 0.