实现Prometheus计数器时出现NoClassDefFoundError

时间:2020-03-22 13:56:28

标签: java prometheus

我实现了Prometheus计数器以获得编号。对服务的请求。致电服务时,出现以下错误。

row_number()

我在pom.xml文件中添加了以下依赖项。

Exception in thread "HTTP-Listener I/O dispatcher-1" java.lang.NoClassDefFoundError: io/prometheus/client/Counter

这是我的Java工具

      <dependency>
         <groupId>io.prometheus</groupId>
         <artifactId>simpleclient</artifactId>
         <version>0.8.1</version>
     </dependency>
     <!-- Hotspot JVM metrics-->
     <dependency>
         <groupId>io.prometheus</groupId>
         <artifactId>simpleclient_hotspot</artifactId>
         <version>0.8.1</version>
     </dependency>
     <!-- Exposition HTTPServer-->
     <dependency>
         <groupId>io.prometheus</groupId>
         <artifactId>simpleclient_httpserver</artifactId>
         <version>0.8.1</version>
     </dependency>

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

您应该始终使用 simpleclient 各个部分的一致版本。

<!-- prometheus - core -->
<dependency>
    <groupId>io.prometheus</groupId>
    <artifactId>simpleclient</artifactId>
    <version>${prometheus.version}</version>
</dependency>

<!-- prometheus - Exposition HTTPServer -->
<dependency>
    <groupId>io.prometheus</groupId>
    <artifactId>simpleclient_httpserver</artifactId>
    <version>${prometheus.version}</version>
</dependency>

<!-- Hotspot JVM metrics -->
<dependency>
    <groupId>io.prometheus</groupId>
    <artifactId>simpleclient_hotspot</artifactId>
    <version>${prometheus.version}</version>
</dependency>

<dependency>
    <groupId>io.prometheus</groupId>
    <artifactId>simpleclient_servlet</artifactId>
    <version>${prometheus.version}</version>
</dependency>

<!-- prometheus - Pushgateway exposition -->
<dependency>
    <groupId>io.prometheus</groupId>
    <artifactId>simpleclient_pushgateway</artifactId>
    <version>${prometheus.version}</version>
</dependency>