此内容没有您所选择的语言版本。
Chapter 9. Monitoring your brokers
To monitor runtime data for brokers in your deployment, use one of these approaches:
In general, using Prometheus is the recommended approach. However, you might choose to use the Jolokia REST interface to JMX if a metric that you need to monitor is not exported by the Prometheus plugin. For more information about the broker runtime metrics that the Prometheus plugin exports, see Section 9.1.1, “Overview of Prometheus metrics”.
9.1. Monitoring broker runtime data using Prometheus 复制链接链接已复制到粘贴板!
The following subsections describe how to monitor broker runtime data using the Prometheus plugin for AMQ Broker.
9.1.1. Overview of Prometheus metrics 复制链接链接已复制到粘贴板!
To monitor the health and performance of your broker instances, you can use the Prometheus plugin for AMQ Broker to monitor and store broker runtime metrics. Prometheus is software built for monitoring large, scalable systems and storing historical runtime data over an extended time period. The AMQ Broker Prometheus plugin exports the broker runtime metrics to Prometheus format, enabling you to use Prometheus itself to visualize and run queries on the data.
You can also use a graphical tool, such as Grafana, to configure more advanced visualizations and dashboards for the metrics that the Prometheus plugin collects.
The metrics that the plugin exports to Prometheus format are listed below. A description of each metric is exported along with the metric itself.
Broker Metrics
-
address.memory.usage -
connection.count -
total.connection.count
Address Metrics
-
routed.message.count -
unrouted.message.count
Queue Metrics
-
consumer.count -
delivering.durable.message.count -
delivering.durable.persistent.size -
delivering.message.count -
delivering.persistent.size -
durable.message.count -
durable.persistent.size -
messages.acknowledged -
messages.added -
message.count -
messages.killed -
messages.expired -
persistent.size -
scheduled.durable.message.count -
scheduled.durable.persistent.size -
scheduled.message.count -
scheduled.persistent.size
For higher-level broker metrics that are not listed above, you can calculate these by aggregating lower-level metrics. For example, to calculate total message count, you can aggregate the message.count metrics from all queues in your broker deployment.
Java Virtual Machine (JVM) memory metrics are also exported to Prometheus format.
This procedure shows how to enable the Prometheus plugin for a broker Pod in a given deployment.
Prerequisites
- You can enable the Prometheus plugin for a broker Pod created with application templates or with the AMQ Broker Operator. However, your deployed broker must use the broker container image for AMQ Broker 7.5 or later. For more information about ensuring that your broker deployment uses the latest broker container image, see Section 4.2, “Upgrading a templates-based broker deployment”.
Procedure
- Log in to the OpenShift Container Platform web console with administrator privileges for the project that contains your broker deployment.
-
In the web console, click
(OpenShift Container Platform 4.1) or the drop-down list in the top-left corner (OpenShift Container Platform 3.11). Choose the project that contains your broker deployment. To see the Stateful Sets or Deployment Configs in your project, click:
-
or (OpenShift Container Platform 4.1). -
or (OpenShift Container Platform 3.11).
-
- Click the Stateful Set or Deployment Config that corresponds to your broker deployment.
- To access the environment variables for your broker deployment, click the Environment tab.
Add a new environment variable,
AMQ_ENABLE_METRICS_PLUGIN. Set the value of the variable totrue.When you set the
AMQ_ENABLE_METRICS_PLUGINenvironment variable, OpenShift restarts each broker Pod in the Stateful Set or Deployment Config. When there are multiple Pods in the deployment, OpenShift restarts each Pod in turn. When each broker Pod restarts, the Prometheus plugin for that broker starts to gather broker runtime metrics.
The AMQ_ENABLE_METRICS_PLUGIN environment variable is included by default in the application templates for AMQ Broker 7.5 or later. To enable the plugin for each broker in a new templates-based deployment, ensure that the value of AMQ_ENABLE_METRICS_PLUGIN is set to true when deploying the application template.
Additional resources
- For information about installing the latest application templates, see Section 3.1, “Installing the image streams and application templates”
This procedure shows how to access Prometheus metrics for a running broker Pod.
Prerequisites
- You must have already enabled the Prometheus plugin for your broker Pod. See Section 9.1.2, “Enabling the Prometheus plugin for a running broker deployment”.
Procedure
For the broker Pod whose metrics you want to access, you need to identify the Route you previously created to connect the Pod to the AMQ Broker management console. The Route name forms part of the URL needed to access the metrics.
-
Click
(OpenShift Container Platform 4.1) or (OpenShift Container Platform 3.11). For your chosen broker Pod, identify the Route created to connect the Pod to the AMQ Broker management console. Under Hostname, note the complete URL that is shown. For example:
http://rte-console-access-pod1.openshiftdomain
http://rte-console-access-pod1.openshiftdomainCopy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Click
To access Prometheus metrics, in a web browser, enter the previously noted Route name appended with
“/metrics”. For example:http://rte-console-access-pod1.openshiftdomain/metrics
http://rte-console-access-pod1.openshiftdomain/metricsCopy to Clipboard Copied! Toggle word wrap Toggle overflow
If your console configuration does not use SSL, specify http in the URL. In this case, DNS resolution of the host name directs traffic to port 80 of the OpenShift router. If your console configuration uses SSL, specify https in the URL. In this case, your browser defaults to port 443 of the OpenShift router. This enables a successful connection to the console if the OpenShift router also uses port 443 for SSL traffic, which the router does by default.
9.2. Monitoring broker runtime data using JMX 复制链接链接已复制到粘贴板!
This example shows how to monitor a broker using the Jolokia REST interface to JMX.
Prerequisites
- This example builds upon Preparing a templates-based broker deployment.
- Completion of Deploying a basic broker is recommended.
Procedure
Get the list of running pods:
oc get pods
$ oc get pods NAME READY STATUS RESTARTS AGE broker-amq-1-ftqmk 1/1 Running 0 14dCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run the
oc logscommand:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run your query to monitor your broker for
MaxConsumers:curl -k -u admin:admin http://console-broker.amq-demo.apps.example.com/console/jolokia/read/org.apache.activemq.artemis:broker=%22broker%22,component=addresses,address=%22TESTQUEUE%22,subcomponent=queues,routing-type=%22anycast%22,queue=%22TESTQUEUE%22/MaxConsumers
$ curl -k -u admin:admin http://console-broker.amq-demo.apps.example.com/console/jolokia/read/org.apache.activemq.artemis:broker=%22broker%22,component=addresses,address=%22TESTQUEUE%22,subcomponent=queues,routing-type=%22anycast%22,queue=%22TESTQUEUE%22/MaxConsumers {"request":{"mbean":"org.apache.activemq.artemis:address=\"TESTQUEUE\",broker=\"broker\",component=addresses,queue=\"TESTQUEUE\",routing-type=\"anycast\",subcomponent=queues","attribute":"MaxConsumers","type":"read"},"value":-1,"timestamp":1528297825,"status":200}Copy to Clipboard Copied! Toggle word wrap Toggle overflow