---
title: "IBM MQ integration | Grafana Cloud documentation"
description: "Learn about IBM MQ Grafana Cloud integration."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# IBM MQ integration for Grafana Cloud

IBM MQ is a message queue software that can be deployed across a range of different environments. MQ sends and receives messages via message queues to support the exchange of information between applications, systems, and services.

This integration includes useful visualizations for cluster, queue manager, queue, and topic metrics. Metrics such as the number of messages sent and received by queue managers and queues, the number of different queue operations, disk usage, CPU usage, active connections, average queue time, and expired messages.

This integration supports IBM MQ 9.1+

This integration includes 4 useful alerts and 4 pre-built dashboards to help monitor and visualize IBM MQ metrics and logs.

## Before you begin

In order for the integration to properly work, you must set up the [MQ Prometheus exporter](https://github.com/ibm-messaging/mq-metric-samples/tree/master/cmd/mq_prometheus) for each queue manager in the cluster.

#### Set up Prometheus exporter

Each instance of the exporter can be run by running the following [setup script](https://github.com/ibm-messaging/mq-metric-samples/blob/master/cmd/mq_prometheus/mq_prometheus.sh).

This file specifies multiple arguments for monitoring your IBM MQ cluster and its objects. Modify this file to ensure that the supplied arguments match your IBM MQ environment.

Key arguments that must be checked include:

- ibmmq.queueManager=`<qmgr>`
- ibmmq.monitoredChannels=`<channels>`
- ibmmq.monitoredTopics=`<topics>`
- ibmmq.monitoredSubscriptions=`<subscriptions>`
- ibmmq.monitoredQueues=`<queues>`

`<qmgr>, <queues>, <channels>, <topics>, <subscriptions>` must be replaced with the regular expression that will match the respective object of your instance of the exporter is monitoring.  
\* ex: Channel Name: `LONDON.NEWYORK` —-&gt; `<channels>`: LONDON.*

### Windows

See [here](https://github.com/ibm-messaging/mq-metric-samples/blob/master/README.md#building-to-run-on-windows) for additional help on building to run on Windows.

The exporter uses port `9157` by default to expose metrics, however if multiple queue managers are going to be monitored by Grafana Alloy on the same machine, you must change the default port. This can be done using the `ibmmq.httpListenPort` flag when running the exporter.

For more information on how to configure the exporter for each queue manager, please refer to the [documentation](https://github.com/ibm-messaging/mq-metric-samples/tree/master/cmd/mq_prometheus) for details.

Once deployed, Grafana Alloy should be able to reach the exporter’s exposed metrics endpoint.

## Install IBM MQ integration for Grafana Cloud

1. In your Grafana Cloud stack, click **Connections** in the left-hand menu.
2. Find **IBM MQ** and click its tile to open the integration.
3. Review the prerequisites in the **Configuration Details** tab and set up Grafana Alloy to send IBM MQ metrics and logs to your Grafana Cloud instance.
4. Click **Install** to add this integration’s pre-built dashboards and alerts to your Grafana Cloud instance, and you can start monitoring your IBM MQ setup.

## Configuration snippets for Grafana Alloy

### Advanced mode

The following snippets provide examples to guide you through the configuration process.

To instruct Grafana Alloy to scrape your IBM MQ instances, **manually** copy and append the snippets to your alloy configuration file, then follow subsequent instructions.

### Advanced metrics snippets

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
discovery.relabel "metrics_integrations_integrations_ibm_mq" {
	targets = concat(
		[{
			__address__ = "<exporter-hostname-1>:<exporter-port-1>",
		}],
		[{
			__address__ = "<exporter-hostname-2>:<exporter-port-2>",
		}],
	)

	rule {
		target_label = "instance"
		replacement  = constants.hostname
	}

	rule {
		target_label = "mq_cluster"
		replacement  = "<your-cluster-name>"
	}
}

prometheus.scrape "metrics_integrations_integrations_ibm_mq" {
	targets    = discovery.relabel.metrics_integrations_integrations_ibm_mq.output
	forward_to = [prometheus.remote_write.metrics_service.receiver]
	job_name   = "integrations/ibm-mq"
}
```

To monitor your IBM MQ instance, you must use a [discovery.relabel](/docs/alloy/latest/reference/components/discovery.relabel/) component to discover your IBM MQ Prometheus endpoint and apply appropriate labels, followed by a [prometheus.scrape](/docs/alloy/latest/reference/components/prometheus.scrape) component to scrape it.

Configure the following properties within each `discovery.relabel` component:

- `__address__`: The address to your IBM MQ Prometheus metrics endpoint.
- `instance` label: `constants.hostname` sets the `instance` label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this IBM MQ instance. Make sure this label value is the same for all telemetry data collected for this instance.
- `mq_cluster`: The `mq_cluster` label to group your IBM MQ instances within a cluster. Set the same value for all nodes within your cluster.

If you have multiple IBM MQ servers to scrape, configure one `discovery.relabel` for each and scrape them by including each under `targets` within the `prometheus.scrape` component.

### Advanced logs snippets

#### linux

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
local.file_match "logs_integrations_integrations_ibm_mq" {
	path_targets = [{
		__address__ = "localhost",
		__path__    = "/var/mqm/errors/*.LOG",
		instance    = constants.hostname,
		job         = "integrations/ibm-mq",
		mq_cluster  = "<your-cluster-name>",
	}]
}

loki.process "logs_integrations_integrations_ibm_mq" {
	forward_to = [loki.write.grafana_cloud_loki.receiver]

	stage.match {
		selector = "{job=\"integrations/ibm-mq\",instance=\"<your-instance-name>\"}"

		stage.regex {
			expression = "/var/mqm/qmgrs/(?P<qmgr>.*?)/errors/.*\\.LOG"
			source     = "filename"
		}

		stage.labels {
			values = {
				qmgr = null,
			}
		}
	}

	stage.multiline {
		firstline     = "^\\s*\\d{2}\\/\\d{2}\\/\\d{2}\\s+\\d{2}:\\d{2}:\\d{2}\\s*-"
		max_lines     = 0
		max_wait_time = "3s"
	}
}

loki.source.file "logs_integrations_integrations_ibm_mq" {
	targets    = local.file_match.logs_integrations_integrations_ibm_mq.targets
	forward_to = [loki.process.logs_integrations_integrations_ibm_mq.receiver]
}
```

To monitor your IBM MQ instance logs, you will use a combination of the following components:

- [local.file\_match](/docs/alloy/latest/reference/components/local.file_match) defines where to find the log file to be scraped. Change the following properties according to your environment:
  
  - `__address__`: The IBM MQ instance address
  - `__path__`: The path to the log file.
  - `instance` label: `constants.hostname` sets the `instance` label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this IBM MQ instance. Make sure this label value is the same for all telemetry data collected for this instance.
  - `mq_cluster`: The `mq_cluster` label to group your IBM MQ instances within a cluster. Set the same value for all nodes within your cluster.
- [loki.process](/docs/alloy/latest/reference/components/loki.process) defines how to process logs before sending it to Loki.
- [loki.source.file](/docs/alloy/latest/reference/components/loki.source.file) sends logs to Loki.

#### windows

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
local.file_match "logs_integrations_integrations_ibm_mq" {
	path_targets = [{
		__address__ = "localhost",
		__path__    = "/var/mqm/errors/*.LOG",
		instance    = constants.hostname,
		job         = "integrations/ibm-mq",
		mq_cluster  = "<your-cluster-name>",
	}]
}

loki.process "logs_integrations_integrations_ibm_mq" {
	forward_to = [loki.write.grafana_cloud_loki.receiver]

	stage.match {
		selector = "{job=\"integrations/ibm-mq\",instance=\"<your-instance-name>\"}"

		stage.regex {
			expression = "/var/mqm/qmgrs/(?P<qmgr>.*?)/errors/.*\\.LOG"
			source     = "filename"
		}

		stage.labels {
			values = {
				qmgr = null,
			}
		}
	}

	stage.multiline {
		firstline     = "^\\s*\\d{2}\\/\\d{2}\\/\\d{2}\\s+\\d{2}:\\d{2}:\\d{2}\\s*-"
		max_lines     = 0
		max_wait_time = "3s"
	}
}

loki.source.file "logs_integrations_integrations_ibm_mq" {
	targets    = local.file_match.logs_integrations_integrations_ibm_mq.targets
	forward_to = [loki.process.logs_integrations_integrations_ibm_mq.receiver]
}
```

To monitor your IBM MQ instance logs, you will use a combination of the following components:

- [local.file\_match](/docs/alloy/latest/reference/components/local.file_match) defines where to find the log file to be scraped. Change the following properties according to your environment:
  
  - `__address__`: The IBM MQ instance address
  - `__path__`: The path to the log file.
  - `instance` label: `constants.hostname` sets the `instance` label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this IBM MQ instance. Make sure this label value is the same for all telemetry data collected for this instance.
  - `mq_cluster`: The `mq_cluster` label to group your IBM MQ instances within a cluster. Set the same value for all nodes within your cluster.
- [loki.process](/docs/alloy/latest/reference/components/loki.process) defines how to process logs before sending it to Loki.
- [loki.source.file](/docs/alloy/latest/reference/components/loki.source.file) sends logs to Loki.

## Kubernetes instructions

Instructions for Kubernetes

### Before you begin with Kubernetes

**Please note**: These instructions assume the use of the [Kubernetes Monitoring Helm chart](https://github.com/grafana/k8s-monitoring-helm)

In order for the integration to properly work, you must set up the [MQ Prometheus exporter](https://github.com/ibm-messaging/mq-metric-samples/tree/master/cmd/mq_prometheus) for each queue manager in the cluster.

#### Set up Prometheus exporter

Each instance of the exporter can be run by running the following [setup script](https://github.com/ibm-messaging/mq-metric-samples/blob/master/cmd/mq_prometheus/mq_prometheus.sh).

This file specifies multiple arguments for monitoring your IBM MQ cluster and its objects. Modify this file to ensure that the supplied arguments match your IBM MQ environment.

Key arguments that must be checked include:

- ibmmq.queueManager=`<qmgr>`
- ibmmq.monitoredChannels=`<channels>`
- ibmmq.monitoredTopics=`<topics>`
- ibmmq.monitoredSubscriptions=`<subscriptions>`
- ibmmq.monitoredQueues=`<queues>`

`<qmgr>, <queues>, <channels>, <topics>, <subscriptions>` must be replaced with the regular expression that will match the respective object of your instance of the exporter is monitoring.  
\* ex: Channel Name: `LONDON.NEWYORK` —-&gt; `<channels>`: LONDON.*

### Configuration snippets for Kubernetes Helm chart

The following snippets provide examples to guide you through the configuration process.

To scrape your IBM MQ instances, **manually** modify your Kubernetes Monitoring Helm chart with these configuration snippets.

Replace any values between the angle brackets `<>` in the provided snippets with your desired configuration values.

#### Metrics snippets

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
alloy-metrics:
    extraConfig: |-
        discovery.kubernetes "ibm_mq" {
            role = "pod"
            selectors {
                role = "pod"
                label = "<ibm-mq-pod-label>=<ibm-mq-pod-label-value>"
            }
        }
        
        discovery.relabel "ibm_mq" {
            targets = discovery.kubernetes.ibm_mq.targets
            rule {
                source_labels = ["__meta_kubernetes_pod_container_port_number"]
                regex = "9157"
                action = "keep"
            }
            rule {
                target_label = "mq_cluster"
                replacement = "<ibm-mq-cluster-label>"
            }
            rule {
                source_labels = ["__meta_kubernetes_namespace", "__meta_kubernetes_pod_container_name"]
                separator = "-"
                target_label = "instance"
            }
        }
        prometheus.scrape "ibm_mq" {
            targets    = discovery.relabel.ibm_mq.output
            job_name   = "integrations/ibm-mq"
            forward_to = [prometheus.remote_write.grafana_cloud_metrics.receiver]
        }
```

#### Logs snippets

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
podLogs:
    extraDiscoveryRules: |-
        rule {
            source_labels = ["__meta_kubernetes_pod_label_<ibm-mq-pod-label>"]
            regex = "<ibm-mq-pod-label-value>"
            replacement = "ibm-mq"
            target_label = "integration"
        }

    extraLogProcessingStages: |-
        stage.match {
            selector = "{integration=\\"ibm-mq\\"}"

            stage.multiline {
                firstline = \`^\\s*\\d{2}\\/\\d{2}\\/\\d{2}\\s+\\d{2}:\\d{2}:\\d{2}\\s*-'\`
            }

            stage.template {
                source   = "instance"
                template = "{{ .namespace }}-{{ .container }}"
            }

            stage.static_labels {
                values = {
                    mq_cluster = "<your-cluster-name>",
                    log_type   = "mq-qmgr-error",
                    job        = "integrations/ibm-mq",
                }
            }
        }
```

## Dashboards

The IBM MQ integration installs the following dashboards in your Grafana Cloud instance to help monitor your system.

- IBM MQ cluster overview
- IBM MQ queue manager overview
- IBM MQ queue overview
- IBM MQ topics overview

**IBM MQ cluster overview**

**IBM MQ queue manager overview (performance)**

**IBM MQ queue overview**

## Alerts

The IBM MQ integration includes the following useful alerts:

Expand table

| Alert                         | Description                                                                               |
|-------------------------------|-------------------------------------------------------------------------------------------|
| IBMMQExpiredMessages          | Critical: There are expired messages, which imply that application resilience is failing. |
| IBMMQStaleMessages            | Warning: Stale messages have been detected.                                               |
| IBMMQLowDiskSpace             | Critical: There is limited disk available for a queue manager.                            |
| IBMMQHighQueueManagerCpuUsage | Critical: There is a high CPU usage estimate for a queue manager.                         |

## Metrics

The most important metrics provided by the IBM MQ integration, which are used on the pre-built dashboards and Prometheus alerts, are as follows:

- ibmmq\_channel\_xmitq\_time\_long
- ibmmq\_channel\_xmitq\_time\_short
- ibmmq\_cluster\_suspend
- ibmmq\_qmgr\_active\_listeners
- ibmmq\_qmgr\_commit\_count
- ibmmq\_qmgr\_connection\_count
- ibmmq\_qmgr\_expired\_message\_count
- ibmmq\_qmgr\_log\_in\_use\_bytes
- ibmmq\_qmgr\_log\_write\_latency\_seconds
- ibmmq\_qmgr\_published\_to\_subscribers\_bytes
- ibmmq\_qmgr\_published\_to\_subscribers\_message\_count
- ibmmq\_qmgr\_queue\_manager\_file\_system\_free\_space\_percentage
- ibmmq\_qmgr\_queue\_manager\_file\_system\_in\_use\_bytes
- ibmmq\_qmgr\_ram\_total\_bytes
- ibmmq\_qmgr\_ram\_total\_estimate\_for\_queue\_manager\_bytes
- ibmmq\_qmgr\_status
- ibmmq\_qmgr\_system\_cpu\_time\_percentage
- ibmmq\_qmgr\_uptime
- ibmmq\_qmgr\_user\_cpu\_time\_estimate\_for\_queue\_manager\_percentage
- ibmmq\_qmgr\_user\_cpu\_time\_percentage
- ibmmq\_queue\_average\_queue\_time\_seconds
- ibmmq\_queue\_depth
- ibmmq\_queue\_expired\_messages
- ibmmq\_queue\_mqclose\_count
- ibmmq\_queue\_mqget\_bytes
- ibmmq\_queue\_mqget\_count
- ibmmq\_queue\_mqinq\_count
- ibmmq\_queue\_mqopen\_count
- ibmmq\_queue\_mqput\_bytes
- ibmmq\_queue\_mqput\_mqput1\_count
- ibmmq\_queue\_mqset\_count
- ibmmq\_queue\_oldest\_message\_age
- ibmmq\_subscription\_messsages\_received
- ibmmq\_subscription\_time\_since\_message\_published
- ibmmq\_topic\_messages\_received
- ibmmq\_topic\_publisher\_count
- ibmmq\_topic\_subscriber\_count
- ibmmq\_topic\_time\_since\_msg\_received
- up

## Changelog

md ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```md
# 1.0.0 - February 2024
* Updated versioning to 1.x
* Added Grafana Agent Operator configuration snippet to support IBM MQ in kubernetes cluster
* Added cluster selector to dashboard for kubernetes support

# 0.0.3 - September 2023

* New Filter Metrics option for configuring the Grafana Agent, which saves on metrics cost by dropping any metric not used by this integration. Beware that anything custom built using metrics that are not on the snippet will stop working.
* New hostname relabel option, which applies the instance name you write on the text box to the Grafana Agent configuration snippets, making it easier and less error prone to configure this mandatory label.

# 0.0.2 - August 2023

* Add regex filter for logs datasource

# 0.0.1 - July 2023

* Initial release
```

## Cost

By connecting your IBM MQ instance to Grafana Cloud, you might incur charges. To view information on the number of active series that your Grafana Cloud account uses for metrics included in each Cloud tier, see [Active series and dpm usage](/docs/grafana-cloud/fundamentals/active-series-and-dpm/) and [Cloud tier pricing](/products/cloud/pricing/).
