title: How to execute a query with two metrics in Prometheus?
body: <p>I am using Prometheus to query metrics from Apache Flink. I want to measure the number of records In and Out per second of a Map function. When I query two different metrics in Prometheus, the chart only shows one of them.</p>
  
  <pre><code>flink_taskmanager_job_task_operator_numRecordsInPerSecond{operator_name="Map"} 
  or flink_taskmanager_job_task_operator_numRecordsOutPerSecond{operator_name="Map"}
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/JfmVC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JfmVC.png" alt="enter image description here"></a>
  Does not matter if I change the operator <code>or</code> to <code>and</code>. The chart shows only the first (<code>flink_taskmanager_job_task_operator_numRecordsInPerSecond</code>). I also have tried to edit the Prometheus config file <code>/etc/prometheus/prometheus.yml</code> but I don't have too much experience on Prometheus and there is something wrong in my configuration. I was basing my solution on <a href="https://www.robustperception.io/extracting-labels-from-legacy-metric-names" rel="noreferrer">this post</a>.</p>
  
  <pre><code>global:
    scrape_interval: 15s
  
  scrape_configs:
    - job_name: 'prometheus'
      scrape_interval: 5s
      static_configs:
        - targets: ['localhost:9090']
    - job_name: 'node_exporter'
      scrape_interval: 5s
      static_configs:
        - targets: ['localhost:9100']   
    - job_name: 'flink'
      scrape_interval: 5s
      static_configs:
        - targets: ['localhost:9250', 'localhost:9251', '192.168.56.20:9250']
      metrics_path: /
  # HOW TO ADD THE OPERATOR NAME ON THE METRIC NAME?
      metric_relabel_configs:
        - source_labels: [__name__]
        regex: '(flink_taskmanager_job_task_operator)_(\w+)'
        replacement: '${2}'
        target_label: pool
        - source_labels: [__name__]
        regex: '(flink_taskmanager_job_task_operator)_(\w+)'
        replacement: '${1}_bytes'
        target_label: __name__
  </code></pre>