21 Mar 2024 07:11 PM
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?
Solved! Go to Solution.
21 Mar 2024 07:36 PM
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,
21 Mar 2024 07:38 PM
Yes, but i want to do this whith host names, not host entity
21 Mar 2024 07:49 PM
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,
21 Mar 2024 07:41 PM
And maybe you can use the metrics option in Notebooks. It's easier to find the right metric.
21 Mar 2024 07:44 PM
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}
21 Mar 2024 07:54 PM
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: