Is there a sensible way to grab overall entity status? I’m thinking something like the way the Hostgroup Overview appears in Nagios/Icinga (a table with the first column being hostname, and second column showing how many checks are OK/WARNING/CRITICAL/UNKNOWN). With the current API, it seems that it would take an excessive number of API calls to generate this data (1 call per check per host).
The only idea I came up with was to actually generate this data in a scheduled check, but I was hoping there is a better way.
One alternative to consider would be in the dashboard using the entity: hostname Filter in the events view. That doesn’t provide a summary/count, however.
Though not its intended purpose, you could probably use the aggregate check to come up with a similar outcome.
Otherwise you could go the route of querying the API and building this information. However, rather than doing a query for each check per host, I would suggest using the events API and using response filtering with a fieldSelector=event.entity.name == hostname for each host. However, be aware that response filtering is a commercial feature.
I’ve been using the existing datasource for some dashboards, but it’s seems to be too limited for creating a dashboard like I’ve mentioned above. I was thinking of creating a custom source that would implement something similar to your code above. A custom panel might also work, but I think the custom data source might be a better option to reduce api queries.
The datasource repo has also had bug fixing pull requests sitting for half a year… Know anyone that can merge them into a new release?