1. Install Artemis
Download artemis from https://activemq.apache.org/artemis/download.html
Unzip artemis to a location
Lets call the location where Artemis is installed as ARTEMIS_HOME
2. Create a messaging broker
Choose a new location to store broker. Lets call this location as "ARTEMIS_BROKERS"
cd to "ARTEMIS_BROKERS"
Run command : ./${ARTEMIS_HOME}/bin/artemis create "firstbroker"
Command will result in creation of broker with name "firstbroker" inside "ARTEMIS_BROKERS" location
Test the broker by
Goto to directory "${ARTEMIS_BROKERS}/firstbroker/bin"
Run command ./artemis run (on windows artemis.cmd run)
If the everything went well you should be able to access artemis console at http://localhost:8161/console
3. Next step is to export Jmx as metrics using Prometheous jmx exporter javaagent
Download the javaagent jar jmx_prometheus_javaagent-0.3.2-SNAPSHOT.jar from https://github.com/prometheus/jmx_exporter
Move jmx_prometheus_javaagent-0.3.2-SNAPSHOT.jar to ${ARTEMIS_HOME}/lib
You can read more about Prometheus jmx export here https://github.com/prometheus/jmx_exporter
Download artemis-2.yml from https://github.com/prometheus/jmx_exporter/tree/master/example_configs
Move the file to ${ARTEMIS_BROKERS}/firstbroker/etc"
Stop the broker if already running
Edit command in artemis.sh file where the "exec" makes call to java to launch org.apache.activemq.artemis.boot.Artemis
Add the entry for javaagent and modified command will look like
exec "$JAVACMD" $JAVA_ARGS $ARTEMIS_CLUSTER_PROPS \
-javagent:"${ARTEMIS_HOME}/lib/jmx_prometheus_javaagent-0.3.2-SNAPSHOT.jar"="8080:${ARTEMIS_BROKERS}/firstbroker/etc/artemis-2.yml"
-classpath "$CLASSPATH" \
-Dartemis.home="$ARTEMIS_HOME" \
-Djava.library.path="$ARTEMIS_HOME/bin/lib/linux-$(uname -m)" \
$DEBUG_ARGS \
org.apache.activemq.artemis.boot.Artemis "$@"
Note : For windows mention relative paths for -javaagent. Giving full path ( due to colon bein separater in javaagent options) will result in error.
Restart the broker
./artemis run (on windows artemis.cmd run)
Call http://localhost:8080/metrics from browsers.
Details of Jvm is coming on the screen.
4. Enable Local Monitoring and Management to expose MBean showing broker details
Next step is to expose MBean showing broker details
To allow the JMX client access to a local Java VM, you had to set the system property com.sun.management.jmxremote to true for the for the Artemis java process.
Update command to add -Dcom.sun.management.jmxremote=true
Final command looks like
exec "$JAVACMD" $JAVA_ARGS $ARTEMIS_CLUSTER_PROPS \
-javagent:${ARTEMIS_HOME}/lib/jmx_prometheus_javaagent-0.3.2-SNAPSHOT.jar"="8080:${ARTEMIS_BROKERS}/firstbroker/etc/artemis-2.yml
-classpath "$CLASSPATH" \
-Dartemis.home="$ARTEMIS_HOME" \
-Dcom.sun.management.jmxremote=true \
-Djava.library.path="$ARTEMIS_HOME/bin/lib/linux-$(uname -m)" \
$DEBUG_ARGS \
org.apache.activemq.artemis.boot.Artemis "$@"
Restart the broker
Call http://localhost:8080/metrics from browsers.
Now the broker details is coming in response.
5. Install and Run Prometheus server
Download Prometheus server from https://prometheus.io/download/ and untar in a location. Lets call Prometheus server location to ${PROMETHEUS_HOME}
Update prometheus.yml file located inside ${PROMETHEUS_HOME}
Updated scrape_configs section looks like. We have update the targets to point to the metrics exposed by Prometheus jmx exporter agent
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:8080']
Start the Prometheus server
Browse to http://localhost:9090
Metrics are available on graph page
6. Create Grafana dashboard for Artemis
Download Grafana from https://grafana.com/grafana/download based on the platform and unzip to a location .
Lets call the location as GRAFANA_HOME
Start the grafana server.
Launch the grafana console. http://localhost:3000
Create the new datasource named DS_PROMETHEUS of type premetheus with url pointing to Prometheus server(localhost:9090 in this case)
Create Artemis dashboard by importing file from https://grafana.com/api/dashboards/9087/revisions/1/download
Change the instance variable to localhost:8080
All done !!
0 comments:
Post a Comment