Hi,

On 6/25/20 4:05 PM, Al wrote:
> All hosts from which I collect node_exporter metrics each have an
> additional node_role metric (added via textfile collector) which
> identifies all the Chef roles a given host has.  As an example, say we
> have 3 hosts with the following textfile collector metrics:
> 
> *server1:*
> |
> node_role{role="web_server_app1"}
> |
> 
> *server2:*
> |
> node_role{role="redis_server"}
> |
> 
> *server3:*
> |
> node_role{role="db_server"}
> |
> 
> *server4:*
> |
> node_role{role="web_server_app2"}
> |
> 
> 
> 
> I'm attempting to write a PromQL query which will return the current
> disk usage % for hosts that do not have a specific role "web_server"
> assigned to them.  I've attempted the following PromQL query although
> it's invalid as we end up with many results on the right hand side,
> which doesn't match the many-to-one nature of the group left:
> 
> |
> 
> 100-(
> 
>    (node_filesystem_free_bytes{mountpoint=“”/data}*on
> (hostname)group_left(role)node_role{role!~“web_server.*”})
> 
>    /
> 
>    (node_filesystem_size_bytes{mountpoint=“”/data}*on
> (hostname)group_left(role)node_role{role!~“web_server”})
> 
>    *
> 
>    100
> 
> )
> 
> |
> 
> How could I modify this query so that it correctly return the disk usage
> percentage of server2 and server3?

The pattern basically looks fine.
Some remarks:

- Your quotation marks do not look like ASCII quotes -- I guess this
comes from pasting?
- The quotation marks around mountpoint= seem off (one should come after
/data).
- Your role regexp is not identical. The regexp in the second part lacks
the .* and will therefore match all your example servers.
- The role "join" can probably be omitted from the second part when
using on(instance, mountpoint)

In general I suggest trying the parts of your query individually and
only putting them into the larger query once both parts return what you
need.

Kind regards,
Christian

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/9e2af627-d490-7eba-9738-faa6b72e1758%40hoffmann-christian.info.

Reply via email to