To pick up labels from the other side, you need to list them as part of your group_right. e.g. (untested)
ltmPoolMbrStatusAvailState * on(instance,ltmPoolMbrStatusNodeName,ltmPoolMbrStatusPoolName,ltmPoolMbrStatusPort) group_right(*foo,bar,baz*) ltmPoolMbrStatusEnabledState will pick up labels foo,bar,baz from the left side. See: https://prometheus.io/docs/prometheus/latest/querying/operators/#many-to-one-and-one-to-many-vector-matches Here's a tested example: node_filesystem_avail_bytes * on (instance) group_left(machine,release,version) node_uname_info It's a many-to-one, where the left side is "many" and the right side is "one", and the given labels from node_uname_info are added to the labels from node_filesystem_avail_bytes. On Tuesday, 7 March 2023 at 08:58:21 UTC Nick Carlton wrote: > Thanks for your response. > > If I do `ltmPoolMbrStatusAvailState * > on(instance,ltmPoolMbrStatusNodeName,ltmPoolMbrStatusPoolName,ltmPoolMbrStatusPort) > > group_right ltmPoolMbrStatusEnabledState` I get: > > `{instance="ltm01", job="f5_ltm_test", ltmPoolMbrStatusEnabledState="1", > ltmPoolMbrStatusNodeName="/Common/VPN1", > ltmPoolMbrStatusPoolName="/Common/Pool1", ltmPoolMbrStatusPort="4500", > prometheus="monitoring/k8s", prometheus_replica="prometheus-k8s-0"}` > > So this has `ltmPoolMbrStatusEnabledState` but not > `ltmPoolMbrStatusAvailState`. If I swap the metrics round: > > `ltmPoolMbrStatusEnabledState * > on(instance,ltmPoolMbrStatusNodeName,ltmPoolMbrStatusPoolName,ltmPoolMbrStatusPort) > > group_right ltmPoolMbrStatusAvailState`. I get: > > `{instance="ltm01", job="f5_ltm_test", ltmPoolMbrStatusAvailState="1", > ltmPoolMbrStatusNodeName="/Common/VPN1", > ltmPoolMbrStatusPoolName="/Common/Pool1", ltmPoolMbrStatusPort="4500", > prometheus="monitoring/k8s", prometheus_replica="prometheus-k8s-0"}` > > This has `ltmPoolMbrStatusAvailState` but not > `ltmPoolMbrStatusEnabledState` > > So it seems I can get one or the other, not both. Unless im forming my > PromQL wrong? > > On Tuesday, 7 March 2023 at 08:31:39 UTC Brian Candler wrote: > >> It has to be done in a query - the relabelling phase of a scrape job >> cannot see other metrics. >> >> What you are looking for is one-to-many queries, which can pick up labels >> from the "one" side and apply them to the "many": >> >> https://www.robustperception.io/how-to-have-labels-for-machine-roles >> >> https://www.robustperception.io/exposing-the-software-version-to-prometheus >> >> https://prometheus.io/docs/prometheus/latest/querying/operators/#many-to-one-and-one-to-many-vector-matches >> https://www.robustperception.io/left-joins-in-promql >> >> > I have tried doing a join but it only seems to bring in one of the >> `ltmPoolMbrStatusEnabledState` and `ltmPoolMbrStatusAvailState` metrics >> depending on if its a left or right join, but I would like both to appear. >> >> Can you show what query you did, the raw metrics which it used, what >> result you got, and what you wanted to get instead? >> > -- 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/4c22a279-a51c-47db-993e-9107e54e883en%40googlegroups.com.

