I would like create a list of all servers and aggregate them by teams. If I do this with a single metric this is easy:
For Linux: count(node_uname_info) by (team)
And Windows: count(wmi_os_info) by (team)
But now I want to aggregate this two queries to one as I want to get count of total servers by team.
Normally I would do it like that:
count(node_uname_info) by (team) + count(wmi_os_info) by (team)
But now I get only the teams which own both Linux and Windows servers.
Is there a way to assume that a value is zero if it is not existent?
Queries I have tried:
count(node_uname_info) by (team) + count(wmi_os_info) by (team)
count(node_uname_info) by (team) + (count(wmi_os_info) by (team) > 0)
count(node_uname_info) by (team) + on(team) count(wmi_os_info) by (team)
Thanks!
As indicated in the documentation about binary operators, the elements that do not match are not part of the result:
Between two instant vectors, a binary arithmetic operator is applied to each entry in the left-hand side vector and its matching element in the right-hand vector[...] Entries for which no matching entry in the right-hand vector can be found are not part of the result.
But you can select multiple metrics using the __name__
internal label (see selectors) and the apply the count
on the resulting vector:
count({__name__=~"node_uname_info|wmi_os_info"}) by (team)