gpt4 book ai didi

java - 无法通过 jmx-exporter 从 activemq 中抓取指标

转载 作者:行者123 更新时间:2023-12-02 01:15:27 29 4
gpt4 key购买 nike

无法通过 jmx-exporter 从 activemq 中抓取指标

我将 jmx 导出器下载到我的虚拟机,然后按照说明运行如下命令:
java -javaagent:./jmx_prometheus_javaagent-0.12.0.jar=8980:config.yaml -jar/usr/local/tomcat/apache-activemq/apache-activemq-5.8.0_56/bin/activemq.jar

我得到了一些有关 activemq 的输出信息。然后我尝试 curl 它:curl http://localhost:8980/metrics

并收到错误:curl: (7) 无法连接到主机

我查看了流程。发现没有jvm-exporter的java进程。

为什么?我做错了什么吗?

这是我的 config.yaml

[root@sz-7-centos162 test]# cat config.yaml 
{
startDelaySeconds: 0,
username: admin,
password: admin,
jmxUrl: "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi",
ssl: false,
lowercaseOutputName: false,
lowercaseOutputLabelNames: false
}

我希望 curl http://localhost:8980/metrics获取指标,但实际上它只是向我显示一些有关 activemq 的信息,但什么也不做。所有输出信息和我的操作都粘贴在下面:

[root@sz-7-centos162 test]# java -javaagent:./jmx_prometheus_javaagent-0.12.0.jar=8980:config.yaml -jar /usr/local/tomcat/apache-activemq/apache-activemq-5.8.0_56/bin/activemq.jar
Java Runtime: Oracle Corporation 1.8.0_51 /usr/jdk1.8.0_51/jre
Heap sizes: current=243712k free=233469k max=3608576k
JVM args: -javaagent:./jmx_prometheus_javaagent-0.12.0.jar=8980:config.yaml
Extensions classpath:
[/usr/local/tomcat/apache-activemq/apache-activemq-5.8.0_56/lib,/usr/local/tomcat/apache-activemq/apache-activemq-5.8.0_56/lib/camel,/usr/local/tomcat/apache-activemq/apache-activemq-5.8.0_56/lib/optional,/usr/local/tomcat/apache-activemq/apache-activemq-5.8.0_56/lib/web,/usr/local/tomcat/apache-activemq/apache-activemq-5.8.0_56/lib/extra]
ACTIVEMQ_HOME: /usr/local/tomcat/apache-activemq/apache-activemq-5.8.0_56
ACTIVEMQ_BASE: /usr/local/tomcat/apache-activemq/apache-activemq-5.8.0_56
ACTIVEMQ_CONF: /usr/local/tomcat/apache-activemq/apache-activemq-5.8.0_56/conf
ACTIVEMQ_DATA: /usr/local/tomcat/apache-activemq/apache-activemq-5.8.0_56/data
Usage: Main [--extdir <dir>] [task] [task-options] [task data]

Tasks:
browse - Display selected messages in a specified destination.
bstat - Performs a predefined query that displays useful statistics regarding the specified broker
create - Creates a runnable broker instance in the specified path.
decrypt - Decrypts given text
encrypt - Encrypts given text
export - Exports a stopped brokers data files to an archive file
list - Lists all available brokers in the specified JMX context
purge - Delete selected destination's messages that matches the message selector
query - Display selected broker component's attributes and statistics.
start - Creates and starts a broker using a configuration file, or a broker URI.
stop - Stops a running broker specified by the broker name.

Task Options (Options specific to each task):
--extdir <dir> - Add the jar files in the directory to the classpath.
--version - Display the version information.
-h,-?,--help - Display this help information. To display task specific help, use Main [task] -h,-?,--help

Task Data:
- Information needed by each specific task.

JMX system property options:
-Dactivemq.jmx.url=<jmx service uri> (default is: 'service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi')
-Dactivemq.jmx.user=<user name>
-Dactivemq.jmx.password=<password>


[root@sz-7-centos162 test]# curl http://localhost:8980/metrics
curl: (7) couldn't connect to host
[root@sz-7-centos162 test]# ps -ef|grep javaagent
root 23739 21179 0 23:46 pts/0 00:00:00 grep javaagent
[root@sz-7-centos162 test]# cat config.yaml
{
startDelaySeconds: 0,
username: admin,
password: admin,
jmxUrl: "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi",
ssl: false,
lowercaseOutputName: false,
lowercaseOutputLabelNames: false
}
[root@sz-7-centos162 test]# ll
total 368
-rw-r--r-- 1 root root 252 Aug 26 23:19 config.yaml
-rw-r--r-- 1 root root 370075 Aug 26 17:45 jmx_prometheus_javaagent-0.12.0.jar
[root@sz-7-centos162 test]#

最佳答案

您实际上并没有启动 ActiveMQ 代理。这就是为什么它打印有关可用命令的所有信息,例如:

Usage: Main [--extdir <dir>] [task] [task-options] [task data]

Tasks:
browse - Display selected messages in a specified destination.
bstat - Performs a predefined query that displays useful statistics regarding the specified broker
create - Creates a runnable broker instance in the specified path.
decrypt - Decrypts given text
encrypt - Encrypts given text
export - Exports a stopped brokers data files to an archive file
list - Lists all available brokers in the specified JMX context
purge - Delete selected destination's messages that matches the message selector
query - Display selected broker component's attributes and statistics.
start - Creates and starts a broker using a configuration file, or a broker URI.
stop - Stops a running broker specified by the broker name.

Task Options (Options specific to each task):
--extdir <dir> - Add the jar files in the directory to the classpath.
--version - Display the version information.
-h,-?,--help - Display this help information. To display task specific help, use Main [task] -h,-?,--help

Task Data:
- Information needed by each specific task.

您会注意到这些命令之一是start。这是您实际启动代理所需运行的命令。

除此之外,您的 config.yaml 没有定义任何规则来告诉导出器要抓取和导出哪些 MBean。您可以找到各种应用程序的示例规则 here 。不幸的是,没有适用于 ActiveMQ 5.x 的工具,因此您需要制作一个。

除此之外,您可能会考虑 ActiveMQ Artemis (下一代 ActiveMQ 代理)。它有一个 plugin architecture to export metrics ,和Prometheus plugin实现,因此无需使用 JMX 导出器和配置规则。

关于java - 无法通过 jmx-exporter 从 activemq 中抓取指标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57661772/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com