I want to create a notebook that shows me the availability of hosts, separated by the name of the hosts, but I can only do this using host.entity, how could I create this?
Hi @ArtuD
You can use this DQL:
timeseries avg(dt.host.availability), by:{dt.entity.host}
or
timeseries availability=sum(dt.host.availability),by:{availability.state,dt.metrics.source,dt.entity.host}
Regards,
Yes, but i want to do this whith host names, not host entity
I tried metric options, but still just the host.entity, just like in your print, something like
timeseries avg(dt.host.availability), by:{host.name}
You should use the lookup command in this case.
This is the code:
timeseries avg(dt.host.availability), by:{dt.entity.host}
| lookup [fetch dt.entity.host], lookupField:id , sourceField:dt.entity.host, prefix:"host."
| fields timeframe,interval,host.entity.name, `avg(dt.host.availability)`
Result:
Regards,
If metric has entity id, but does not have entity name (or yet another dimension), you can always enrich result using lookup command and referencing to entity model.
In my example I calculate % of availability for 2 hosts and add entity name from dt.entity.host
timeseries availability=avg(dt.host.availability), by:{dt.entity.host, availability.state}
, filter:in(dt.entity.host, {"HOST-86E98F7E966EA327","HOST-9F38503667743716"}), interval:5m
| summarize { availability = 100*sum(if(availability.state=="up",availability[])) / sum(availability[])},
by: {interval, timeframe, dt.entity.host}
| lookup [fetch dt.entity.host], sourceField:dt.entity.host, lookupField:id, fields:{entity.name}
Result looks like this:


