I want to add a path "localhost:8080/metrics" to my app to see Counter on my variables by using Prometheus. I read that for a spring boot application I need the only annotation over the main class.
package hello;
import io.prometheus.client.spring.boot.EnablePrometheusEndpoint;
import io.prometheus.client.spring.boot.EnableSpringBootMetricsCollector;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnablePrometheusEndpoint
@EnableSpringBootMetricsCollector
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
How can I obtain the same result in a non-Spring Boot application where I don't have a @SpringBootApplication.
Can it be achieved by registering multiple servlets?