弹性4j和Prometheus的集成

时间:2019-07-08 11:48:00

标签: microservices grafana prometheus resilience4j prometheus-java

如何将Resilience-4J和Prometheus与微服务集成。

我已经集成了具有4j弹性和Prometheus的微服务。     我的问题是,在Prometheus中,我没有任何弹性查询,只有HTTP和其他默认值正在填充。

Kindly help
Steps that i have implemented so far are listed below...
1>created micro-services
2>Integrate micro-services with Resilience 4j by following steps
    i>dependency in pom.xml file
    ii>created separate class of Circuit-breaker and retry module.
    iii>After that i have added Prometheus by adding its jar 
  which is...

 <dependency>
        <groupId>io.micrometer</groupId>
        <artifactId>micrometer-registry-prometheus</artifactId>
    </dependency>

3>在Prometheus Dashboard中,弹性/查询未填充。

i.e # HELP resilience4j_circuit-breaker_calls Circuit Breaker Call Stats
      # TYPE resilience4j_circuit-breaker_calls gauge
       resilience4j_circuit-breaker_calls{name="backendB",call_result="successful",} 0.0
       resilience4j_circuit-breaker_calls{name="backendB",call_result="failed",} 0.0

请帮助。 在此先感谢

我还为弹性4j和Prometheus集成添加了以下依赖项...

 <dependency>
             <groupId>io.github.resilience4j</groupId>
             <artifactId>resilience4j-metrics</artifactId>
             <version>0.16.0</version>
 </dependency>

   <dependency>
            <groupId>io.github.resilience4j</groupId>
            <artifactId>resilience4j-prometheus</artifactId>
            <version>0.16.0</version>
   </dependency>

要在Prometheus仪表板上使用弹性矩阵。

1 个答案:

答案 0 :(得分:0)

您是否使用Spring Boot 1或Spring Boot 2之类的框架? 如果是这种情况,您可以看一下我们的演示,其中还包括Prometheus的Grafana仪表板。

https://github.com/resilience4j/resilience4j-spring-boot2-demo

如果要使用千分尺,则不应添加resilience4j-prometheusresilience4j-metricsresilience4j-prometheus使用Prometheus Java库,resilience4j-metrics使用Dropwizard指标。 您应该改为添加resilience4j-micrometer。但是,如果您使用我们的Spring Boot 2入门程序,则没有必要。