Prometheus指标servlet不显示任何指标

时间:2018-09-07 10:53:06

标签: servlets jboss7.x metrics prometheus resilience4j

我正在使用resilience4j断路器,并且无法使用Prometheus Servlet客户端导出度量标准。我正在部署到jbossas7服务器,但是/ metrics端点未显示任何内容。有任何想法吗?我正在将断路器注入一个Bean中,该bean与下面的断路器初始化代码(位于工厂中)一起正常工作。

调试代码时,我看到断路器已制成并已在collectorRegistry中注册。但是,当将其写入simpleclient servlet的servlet中时,不会将任何内容写入输出。它只是跳到客户端库代码中的finally块

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<servlet>
    <servlet-name>metrics</servlet-name>
    <servlet-class>io.prometheus.client.exporter.MetricsServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>metrics</servlet-name>
    <url-pattern>/metrics</url-pattern>
</servlet-mapping>

</web-app>

pom.xml依赖项

<dependency>
        <groupId>io.github.resilience4j</groupId>
        <artifactId>resilience4j-circuitbreaker</artifactId>
        <version>${resilience4j.version}</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>io.github.resilience4j</groupId>
        <artifactId>resilience4j-prometheus</artifactId>
        <version>0.13.1</version>
    </dependency>
    <dependency>
        <groupId>io.prometheus</groupId>
        <artifactId>simpleclient</artifactId>
        <version>0.5.0</version>
    </dependency>
    <dependency>
        <groupId>io.prometheus</groupId>
        <artifactId>simpleclient_servlet</artifactId>
        <version>0.5.0</version>
    </dependency>

断路器启动

public CircuitBreaker getInjectedCircuitbreaker(InjectionPoint injectionPoint) {
    Circuitbreaker breaker = injectionPoint.getAnnotated().getAnnotation(Circuitbreaker.class);
    CircuitBreaker circuitBreaker = circuitBreakerRegistry.circuitBreaker(breaker.breakerName());
    collectorRegistry.register(CircuitBreakerExports.ofCircuitBreakerRegistry(circuitBreakerRegistry));
    return circuitBreaker;
}

0 个答案:

没有答案