0
votes

I have two counters like below . Both counter have common label interface_name.

Counter A= {app_kubernetes_io_component="xyz-rest-ep",interface_name="N7",command="create","job="kubernetes-pods",monitor="prometheus",namespace="xyz-foo",pod="xyz-rest-ep-9f5686bc-dvtjr",pod_template_hash="9f5686bc",}

Counter B= {app_kubernetes_io_component="xyz-rest-ep",interface_name="N7",command="delete",job="kubernetes-pods",monitor="prometheus",namespace="xyz-foo",pod="xyz-rest-ep-9f5686bc-dvtjr",pod_template_hash="9f5686bc",target_base_url="http://192.168.102.50:7044/"}

I would like to have addition of counter A and counter B by interface_name lable.

Note that Counter B have extra label as target_base_url which is absent in Counter A

Kindly let us know how to achieve this in Prometheus query.

1

1 Answers

0
votes

You should take a look at the Vector matching section, especially at the on/ignoring keywords. If you just want to do an operation like counterA + counterB a query similar to:

counterA + ignoring(target_base_url) counters

should work. This will sum both counters matching on all labels except the target_base_url. If you want to match only on a subset of the labels you could use the on keyword.