【问题标题】:Expose metrics from spring application to prometheus without using spring-boot actuator在不使用 spring-boot 执行器的情况下将来自 spring 应用程序的指标公开给 prometheus
【发布时间】:2020-05-22 08:02:52
【问题描述】:

我一直在尝试在非 springboot 应用程序中收集千分尺指标并将它们公开给 prometheus。我添加了以下依赖项和相同的测试方法。我想知道如何继续并将收集的指标公开给prometheus 来自我的非 Spring Boot 应用程序(传统的 Spring 应用程序)。

<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-registry-prometheus</artifactId>
    <version>1.2.0</version>
</dependency>
public string testmetrics(){
    private PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
    registry.counter("ws metric collection","tktdoc metrics");
    String metricsInfo = registry.scrape();
    return metricsInfo;
} 

【问题讨论】:

    标签: spring prometheus code-metrics spring-micrometer


    【解决方案1】:

    您实际上必须公开一个 HTTP 端点并使用它配置 Prometheus; HTTP 端点将为抓取提供数据。

    here 是一个展示如何通过启动 HTTP 服务器(您的应用程序可能已经在使用)添加 HTTP 端点的示例。

    【讨论】:

      猜你喜欢
      • 2020-10-06
      • 1970-01-01
      • 2020-08-18
      • 2021-11-12
      • 2018-07-12
      • 2022-08-17
      • 2021-07-22
      • 1970-01-01
      • 2018-05-15
      相关资源
      最近更新 更多