can't scrape metrics from activemq by jmx-exporter
i download the jmx exporter to my virtual machine and i follow the directions to run the command like this: 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
And i get some output info about the activemq. then i try to curl it: curl http://localhost:8980/metrics
.
And get the error: curl: (7) couldn't connect to host
I check out the process. And found there is no java process of the jvm-exporter.
Why? something i do wrong?
here is my 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
}
I expect curl http://localhost:8980/metrics to get the metrics,but actual it just display me some info about activemq but do nothing. all the output info and my operate are paste below:
[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]#
You aren't actually starting the ActiveMQ broker. That's why it prints all that information about what commands are available, eg:
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.
You'll notice that one of those commands is start
. This is the command you need to run to actually start a broker.
Aside from that, your config.yaml
doesn't have any rules
defined to tell the exporter what MBeans to scrape & export. You can find example rules for various application here . Unfortunately there isn't one for ActiveMQ 5.x so you'll need to work one up.
Aside from that you might consider ActiveMQ Artemis (the next generation of ActiveMQ broker). It has a plugin architecture to export metrics , and Prometheus plugin implementation so there's no need to use the JMX exporter and configure rules.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.