Flux for check offline host

Hi everyone,
I have few question for the community.
I want to make a board with 2 single stat, one with the online host and one with the offline host

I have find a flux command to list host online in a bucket =

from(bucket: "test")
    |> range(start: -1m)
    |> filter(fn: (r) => r._measurement == "system")
    |> filter(fn: (r) => r._field == "n_cpus")
    |> unique(column: "host")
    |> count()

But how can i do that with all my buckets (like a for buckets() do) ?

I have think about use the to() function to send all my data to a general bucket but i dont know if its possible.

Thanks.
Mike

@MikeSPROW In your example, your using the existence of n_cpus data to determine that a host is online. I assume that if a host is offline, it won’t report any data. Unless you have a fixed list or number of total hosts, there isn’t a way to tell if any are offline.

It’s possible to detect if a host was online, but is now offline using monitor.deadman. But I don’t know if this is exactly what you’re trying to do.

Thanks is a big part of what i want to do :grinning: but can i do this for all my bucket and/or org ? or i have to create à check for all my bucket ? I don’t know if in flux we can do some loops .
Thanks

You can only query a single bucket in a from() call, but you could join results from two buckets in a single query. You’d probably need a task for each bucket.

I want to create a dashboard with a single stat for the count of online host and one for the offline host. I can’t do a for loop so i have to create a task for all my bucket ?