<p>Trying to filter out some services with a <code>relabel_config</code>. On the target I have a label <code>app.kubernetes.io/name</code> with a value of <code>kube-state-metrics</code>.</p>
<p>When I set up my <code>relabel-configs</code> I realized the <code>.</code> and the <code>/</code> are not valid according to the <a href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/#labelname" rel="nofollow noreferrer">Prometheus documentation</a>. I get an error complaining of these invalid characters. Outside of adding a new label on to this service, is this achievable the way it sets? Most Helm charts use this label convention so it would be a lot of work to add additional labels for everything, hoping to avoid it.</p>
<pre><code>relabel_configs:
   - source_labels: [app.kubernetes.io/name]
     action: keep
     regex: kube-state-metrics 
</code></pre>

<p>Prometheus changes dots <code>.</code> and slashes <code>/</code> to underscores <code>_</code> during service discovery, so you need to replace them as well: <code>app_kubernetes_io_name</code>. But this isn't the end, you may also need to add <code>__meta_kubernetes_pod_label_</code> prefix to it:</p>
<pre class="lang-yaml prettyprint-override"><code>- job_name: 'pods'
 kubernetes_sd_configs:
 - role: pod
 relabel_configs:
 - source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_name]
   action: keep
   regex: kube-state-metrics
</code></pre>
