<p>I want to reduce the number of metrics that are scraped under Kube-state-metrics.
When I use the following configuration:</p>
<pre><code>  metric_relabel_configs:
  - source_labels: [__name__]
    separator: ;
    regex: kube_pod_(status_phase|container_resource_requests_memory_bytes|container_resource_requests_cpu_cores|owner|labels|container_resource_limits_memory_bytes|container_resource_limits_cpu_cores)
    replacement: $1
    action: keep
</code></pre>
<p>It is working and I can see only the metrics I selected above.
But when I try to add another rule:</p>
<pre><code>metric_relabel_configs:
  - source_labels: [__name__]
    separator: ;
    regex: kube_pod_(status_phase|container_resource_requests_memory_bytes|container_resource_requests_cpu_cores|owner|labels|container_resource_limits_memory_bytes|container_resource_limits_cpu_cores)
    replacement: $1
    action: keep
  - source_labels: [__name__]
    separator: ;
    regex: kube_replicaset_(owner)
    replacement: $1
    action: keep
</code></pre>
<p>It will remove everything, including the first rule that used to work.
How should it be correctly written so that I can create multiple rules for keeping selective metrics?</p>

Tomer Leibovich
<p>Figured out that both conditions can't be together, only one <code>keep</code> can be.</p>
