无法通过 jmx 导出器从 activemq 中抓取指标



无法从 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

我得到了一些关于活动mq的输出信息。 然后我试着卷曲它:curl http://localhost:8980/metrics.

并得到错误:curl: (7) couldn't connect to host

我检查了这个过程。并发现没有java进程的jvm导出器。

为什么?我做错了什么?

这是我的配置.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没有任何定义rules来告诉导出商要抓取和导出哪些MBean。您可以在此处找到各种应用程序的示例规则。不幸的是,ActiveMQ 5.x没有一个,所以你需要工作一个。

除此之外,您还可以考虑ActiveMQ Artemis(下一代ActiveMQ代理(。它具有导出指标的插件架构和 Prometheus 插件实现,因此无需使用 JMX 导出器和配置规则。

相关内容

  • 没有找到相关文章

最新更新