title: Pretty print JSON output of Spring Boot Actuator endpoints
body: <p><strong>Spring Boot Actuator</strong> provides several <strong>endpoints</strong> to <strong>monitor</strong> an <strong>application</strong> as:</p>
  
  <pre><code>/metrics
  /beans
  /health
  ...
  </code></pre>
  
  <p>Checking the endpoints with:</p>
  
  <pre><code>curl http://localhost:8080/metrics
  </code></pre>
  
  <p>results in:</p>
  
  <pre><code>{"counter.status.200.env":1,"counter.status.200.health":1,"counter.status.200.info":2,"counter.status.200.metrics":2,"gauge.response.env":5.0,"gauge.response.health":22.0,"gauge.response.info":1.0,"gauge.response.metrics":1.0,"mem":1030144,"mem.free":56118,"processors":8,"uptime":5108095,"instance.uptime":5102906,"heap.committed":1030144,"heap.init":262144,"heap.used":974031,"heap":3728384,"threads.peak":81,"threads.daemon":21,"threads":77,"classes":8854,"classes.loaded":8860,"classes.unloaded":6,"gc.ps_scavenge.count":119,"gc.ps_scavenge.time":7223,"gc.ps_marksweep.count":12,"gc.ps_marksweep.time":17573}
  </code></pre>
  
  <p>This is <strong>fine for machine consumption</strong> but <strong>hard to read</strong> by <strong>humans</strong>.</p>
  
  <p>I'd like to <strong>format</strong> (i.e. pretty print) the <strong>JSON</strong> output of the <strong>Spring Boot Actuator</strong> endpoints to make them easier to read by operations personel.</p>
  
  <p>Something like:</p>
  
  <pre><code>{
    "counter.status.200.env":1,
    "counter.status.200.health":1,
    "counter.status.200.info":2,
    "counter.status.200.metrics":2,
    "gauge.response.env":5.0,
    "gauge.response.health":22.0,
    "gauge.response.info":1.0,
    ...
  }
  </code></pre>
  
  <p>I tried setting </p>
  
  <pre><code>http.mappers.json-pretty-print=true 
  </code></pre>
  
  <p>but this setting didn't affect the Actuator output.</p>
  
  <p>Is there a <strong>configuration</strong> to <strong>enable pretty print</strong> of the <strong>Spring Boot Actuator JSON</strong> output?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>The <a href="https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-actuator">official sample</a> works for me. </p>
  
  <p>It's important to follow the comments from @DaveSyer: the property to set is </p>
  
  <pre><code>http.mappers.jsonPrettyPrint=true
  </code></pre>
  
  <p>Investigation is still under way.</p>
  
  <p>In the meantime I use the the json pretty print <strong>command line</strong> as <strong>workaround</strong>:</p>
  
  <p>Install jsonpp (e.g. for OS X):</p>
  
  <pre><code>brew install jsonpp
  </code></pre>
  
  <p>Then pipe the curl output trough jsonpp which formats the json file on the fly:</p>
  
  <pre><code>curl http://localhost:8080/metrics | jsonpp
  </code></pre>
  
  <p>Results in:</p>
  
  <pre><code>{
    "counter.status.200.env": 1,
    "counter.status.200.health": 1,
    "counter.status.200.info": 2,
    "counter.status.200.metrics": 2,
    ...
  }
  </code></pre>