5.5. Accessing broker runtime data using Prometheus
Prerequisites
- To query and visualize the broker runtime data collected by the Prometheus plugin, you need to install Prometheus. For more information, see Installing Prometheus in the Prometheus documentation.
Procedure
-
From your Prometheus installation directory, open the
prometheus.ymlconfiguration file. -
In the
static_configssection of the configuration file, change thetargetselement tolocalhost:8161. This location is where the broker runs its web server. By default,/metricsis appended to this host name, forming the full path to the metrics stored on the broker web server. To view the broker runtime metrics collected by the Prometheus plugin, open
localhost:8161/metricsin a web browser.On the resulting web page, you see the current values of the metrics collected by the plugin, based on the queues and addresses that you have configured on the broker. If you have more than one running broker instance in your JVM, you see metrics for each broker.
From your Prometheus installation directory, run Prometheus.
$ ./prometheusWhen Prometheus starts, the shell output includes the following line:
component=web, msg=”Start listening for connections” address=0.0.0.0:9090The preceding line indicates that Prometheus is listening for HTTP traffic on port 9090.
-
To access the Prometheus web console, open
127.0.0.1:9090in a web browser. In the Prometheus web console, you can use the
Expressionfield to create a query on your broker data. The queries you create are based on the Prometheus query language, PromQL. Broker metrics that are available to insert in your query are in theInsert metricdrop-down list.As a simple example, suppose you want to query the message count on the DLQ queue, over time. In this case, select
artemis_message_countfrom the metrics drop-down list. Complete your query by specifying the DLQ queue name and address. This example query is shown below.artemis_message_count{address=“DLQ”, queue=“DLQ”}For more advanced visualizations, you can use regular expressions to create complex queries that overlay several metrics, for example. Or, you can perform mathematical operations on a number of metrics, such as aggregating them. For more information about creating Prometheus queries, see Querying Prometheus in the Prometheus documentation.