title: how to label Prometheus blackbox_exporter endpoints
body: <p>I have a k8s cluster with Prometheus and a few pods with a web application. I want to collect the metrics from these web apps. I use the <a href="https://github.com/prometheus/blackbox_exporter" rel="nofollow noreferrer">Prometheus blackbox_exporter</a> for that.</p>
  <p>I configured the Service Monitor, deployment, working by prometheus operator. The Prometheus collect the metrics but I cannot tell them apart. For example,<br />
  <code>probe_success{endpoint=&quot;http-metrics&quot;,instance=&quot;10.20.0.105:9115&quot;,job=&quot;prometheus-blackbox-exporter&quot;,namespace=&quot;staging&quot;,pod=&quot;prometheus-blackbox-exporter-66fb58ff97-pd6lk&quot;,service=&quot;prometheus-blackbox-exporter&quot;}</code></p>
  <p>What I should do to add extra labels for each endpoint?</p>
  <p>how to add labels like <strong>target</strong> to probe_success metric?</p>
  <p><a href="https://i.stack.imgur.com/afl3t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/afl3t.png" alt="enter image description here" /></a></p>
  <pre><code>  blackbox.yaml: |
      modules:
        http_2xx:
          prober: http
          http:
            preferred_ip_protocol: &quot;ipv4&quot;
            tls_config:
              ca_file: &quot;/config/my.pem&quot;
        http_post_4xx:
          prober: http
          http:
            method: POST
            valid_status_codes: [400,404,401,403]
            headers:
              Content-Type: application/json
            body: '{&quot;nonsense&quot;}'
            preferred_ip_protocol: &quot;ipv4&quot;
            tls_config:
              ca_file: &quot;/config/my.pem&quot;
  </code></pre>
  <p>the service is</p>
  <pre><code>---
  kind: Service
  apiVersion: v1
  metadata:
    name: prometheus-blackbox-exporter
    labels:
      app.kubernetes.io/name: prometheus-blackbox-exporter
      name: prometheus-blackbox-exporter
      monitoring: &quot;true&quot;
  spec:
    type: ClusterIP
    ports:
      - name: http-metrics
        port: 9115
        protocol: TCP
    selector:
      app.kubernetes.io/name: prometheus-blackbox-exporter
  
  ---
  apiVersion: monitoring.coreos.com/v1
  kind: ServiceMonitor
  metadata:
    name: prometheus-blackbox-exporter
    labels: {}
  spec:
    selector:
      matchLabels:
        name: prometheus-blackbox-exporter
    endpoints:
      - port: http-metrics
        metricRelabelings:
          - sourceLabels: [__address__]
            targetLabel: __param_target
          - sourceLabels: [__param_target]
            targetLabel: instance
          - sourceLabels: [__address__]
            replacement: prometheus-blackbox-exporter:9115
        path: /probe
        params:
          target:
            - &quot;web:3000&quot;
          module:
            - &quot;http_2xx&quot;
  
      - port: http-metrics
        metricRelabelings:
          - sourceLabels: [__address__]
            targetLabel: __param_target
          - sourceLabels: [__param_target]
            targetLabel: instance
          - sourceLabels: [__address__]
            replacement: prometheus-blackbox-exporter:9115
        path: /probe
        params:
          target:
            - &quot;api:8080/api/v1/login&quot;
          module:
            - &quot;http_post_4xx&quot;
  </code></pre>