This is python client for collecting IBM MQ metrics and exporting to Prometheus pushgateway. The collected metrics can be explored in Prometheus or Grafana. This client is useful in cases when requiring to collect metrics from old MQ versions.
The metrics are collected by using standard MQSC
commands. The metrics are collected for all local MQ managers. You need to run MQ metrics pyclient
in the same host where IBM MQ server
was installed.
Tested for IBM MQ v7.5, v8, v9 and Python 3.6, 3.7 on Linux.
By default, metrics are collected every 15 seconds.
The metrics provided by the client:
mq_manager_status...
- current status of MQ manager;mq_listener_status...
- current status of MQ listener;mq_channel_status...
- current status of MQ channel;mq_channel_batches...
- number of completed batches during this session (since the channel was started);mq_channel_buffers...
- number of transmission buffers received and sent;mq_channel_bytes...
- number of bytes received and sent during this session (since the channel was started);mq_channel_lmsg...
- timestamp on which the last message was sent or MQI call was handled;mq_channel_msgs...
- number of messages sent or received during this session (since the channel was started);mq_queue_curdepth...
- current depth of queue;mq_queue_maxdepth...
- maximum depth of queue;
When real-time monitoring for queues is enabled:mq_queue_msgage...
- age of the oldest message on the queue;mq_queue_lput...
- timestamp on which the last message was put to the queue;mq_queue_lget...
- timestamp on which the last message was retrieved from the queue;mq_queue_qtime...
- interval between messages being put on the queue and then being destructively read.
See detailed description of the metrics for an in-depth understanding.
You can run MQ metrics pyclient
and IB metrics pyclient together. Metrics from both clients will be sent to the same pushgateway. Conflicts will not arise.
Download Prometheus Pushgateway from the release page and unpack the tarball.
cd pushgateway
nohup ./pushgateway > pushgateway.log &
For Pushgateway the default port is used (":9091").
git clone https://github.com/AATools/mq-metrics-pyclient
cd mq-metrics-pyclient
nohup python3 mq_metrics_client.py &
After that, you should set up your Prometheus server to collect metrics from Pushgateway (http://<hostname>:9091/metrics
).
You can specify host
and port
for pushgateway and time interval in seconds between collecting metrics via command-line arguments.
python3 mq_metrics_client.py -h
usage: mq_metrics_client.py [-h] [--pghost [pushgatewayHost]] [--pgport [pushgatewayPort]] [--collectint [collectInterval]]
optional arguments:
-h, --help show this help message and exit
--pghost [pushgatewayHost]
pushgateway host
--pgport [pushgatewayPort]
pushgateway port
--collectint [collectInterval]
time interval between collecting metrics
If argument is not set the default value is used.
Command-line argument | Description | Default value |
---|---|---|
pghost |
Pushgateway host | Hostname on which client is started. Value define via platform.node() . |
pgport |
Pushgateway port | 9091 |
collectint |
Time interval between collecting metrics | 15 Time in seconds. |
The Grafana dashboard visualizes collected metrics. This is an example of a dashboard. You can create your own dashboards to analyze metrics.
Metric | Description |
---|---|
mq_manager_status | The metric shows current status of MQ manager. Metric type: gauge .If there are several managers on host, there will be a own metric for each manager. Possible values: 0 - STOPPED;1 - RUNNING.Example display in Pushgateway: mq_manager_status{default="no",instance="",instname="Installation1",instpath="/opt/mqm",instver="7.5.0.0",job="QM1",qmname="QM1",standby="Not permitted"} 1 |
mq_listener_status | The metric shows current status of MQ listener. Metric type: gauge .If there are several listeners on mq manager, there will be a own metric for each listener. The default listener SYSTEM.DEFAULT.LISTENER.TCP is hidden.Possible values: 0 - STOPPED;1 - STOPING;2 - STARTING;3 - RUNNING.Example display in Pushgateway: mq_listener_status{backlog="10000",control="QMGR",desc=" ",instance="",ipadd="*",job="QM1",listener="QM1.LST",pid="13111",port="1414",qmname="QM1",startda="2019-12-25",startti="12.00.00",trptype="TCP"} 3 |
mq_channel_status | The metric shows current status of MQ channel. Metric type: gauge .If there are several channels on mq manager, there will be a own metric for each channel. The default channels SYSTEM.* are hidden.Possible values: 0 - INACTIVE;1 - BINDING;2 - STARTING;3 - RUNNING;4 - STOPPING;5 - RETRYING;6 - STOPPED;7 - REQUESTING;8 - PAUSED;9 - DISCONNECTED;13 - INITIALIZING;14 - SWITCHING;Example display in Pushgateway: mq_channel_status{channel="QM1.SVRCONN",chltype="SVRCONN",chstada="2020-02-28",chstati="11.23.21",conname="127.0.0.1",instance="",job="QM1",jobname="000010EC00000007",qmname="QM1",rqmname="",substate="RECEIVE",xmitq=""} 3 |
mq_channel_batches | The metric shows number of completed batches during this session (since the channel was started). Metric type: counter .If there are several channels on mq manager, there will be a own metric for each channel. The default channels SYSTEM.* are hidden.The metric is collected if current status or status of saved information is available. Example display in Pushgateway: mq_channel_batches{channel="QM1.SVRCONN",chltype="SVRCONN",chstada="2020-02-28",chstati="11.23.21",conname="127.0.0.1",instance="",job="QM1",jobname="000010EC00000007",qmname="QM1",rqmname="",substate="RECEIVE",xmitq=""} 0 |
mq_channel_buffers | The metric shows number of transmission buffers received and sent. This includes transmissions to receive control information only. For each channel two value of metric are collected - indicator="buffers_received" and indicator="buffers_sent" .Metric type: counter .If there are several channels on mq manager, there will be a own metric for each channel. The default channels SYSTEM.* are hidden.The metric is collected if current status or status of saved information is available. Example display in Pushgateway: mq_channel_buffers{channel="QM1.SVRCONN",chltype="SVRCONN",chstada="2020-02-28",chstati="11.23.21",conname="127.0.0.1",indicator="buffers_received",instance="",job="QM1",jobname="000010EC00000007",qmname="QM1",rqmname="",substate="RECEIVE",xmitq=""} 8766 mq_channel_buffers{channel="QM1.SVRCONN",chltype="SVRCONN",chstada="2020-02-28",chstati="11.23.21",conname="127.0.0.1",indicator="buffers_sent",instance="",job="QM1",jobname="000010EC00000007",qmname="QM1",rqmname="",substate="RECEIVE",xmitq=""} 8765 |
mq_channel_bytes | The metric shows number of bytes received and sent during this session (since the channel was started). This includes control information received by the message channel agent. For each channel two value of metric are collected - indicator="bytes_received" and indicator="bytes_sent" .Metric type: counter .If there are several channels on mq manager, there will be a own metric for each channel. The default channels SYSTEM.* are hidden.The metric is collected if current status or status of saved information is available. Example display in Pushgateway: mq_channel_bytes{channel="QM1.SVRCONN",chltype="SVRCONN",chstada="2020-02-28",chstati="11.23.21",conname="127.0.0.1",indicator="bytes_received",instance="",job="QM1",jobname="000010EC00000007",qmname="QM1",rqmname="",substate="RECEIVE",xmitq=""} 32552 mq_channel_bytes{channel="QM1.SVRCONN",chltype="SVRCONN",chstada="2020-02-28",chstati="11.23.21",conname="127.0.0.1",indicator="bytes_sent",instance="",job="QM1",jobname="000010EC00000007",qmname="QM1",rqmname="",substate="RECEIVE",xmitq=""} 33812 |
mq_channel_lmsg | The metric shows timestamp on which the last message was sent or MQI call was handled. Metric type: gauge .If there are several channels on mq manager, there will be a own metric for each channel. The default channels SYSTEM.* are hidden.The metric is collected if current status or status of saved information is available. Example display in Pushgateway: mq_channel_lmsg{channel="QM1.SVRCONN",chltype="SVRCONN",chstada="2020-02-28",chstati="11.23.21",conname="127.0.0.1",instance="",job="QM1",jobname="000010EC00000007",qmname="QM1",rqmname="",substate="RECEIVE",xmitq=""} 1584965991 |
mq_channel_msgs | The metric shows number of messages sent or received (or, for server-connection channels, the number of MQI calls handled) during this session (since the channel was started). Metric type: counter .If there are several channels on mq manager, there will be a own metric for each channel. The default channels SYSTEM.* are hidden.The metric is collected if current status or status of saved information is available. Example display in Pushgateway: mq_channel_msgs{channel="QM1.SVRCONN",chltype="SVRCONN",chstada="2020-02-28",chstati="11.23.21",conname="127.0.0.1",instance="",job="QM1",jobname="000010EC00000007",qmname="QM1",rqmname="",substate="RECEIVE",xmitq=""} 1741 |
mq_queue_curdepth | The metric shows current depth of local queue. Metric type: gauge .The metric is available for applications and SYSTEM.* queues.Example display in Pushgateway: mq_queue_curdepth{instance="",job="QM1",qmname="QM1",queuename="DEV.QUEUE.1",type="QLOCAL"} 0 |
mq_queue_maxdepth | The metric shows maximum depth of local queue. Metric type: gauge .The metric is available for applications and SYSTEM.* queues.Example display in Pushgateway: mq_queue_maxdepth{instance="",job="QM1",qmname="QM1",queuename="DEV.QUEUE.1",type="QLOCAL"} 5000 |
mq_queue_msgage | If real-time monitoring for queues is enabled, metric will be collected. If not ( MONQ (OFF) ) or any data from real-time monitoring is blank, there is no metric collected. The metric shows age, in seconds, of the oldest message on the queue. Metric type: gauge .The maximum value is 999999999. The metricis available for applications and SYSTEM.* queues.Example display in Pushgateway: mq_queue_msgage{instance="",job="QM1",qmname="QM1",queuename="DEV.QUEUE.1"} 0 |
mq_queue_lput | If real-time monitoring for queues is enabled, metric will be collected. If not ( MONQ (OFF) ) or any data from real-time monitoring is blank, there is no metric collected. The metric shows timestamp on which the last message was put to the queue since the queue manager started. Metric type: gauge .The metricis available for applications and SYSTEM.* queues.Example display in Pushgateway: mq_queue_lput{instance="",job="QM1",qmname="QM1",queuename="DEV.QUEUE.1"} 1577181600 |
mq_queue_lget | If real-time monitoring for queues is enabled, metric will be collected. If not ( MONQ (OFF) ) or any data from real-time monitoring is blank, there is no metric collected. The metric shows timestamp on which the last message was retrieved from the queue since the queue manager started. Metric type: gauge .A message being browsed does not count as a message being retrieved. The metricis available for applications and SYSTEM.* queues.Example display in Pushgateway: mq_queue_lget{instance="",job="QM1",qmname="QM1",queuename="DEV.QUEUE.1"} 1577181601 |
mq_queue_qtime | If real-time monitoring for queues is enabled, metric will be collected. If not ( MONQ (OFF) ) or any data from real-time monitoring is blank, there is no metric collected. The metric shows interval, in microseconds, between messages being put on the queue and then being destructively read. Metric type: gauge .The maximum value is 999999999. For each queue two value of metric are collected - indicator="short_term" and indicator="long_term" . The metricis available for applications and SYSTEM.* queues.Example display in Pushgateway: mq_queue_qtime{indicator="short_term",instance="",job="QM1",qmname="QM1",queuename="DEV.QUEUE.1"} 1474 mq_queue_qtime{indicator="long_term",instance="",job="QM1",qmname="QM1",queuename="DEV.QUEUE.1"} 1486 |