【发布时间】:2018-09-10 10:54:10
【问题描述】:
我想在我的应用程序中添加一个路径“localhost:8080/metrics”,以便使用 Prometheus 在我的变量上查看 Counter。我读到,对于 Spring Boot 应用程序,我需要主类上的唯一注释。
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);
}
}
如何在没有@SpringBootApplication 的非 Spring Boot 应用程序中获得相同的结果。
可以通过注册多个servlet来实现吗?
【问题讨论】:
标签: java spring spring-boot prometheus