Number or count of a object

Hi team,

Below query from Grafana is giving us time series metrics of “utilization_average” of all “esxhostname”s.

SELECT mean("utilization_average") FROM "vsphere_host_cpu" WHERE time >= now() - 1h and time <= now() GROUP BY time(2s), "esxhostname" fill(null)

But now we need to get the number of “esxhostname” present in the db “vsphere_host_cpu”.

We are trying below query but its not working;

**SELECT count(esxhostname) FROM " vsphere_host_cpu”**

Can someone guide us with the correct query so that we can see the number of “esxhostname” present.

My guess (it may need some minor polishing):

SELECT COUNT(DISTINCT "esxhostname")
FROM (
  SELECT mean("utilization_average") 
  FROM "vsphere_host_cpu" 
  WHERE time >= now() - 1h and time <= now() 
  GROUP BY time(1d), "esxhostname" fill(null)
)