0
votes

I have been trying to collect micrometer metrics in a non springboot application and expose them to prometheus.I have added the following dependency and the test method for the same.I would like to know how to proceed and expose the collected metrics to prometheus from my non spring boot application(traditional spring application).

<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-registry-prometheus</artifactId>
    <version>1.2.0</version>
</dependency>
public string testmetrics(){
    private PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
    registry.counter("ws metric collection","tktdoc metrics");
    String metricsInfo = registry.scrape();
    return metricsInfo;
} 
1

1 Answers

0
votes

You practically have to expose an HTTP endpoint and configure Prometheus with it; the HTTP endpoint will supply the data for the scrapes.

An example showing how to add the HTTP endpoint by starting up an HTTP Server (your application may already be using one) is here.