<p>I'm trying to add a new label <code>source_ip</code> to the prometheus metric <code>requestcount</code><br>
I've added the attribute to prom handler</p>
<pre><code>params:
    metrics:
    - instance_name: requestcount.instance.istio-system
      kind: COUNTER
      label_names:
      - reporter
      - source_ip
      - source_app
</code></pre>
<p>and added a dimension to <code>requestcount</code> instance</p>
<pre><code>compiledTemplate: metric
  params:
    dimensions:
      reporter: conditional((context.reporter.kind | &quot;inbound&quot;) == &quot;outbound&quot;, &quot;source&quot;, &quot;destination&quot;)
      source_app: source.labels[&quot;app&quot;] | &quot;unknown&quot;
      source_ip: source.ip | &quot;unknown&quot;
</code></pre>
<p>and added an <code>attribute_binding</code> to the <code>attributes</code> instance</p>
<pre><code>spec:
  attributeBindings:
    destination.workload.namespace: $out.destination_workload_namespace | &quot;unknown&quot;
    destination.workload.uid: $out.destination_workload_uid | &quot;unknown&quot;
    source.ip: $out.source_pod_ip | ip(&quot;0.0.0.0&quot;)
</code></pre>
<p>yet, <code>source_ip</code> label is not included in the <code>istio_request_total</code> metric reported by prometheus, am I missing something here?</p>

<h2>About mixer and documentation you use</h2>
<blockquote>
<p>I'm using istio 1.5 and upgrading might take me some considerable time.</p>
</blockquote>
<p>That <a href="https://istio.io/latest/docs/reference/config/policy-and-telemetry/mixer-overview/#handlers" rel="nofollow noreferrer">documentation</a> you mentioned won't work on istio 1.5 as it uses mixer which is deprecated since istio 1.5, as mentioned in below docs you might re-enable it but I couldn't find any documentation about that.</p>
<p>As mentioned <a href="https://istio.io/latest/docs/reference/config/policy-and-telemetry/" rel="nofollow noreferrer">here</a> and <a href="https://istio.io/latest/news/releases/1.5.x/announcing-1.5/upgrade-notes/#mixer-deprecation" rel="nofollow noreferrer">here</a></p>
<blockquote>
<p>Mixer is deprecated. The functionality provided by Mixer is being moved into the Envoy proxies. Use of Mixer with Istio will only be supported through the 1.7 release of Istio.</p>
</blockquote>
<blockquote>
<p>Mixer deprecation</p>
<p>Mixer, the process behind the istio-telemetry and istio-policy deployments, has been deprecated with the 1.5 release. istio-policy was disabled by default since Istio 1.3 and istio-telemetry is disabled by default in Istio 1.5.</p>
<p>Telemetry is collected using an in-proxy extension mechanism (Telemetry V2) that does not require Mixer.</p>
<p>If you depend on specific Mixer features like out of process adapters, you may re-enable Mixer. Mixer will continue receiving bug fixes and security fixes until Istio 1.7. Many features supported by Mixer have alternatives as specified in the Mixer Deprecation document including the in-proxy <a href="https://github.com/istio/proxy/tree/master/extensions" rel="nofollow noreferrer">extensions</a> based on the WebAssembly sandbox API.</p>
<p>If you rely on a Mixer feature that does not have an equivalent, we encourage you to open issues and discuss in the community.</p>
</blockquote>
<hr />
<h2>About upgrade</h2>
<p>About the upgrade, I would say if that was older version of istio then it might be harder to upgrade, but since it's 1.5 I would say it might be easy to upgrade to 1.6 with <a href="https://istio.io/latest/docs/setup/upgrade/" rel="nofollow noreferrer">istioctl upgrade</a>. I would suggest to test it first on some test environment.</p>
<h2>About the main question</h2>
<p>Istio configures prometheus with a 'kubernetes-pods' job. At least while using the 'demo' profile. In this prometheus job config, there is a relabel_configs which gets the pod labels.</p>
<pre><code>relabel_configs: 
...
- action: labelmap
  regex: __meta_kubernetes_pod_label_(.+)
</code></pre>
<p>If you want to use it then use meshConfig.enablePrometheusMerge=true option, it will append the labels to the istio metrics. There is related <a href="https://istio.io/latest/docs/ops/integrations/prometheus/#option-2-metrics-merging" rel="nofollow noreferrer">documentation</a> about that. Just a notice that this option is newly introduced in Istio 1.6 and is considered alpha at this time.</p>
