17 Jun 2022 05:08 PM
I am fairly accomplished in pulling back time series data in the V2 API, but my question is this:
A user could in fact specify a tag name that has thousands of entities tied to it. For example - "server:servername" versus just "server".
Is there an easy was to pull back just the number of entities count for a particular tag?
I can use this as a pre-check safeguard to ensure my API will not try to pull back data for thousands of servers.
Any advice is appreciated.
Thanks,
Lou
Solved! Go to Solution.
17 Jun 2022 06:29 PM
You can use an entity selector on the /api/v2/entities endpoint of the Monitored Entities API. For example if you're looking for hosts with a specific tag:
type(HOST),tag("[context]key")
Or, if you're looking for hosts with a specific tag value:
type(HOST),tag("[context]key:value")
context is for specific types of tags like [Environment] or [Azure] and isn't needed if your tag does not have a context.
The JSON returned will have a "totalCount" which is the number of entities with a tag or tag:value. You can set your pagesize to 1 if all you're interested in is the total number of entities and not the list of entities.