无法通过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 http://localhost:8980/metrics
。
并得到错误:curl: (7) couldn't connect to host
我检查了该过程。并发现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]#
答案 0 :(得分:0)
您实际上并没有启动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
没有定义任何rules
来告诉导出者要刮擦和导出的MBean。您可以找到各种应用程序here的示例规则。不幸的是,ActiveMQ 5.x没有一个,因此您需要进行一次改进。
除此之外,您还可以考虑使用ActiveMQ Artemis(下一代ActiveMQ代理)。它具有plugin architecture to export metrics和Prometheus plugin实现,因此无需使用JMX导出器和配置规则。