title: Configuring Prometheus for Spring Boot health check monitoring
body: <p>We have few Spring Boot applications that have health check implemented. The response for those checks was changed to JSON format based on @Thiru's <a href="https://stackoverflow.com/questions/52806576/configuring-prometheus-for-spring-boot-health-check-monitoring#comment92542176_52806954">suggestion</a>. I now get the following response:</p>
  
  <p><a href="https://i.stack.imgur.com/uJJbq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uJJbq.png" alt="enter image description here"></a></p>
  
  <p>Prometheus server is running on Ubuntu instance. Spring boot services that have to be monitored are running on Windows server 2016. I have installed <em>blackbox-exporter</em> (version <code>0.12.0.windows-amd64</code>) on Windows server after seeing <a href="https://medium.com/the-telegraph-engineering/how-prometheus-and-the-blackbox-exporter-makes-monitoring-microservice-endpoints-easy-and-free-of-a986078912ee" rel="nofollow noreferrer">this</a> post.</p>
  
  <p>Following change was done on client (Windows server with IP: <code>172.16.x.yz</code>) side in <code>blackbox.yml</code>:</p>
  
  <pre><code>modules:
    http_2xx:
      prober: http
      http:
    http_post_2xx:
      prober: http
      timeout: 5s
      http:
        method: POST
        headers:
          Content-Type: application/json
        body: '{"status": "UP"}'
    ...
    ...
  </code></pre>
  
  <p>On Prometheus server, following is the content of <code>prometheus.yml</code>:</p>
  
  <pre><code>...
  ...
  scrape_configs:
    - job_name: 'prometheus'
      static_configs:
      - targets: ['localhost:9090']
  
    - job_name: 'blackbox'
      metrics_path: /probe
      params:
        #module: [http_2xx]  # Look for a HTTP 200 response.
        module: [http_post_2xx]  # Look for a HTTP 200 response.
      static_configs:
        - targets:
          - http://172.16.x.yz:6300/serviceA/actuator/health
          - http://172.16.x.yz:6340/serviceB/actuator/health
      relabel_configs:
        - source_labels: [__address__]
          target_label: __param_target
        - source_labels: [__param_target]
          target_label: instance
        - target_label: __address__
          replacement: 172.16.x.yz:9115  # The blackbox exporter's real hostname:port.
  </code></pre>
  
  <p>After making above changes on client and server, when i restart both the <code>blackbox-exporter</code> and <code>prometheus</code>, i see that Prometheus <em>always</em> shows <code>State</code> as UP even if the two services that the exporter is monitoring go down. Seems Prometheus is displaying the status of the <code>blackbox-exporter</code> and not for the services. Any suggestion how i can fix that?</p>
  
  <p><a href="https://i.stack.imgur.com/Z42fN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z42fN.png" alt="enter image description here"></a></p>