title: how to get metrics from spring-boot-actuator programmatically?
body: <p>we have a spring application in production. It is NOT Spring-boot. I found <a href="https://stackoverflow.com/questions/26913087/use-spring-boot-actuator-without-a-spring-boot-application">this post</a> on how to use spring-boot-actuator in a non-spring-boot application.</p>
  
  <p>However, the requirement for us is to aggregate the data from /metrics endpoint and do some analytics on it and report a status indicator.</p>
  
  <p>For eg, we might use heap parameter such as
  <code>{"heap.committed":480768,"heap.init":262144,"heap.used":294461,"heap":3728384,"threads.peak":37}</code> to indicate the status of the application - FATAL, WARN or HEALTHY. </p>
  
  <p>This is just an example. our requirement is more complex. In-fact, we already have a <code>status endpoint</code> where we want to add more info (based on data from <code>/metrics</code> and <code>/health</code> endpoints of <code>spring-boot-actuator</code>).</p>
  
  <p>One way I am thinking of acheiving this is 
  making REST call to <code>/metrics</code> and <code>/health</code> with-in the application, collect the data, aggregate them and return the response. I don't think it is a recommended way.</p>
  
  <p>If there is a bean where I could extract these parameters directly, I would autowire it and calculate them on the fly as and when needed. (In fact, I will schedule to calculate periodically).</p>
  
  <p>I am interested in all the attributes returned from <code>/metrics</code>.
  while I am also interested in the following from <code>/health</code>.</p>
  
  <pre><code>{"diskSpace":{"status":"UP","free":386186194944,"threshold":10485760}}
  </code></pre>
  
  <p>what beans should I autowire and get these attributes for free!</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This <a href="http://kielczewski.eu/2015/01/application-metrics-with-spring-boot-actuator/" rel="noreferrer">post</a> has <code>@Autowired MetricRepository</code>. But for some reason, it returning only the custom counter properties. It is NOT returning heap, memory info etc
  Eg:
  <code>
  Reporting metric counter.calls.get_greeting=4
  Reporting metric counter.calls.get_greeting.1=1
  Reporting metric counter.calls.get_greeting.2=1
  Reporting metric counter.calls.get_greeting.3=1
  Reporting metric counter.calls.get_greeting.4=1
  Reporting metric counter.status.200.greeting.number=4
  Reporting metric counter.status.404.star-star=1
  </code></p>