Skip to content

一.上传 jar 包和 war 包

shell
# 将 jar 包复制到 /var/lib/artemis-instance/lib/ 目录下(docker 挂载目录的需要放到对应的位置)
# 将 war 包复制到 /var/lib/artemis-instance/web/ 目录下(web/ 目录需要自己创建, docker 挂载目录的需要放到对应的位置)

二.配置 broker.xml

shell
# 修改 broker.xml 文件, 该文件在 /var/lib/artemis-instance/etc/ 下, docker 挂在目录需要找到对应的位置
vi broker.xml
# 填充以下内容
<metrics>
   <jvm-memory>true</jvm-memory>
   <jvm-gc>true</jvm-gc>
   <jvm-threads>true</jvm-threads>
   <processor>true</processor>
   <uptime>true</uptime>
   <plugin class-name="com.redhat.amq.broker.core.server.metrics.plugins.ArtemisPrometheusMetricsPlugin"/>
</metrics>
# 填充好是这个样子的
<name>0.0.0.0</name><!-- 以这里为定位点, 配置文件即可 -->

<metrics>
   <jvm-memory>true</jvm-memory>
   <jvm-gc>true</jvm-gc>
   <jvm-threads>true</jvm-threads>
   <processor>true</processor>
   <uptime>true</uptime>
   <plugin class-name="com.redhat.amq.broker.core.server.metrics.plugins.ArtemisPrometheusMetricsPlugin"/>
</metrics>

三.配置 bootstrap.xml

shell
# 修改 broker.xml 文件, 该文件在 /var/lib/artemis-instance/etc/ 下, docker 挂在目录需要找到对应的位置
vi bootstrap.xml
# 在 <web><binding></binding></web> 内添加一个 <app> 标签, 添加完是这个样子的
<!-- The web server is only bound to localhost by default -->
<web path="web" rootRedirectLocation="console">
   <binding name="artemis" uri="http://0.0.0.0:8161">
       <app name="console" url="console" war="console.war"/>
       <app url="metrics" war="metrics.war"/>
   </binding>
</web>

四.重启测试

shell
# 先重启 Artemis
# 访问一下url(这里的 8161 实际上就是 console 的端口, 如果是 docker 安装的, 就需要改成映射端口)
curl 127.0.0.1:8161/metrics/

五,配置 Prometheus 采集

shell
global:
  scrape_interval:     15s
  evaluation_interval: 15s

scrape_configs:
  - job_name: artemis
    static_configs:
      - targets: ['127.0.0.1:8161']