prometheus - 将指标从 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
文件
解决方案
在开始之前,有几个要点需要了解:
- 使用 Artemis Prometheus Metrics Plugin 时,代理和应用程序都不会将指标“发送”到 Prometheus。Prometheus 本身必须从代理中检索或“抓取”指标。这就是为什么该插件带有一个 servlet。servlet 公开了一个 HTTP 端点,Prometheus 可以使用它来抓取指标。
- Artemis Prometheus 指标插件是代理基础设施的一部分。它不能作为应用程序的一部分进行部署。插件的jar和war文件部署在broker上,分别配置在
broker.xml
和bootstrap.xml
。
Artemis Prometheus Metrics Plugin 使用两个模块提供与 Prometheus 的集成:
artemis-prometheus-metrics-plugin
org.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 组来管理和配置您的代理,那么他们将遵循这些步骤。
复制
artemis-prometheus-metrics-plugin/target/artemis-prometheus-metrics-plugin-<VERSION>.jar
到<ARTEMIS_INSTANCE>/lib
.将此添加到您的
<ARTEMIS_INSTANCE>/etc/broker.xml
:<metrics-plugin class-name="org.apache.activemq.artemis.core.server.metrics.plugins.ArtemisPrometheusMetricsPlugin"/>
创建目录
<ARTEMIS_INSTANCE>/web
。复制
artemis-prometheus-metrics-plugin-servlet/target/metrics.war
到<ARTEMIS_INSTANCE>/web
.将此添加到中的
web
元素<ARTEMIS_INSTANCE>/etc/bootstrap.xml
:<app url="metrics" war="metrics.war"/>
推荐阅读
- .net - 如何在消息框中显示数据库值
- oracle - V$CONTAINERS 仅显示 CDB 根目录
- javascript - 声明具有相同值的对象属性
- python - Pandas 多索引聚合
- c++ - 数组值输出不正确
- python - Django Exception KeyError 'data' - 只运行一次
- graph - 如何使用图形资源管理器将文件上传到共享驱动器
- node.js - Node JS REST API图像上传,我如何只上传jpg文件而不上传png?
- vue.js - 在 Mocha 和 Playwright 的所有测试之前运行的 Root Hook 插件
- ios - SwiftUI:TabView 和 NavigationView 在 iPhone 上玩得很好,但在 iPad 上不行?