Add metric dimension based on service/pod label

Howdy, y’all

I would like to add a dimensions to the istio_requests_total metric, which would be pulled froma label.

E.g. If I have a service my-service (or a pod my-pod), with a label.branch = master, I’d like to be able to add a

istio_requests_total{branch=master}

dimension.

I’ve looked up on this piece of doc : https://istio.io/latest/docs/tasks/observability/metrics/customize-metrics/ , but I can’t find any way to do this.

I see that destination_app and destination_version are available. Is there any way to pull from “custom” labels, like branch, revision, deployment, etc. ?

Could somebody help me out?

This should be doable, using CEL and the extraStatsTags. I believe you’ll need to start with something like node.metadata.labels[branch], but I have not personally tried.

@kuat can you provide any extra guidance here?

1 Like

Yeah, you can customize destination_version as follows:
listener_direction == 1 ? node.metadata['LABELS']['branch'] : upstream_peer.labels['branch'].

1 stands for INBOUND listener direction (incoming requests should get node label, outgoing should get upstream_peer label).

1 Like

Cool, I’ll give it a shot. Thanks @douglas-reid and @kuat.