25 Feb 2025
06:56 PM
- last edited on
26 Feb 2025
11:37 AM
by
MaciejNeumann
I have os:service entities tagged with an Uptime tag - I want to get availability metrics only for those services via API.
Here is my current metric selector that does not consider tags. It works in API v2:
(builtin:osservice.availability:filter(prefix("dt.entity.os:service",CUSTOM_DEVICE-)):filter(or(eq("dt.osservice.status",running),eq("dt.osservice.status",active))):sum:auto:sort(value(sum,descending)):splitBy("dt.entity.host","dt.entity.os:service")/builtin:osservice.availability:filter(prefix("dt.entity.os:service",CUSTOM_DEVICE-)):sum:auto:sort(value(sum, descending)):splitBy("dt.entity.host","dt.entity.os:service")*100):setUnit(Percent):sort(dimension("dt.entity.host",ascending),dimension("dt.entity.os:service",ascending))
How can I edit it to filter by specific tags?
That's what I have tried so far:
In DT API Swagger page I can specify EntitySelector:
type(os:service),tag(Uptime)
, which suppose to do it, but I'm getting this error:
"Entity type mismatch: the entity selector matches type `os:service`, but no primary entity dimension in the given metric selector has such type. Possible primary entity types: [`HOST`]. Alternatively, use an embedded entity selector. For example, `yourMetricKey:filter(in(dt.entity.disk, entitySelector(\"...\"))`."
I followed the advice and tried to use embedded entitySelector :
filter(in("dt.entity.os:service",entitySelector(type("os:service"),tag(Uptime)))
And now here is the result:
"Metric selector parse error: expected one argument for `entitySelector`"
Any idea how can I grab this metric only for tagged os:service entities?
Thanks,
Oleg
26 Feb 2025 05:41 AM
Hi Oleg,
Have you tried to filter by OS Service - Tag?
Or you've tried but you receive any error to add this filter to the rest of filters you need to your metric?
Regards,
Elena.