首页 > 解决方案 > 将指标从 ActiveMQ Artemis 发送到 Prometheus

问题描述

我有一个问题我被卡住了,我不太确定如何解决它。

在我的工作项目中,我有一个 ActiveMQ 队列,我想向 Prometheus 发送一些指标,这将帮助我在 Grafana 中创建一些警报。我知道对于 ActiveMQ Artemis,我可以使用这个插件,但我 100% 不明白如何配置它。

我的应用程序部署在 Kubernetes 集群上,ActiveMQ 代理也在那里。所以我创建了ActiveMQPrometheusMetricsPlugin类,它实现了org.apache.activemq.artemis.core.server.metrics.ActiveMQMetricsPlugin. 现在是我现在感到困惑的地方,我应该部署我的应用程序,Prometheus 会收集这些指标吗?我应该做更多的配置吗?

我们通常不在本地环境上构建应用程序。我们正在使用一个管道,它正在构建应用程序并将其部署到各种环境(开发、测试、产品)。我应该对 GitHub 插件项目进行类似的配置,部署它,然后在 Kubernetes 上找到这些 jar 并将它们移动到正确的位置?dev-ops 还对我说我们正在使用默认配置。不知道有没有broker.xml文件

标签: prometheusactivemq-artemis

解决方案


在开始之前,有几个要点需要了解:

  • 使用 Artemis Prometheus Metrics Plugin 时,代理和应用程序都不会将指标“发送”到 Prometheus。Prometheus 本身必须从代理中检索或“抓取”指标。这就是为什么该插件带有一个 servlet。servlet 公开了一个 HTTP 端点,Prometheus 可以使用它来抓取指标。
  • Artemis Prometheus 指标插件是代理基础设施的一部分。它不能作为应用程序的一部分进行部署。插件的jar和war文件部署在broker上,分别配置在broker.xmlbootstrap.xml

Artemis Prometheus Metrics Plugin 使用两个模块提供与 Prometheus 的集成:

  • artemis-prometheus-metrics-pluginorg.apache.activemq.artemis.core.server.metrics.ActiveMQMetricsPlugin :这提供了 Micrometer 和 Prometheus 依赖项的实际实现并将其打包在“uber”jar 中。

  • artemis-prometheus-metrics-plugin-servlet:这提供了一个包含简单 servlet 的 war 文件,该文件可以部署到代理的嵌入式 Web 服务器,然后 Prometheus 可以使用它来抓取指标。

克隆 Artemis Prometheus Metrics Plugin 存储库后,只需运行mvn install即可构建这两个模块。输出将在各自的target目录中。

构建模块后,请按照以下步骤部署和配置 Artemis Prometheus Metrics 插件。如果您有某种类型的 dev-ops 组来管理和配置您的代理,那么他们将遵循这些步骤。

  1. 复制artemis-prometheus-metrics-plugin/target/artemis-prometheus-metrics-plugin-<VERSION>.jar<ARTEMIS_INSTANCE>/lib.

  2. 将此添加到您的<ARTEMIS_INSTANCE>/etc/broker.xml

    <metrics-plugin class-name="org.apache.activemq.artemis.core.server.metrics.plugins.ArtemisPrometheusMetricsPlugin"/>
    
  3. 创建目录<ARTEMIS_INSTANCE>/web

  4. 复制artemis-prometheus-metrics-plugin-servlet/target/metrics.war<ARTEMIS_INSTANCE>/web.

  5. 将此添加到中的web元素<ARTEMIS_INSTANCE>/etc/bootstrap.xml

    <app url="metrics" war="metrics.war"/>
    

推荐阅读