简体   繁体   English

Akka Stream 和 Kamon-Prometheus 不返回任何指标但加载一个空页面

[英]Akka Stream & Kamon-Prometheus not returning any metrics but loads an empty page

I tried to integrate kamon-prometheus with akka stream project but at http://localhost:9095/ it loads an empty page.In the console I could see the message that metrics information is available at http://localhost:9095/ .我尝试将 kamon-prometheus 与 akka 流项目集成,但在http://localhost:9095/它加载了一个空页面。在控制台中,我可以看到度量信息在http://localhost:9095/可用的消息。 When I tried with akka quickstart project, it worked fine.当我尝试使用 akka quickstart 项目时,它运行良好。

Is kamon supported for akka streams? akka 流是否支持 kamon?

Kamon uses aspecj heavily to gather some of the metrics. Kamon 大量使用 aspecj 来收集一些指标。 Please make sure that java agent aspectj-weaver is added to the boot of you JVM.请确保将 java 代理 aspectj-weaver 添加到您的 JVM 启动中。 See different options in this documentation .请参阅本文档中的不同选项。

You also need to add dependencies to build.sbt您还需要向build.sbt添加依赖build.sbt

libraryDependencies += "io.kamon" %% "kamon-core" % "1.1.0"
libraryDependencies += "io.kamon" %% "kamon-prometheus" % "1.0.0"

Disable built-in server in kamon-prometheus by changing this setting key in application.conf file.通过更改application.conf文件中的此设置键,禁用kamon-prometheus的内置服务器。

kamon.prometheus.start-embedded-http-server = no

Add PrometheusReporter to KamonPrometheusReporter添加到Kamon

    import kamon.Kamon
    import kamon.prometheus.PrometheusReporter
    
    private val reporter = new PrometheusReporter()
    private val registry = Kamon.addReporter(reporter)

And serve results of metrics with akka-http by defining a route and getting data from reporter.scrapeData() .并通过定义路由并从akka-http reporter.scrapeData()获取数据来使用akka-http提供度量结果。

     val metrics = path("metrics") {
      encodeResponse {
        val prometheusContentType: ContentType.NonBinary = {
          ContentType.parse("text/plain; version=0.0.4; charset=utf-8").right.get.asInstanceOf[ContentType.NonBinary]
        }
        Kamon.gauge("metrics_called").increment()
        complete(
          HttpResponse(
            status = StatusCodes.OK,
            entity = HttpEntity(prometheusContentType, reporter.scrapeData())
          )
        )
      }
    }

Or serve metrics to any incoming http request with code或使用代码为任何传入的 http 请求提供指标

    akka.http.scaladsl
      .Http(actorSystem)
      .bindAndHandleSync(
        _ => {
          Kamon.gauge("metrics_called").increment()
          HttpResponse(
            status = StatusCodes.OK,
            entity = HttpEntity(prometheusContentType, reporter.scrapeData())
          )
        },
        "0.0.0.0",
        9015
      )

In case if you receive blank page, make sure that Kamon gathers some metrics in the system.如果您收到空白页,请确保Kamon在系统中收集一些指标。 You could test this by adding Kamon.gauge("metrics_called").increment() into a http route for example.例如,您可以通过将Kamon.gauge("metrics_called").increment()到 http 路由来测试这一点。

我试图从 Intellij 运行 Main,这就是我没有得到指标的原因。根据@Ivan Stanislavciuc 的建议,我尝试了sbt run并且它起作用了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有与scala 2.12.1兼容的kamon-prometheus依赖版本吗? - Is there any compatible version of kamon-prometheus dependency with scala 2.12.1? 如何配置 Akka 以使用 Kamon 向 Prometheus 公开指标? - How to configure Akka to expose metrics to Prometheus using Kamon? 是否可以更改Kamon Prometheus报告程序公开指标的终结点? - Is it possible to change the endpoint at which Kamon Prometheus reporter exposes the metrics? Kamon没有将数据报告给普罗米修斯 - Kamon is not reporting the data to prometheus Prometheus 端点是一个空白页 - 在 Spring Boot 应用程序中使用带有 Prometheus 报告器的 kamon - Prometheus endpoint is a blank page - using kamon with Prometheus reporter in a Spring Boot app Prometheus 添加指标时查询结果为空 - Prometheus empty query result when adding metrics 卡蒙普罗米修斯需要很长时间才能刷新 - Kamon Prometheus takes long to refresh Prometheus 节点导出器未返回 Centos 6 上的指标 - Prometheus node-exporter not returning metrics on Centos 6 Traefik 指标适用于 Prometheus,但 Grafana 仪表板为空 - Traefik metrics working for Prometheus but Grafana dashboards are empty Prometheus 适配器返回空的自定义指标 - Prometheus adapter return empty custom metrics
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM