<p>I have the following file:</p>
<pre><code># HELP container_cpu_usage_seconds_total [ALPHA] Cumulative cpu time consumed by the container in core-seconds
# TYPE container_cpu_usage_seconds_total counter
container_cpu_usage_seconds_total{container=&quot;coredns&quot;,namespace=&quot;kube-system&quot;,pod=&quot;coredns-64897985d-qzvj8&quot;} 1075.30302335 1641411355244
container_cpu_usage_seconds_total{container=&quot;etcd&quot;,namespace=&quot;kube-system&quot;,pod=&quot;etcd-minikube&quot;} 7948.244422673 1641411341787
container_cpu_usage_seconds_total{container=&quot;kindnet-cni&quot;,namespace=&quot;kube-system&quot;,pod=&quot;kindnet-v9rn4&quot;} 253.401092815 1641411342227
container_cpu_usage_seconds_total{container=&quot;kube-apiserver&quot;,namespace=&quot;kube-system&quot;,pod=&quot;kube-apiserver-minikube&quot;} 21314.526032702 1641411341706
container_cpu_usage_seconds_total{container=&quot;kube-controller-manager&quot;,namespace=&quot;kube-system&quot;,pod=&quot;kube-controller-manager-minikube&quot;} 9960.616171401 1641411346752
container_cpu_usage_seconds_total{container=&quot;kube-proxy&quot;,namespace=&quot;kube-system&quot;,pod=&quot;kube-proxy-ktclh&quot;} 220.17024815 1641411352327
container_cpu_usage_seconds_total{container=&quot;kube-scheduler&quot;,namespace=&quot;kube-system&quot;,pod=&quot;kube-scheduler-minikube&quot;} 1216.162832124 1641411355059
container_cpu_usage_seconds_total{container=&quot;metrics-server&quot;,namespace=&quot;kube-system&quot;,pod=&quot;metrics-server-6b76bd68b6-lpx4q&quot;} 715.97119974 1641411344274
container_cpu_usage_seconds_total{container=&quot;storage-provisioner&quot;,namespace=&quot;kube-system&quot;,pod=&quot;storage-provisioner&quot;} 47.685435216 1641411354429
# HELP container_memory_working_set_bytes [ALPHA] Current working set of the container in bytes
# TYPE container_memory_working_set_bytes gauge
container_memory_working_set_bytes{container=&quot;coredns&quot;,namespace=&quot;kube-system&quot;,pod=&quot;coredns-64897985d-qzvj8&quot;} 1.5364096e+07 1641411355244
container_memory_working_set_bytes{container=&quot;etcd&quot;,namespace=&quot;kube-system&quot;,pod=&quot;etcd-minikube&quot;} 5.9752448e+07 1641411341787
container_memory_working_set_bytes{container=&quot;kindnet-cni&quot;,namespace=&quot;kube-system&quot;,pod=&quot;kindnet-v9rn4&quot;} 1.0326016e+07 1641411342227
container_memory_working_set_bytes{container=&quot;kube-apiserver&quot;,namespace=&quot;kube-system&quot;,pod=&quot;kube-apiserver-minikube&quot;} 2.66002432e+08 1641411341706
container_memory_working_set_bytes{container=&quot;kube-controller-manager&quot;,namespace=&quot;kube-system&quot;,pod=&quot;kube-controller-manager-minikube&quot;} 5.9129856e+07 1641411346752
container_memory_working_set_bytes{container=&quot;kube-proxy&quot;,namespace=&quot;kube-system&quot;,pod=&quot;kube-proxy-ktclh&quot;} 2.00704e+07 1641411352327
container_memory_working_set_bytes{container=&quot;kube-scheduler&quot;,namespace=&quot;kube-system&quot;,pod=&quot;kube-scheduler-minikube&quot;} 2.3130112e+07 1641411355059
container_memory_working_set_bytes{container=&quot;metrics-server&quot;,namespace=&quot;kube-system&quot;,pod=&quot;metrics-server-6b76bd68b6-lpx4q&quot;} 2.6923008e+07 1641411344274
container_memory_working_set_bytes{container=&quot;storage-provisioner&quot;,namespace=&quot;kube-system&quot;,pod=&quot;storage-provisioner&quot;} 1.4209024e+07 1641411354429
</code></pre>
<p>A few questions:</p>
<ul>
<li>What format is this? I know it isn't JSON.</li>
<li>Can I use jq to parse/filter this data? I would like to get all metrics on the <code>coredns</code> container:</li>
</ul>
<pre><code>container_cpu_usage_seconds_total{container=&quot;coredns&quot;,namespace=&quot;kube-system&quot;,pod=&quot;coredns-64897985d-qzvj8&quot;} 1075.30302335 1641411355244
container_memory_working_set_bytes{container=&quot;coredns&quot;,namespace=&quot;kube-system&quot;,pod=&quot;coredns-64897985d-qzvj8&quot;} 1.5364096e+07 1641411355244
</code></pre>

Johnny Metz
<p>You could convert your file to JSON using <a href="https://github.com/prometheus/prom2json" rel="nofollow noreferrer">https://github.com/prometheus/prom2json</a></p>
<p>Then it's jq all the way down, if you wish.  E.g. with your input:</p>
<pre><code>prom2json sample.prom | jq '
  .[] | .metrics |= map(select(.labels.container==&quot;coredns&quot;) )'
</code></pre>
<p>yields</p>
<pre><code>{
  &quot;name&quot;: &quot;container_memory_working_set_bytes&quot;,
  &quot;help&quot;: &quot;[ALPHA] Current working set of the container in bytes&quot;,
  &quot;type&quot;: &quot;GAUGE&quot;,
  &quot;metrics&quot;: [
    {
      &quot;labels&quot;: {
        &quot;container&quot;: &quot;coredns&quot;,
        &quot;namespace&quot;: &quot;kube-system&quot;,
        &quot;pod&quot;: &quot;coredns-64897985d-qzvj8&quot;
      },
      &quot;timestamp_ms&quot;: &quot;1641411355244&quot;,
      &quot;value&quot;: &quot;1.5364096e+07&quot;
    }
  ]
}
{
  &quot;name&quot;: &quot;container_cpu_usage_seconds_total&quot;,
  &quot;help&quot;: &quot;[ALPHA] Cumulative cpu time consumed by the container in core-seconds&quot;,
  &quot;type&quot;: &quot;COUNTER&quot;,
  &quot;metrics&quot;: [
    {
      &quot;labels&quot;: {
        &quot;container&quot;: &quot;coredns&quot;,
        &quot;namespace&quot;: &quot;kube-system&quot;,
        &quot;pod&quot;: &quot;coredns-64897985d-qzvj8&quot;
      },
      &quot;timestamp_ms&quot;: &quot;1641411355244&quot;,
      &quot;value&quot;: &quot;1075.30302335&quot;
    }
  ]
}
</code></pre>
