Dashboard tile with number of hosts with CPU bigger than 80%?

In Data Explorer, if you want to have a list of hosts that have, eg. more than 80% of CPU for a certain timeframe, you put the following metric selector and select table:

builtin:host.cpu.usage:splitBy("dt.entity.host"):filter(series(avg,gt(80)))

Now imagine there are 10 hosts in the list and you want a single value in a dashboard with 10 in it. Been struggling to get this use-case done :rofl: Any ideas?
And yes, it’s for a Managed environment…

Hi @AntonioSousa , how about using the table and pin it to dashboard ?

I’m afraid it’s not possible, i was trying hard with similar task.

In fact table in data explorer is only way to really count records, but unfortunately, when pinned to dashboard that count is not displayed.

@AntonioSousa what about this?

builtin:host.cpu.usage:splitBy("dt.entity.host"):filter(series(avg,gt(10))):count:splitby():last

It’s not working - f.e. 5 hosts with cpu>0

@Julius_Loman

I tried your selector and it was very volatile. It would sometimes work, but others not.

But I have worked with it, and came to this one, only without the last:

builtin:host.cpu.usage:splitBy("dt.entity.host"):filter(series(avg,gt(80))):count:splitby()

This one seems to work perfectly!

Thanks for the double splitBy() idea!

I found out that you have to timeshift and then it’s finally working:

builtin:host.cpu.usage:splitBy(“dt.entity.host”):filter(series(avg,gt(0))):count:splitby():timeshift(-1m)

it’s b/c data from all records are not collected in last time bucket, for other metrics collected with >1m interval you will need to perform bigger timeshift. Here is examle of what you can get if doing last():

simple skipping :last() without timeshift() will also work for single value, but you need to let “Auto” or “Maximum” Fold transformation with global timeframe >1m:

If you skip the first splitBy() transformation, the expression can be simplified a bit and it still works.

The only requirement is that you apply the second splitBy() (in my case, the only one) before you apply the :count transformation, otherwise it won’t work.

As a result, I got this:

builtin:host.cpu.usage:filter(series(avg,gt(80))):splitBy():count

Hope this helps!

Thanks all for your input! Several ways to do something that I believe is a good use-case :hugs:
Which leaves me thinking that the efficiency of doing certain approaches in Data Explorer might lead to different usage of resources inside the Dynatrace platform.
Looks like @PedroDeodato metric selector is the most efficient, but does anyone have any idea which metric selectors are more efficient or not?

It was very useful for me as well, thanks for posting question! @PedroDeodato 's selector is ok, but you have to also check Fold transformation (for Single value visualization) to be in correct mode (Auto or Maximum).