Grafana Cloud

IBM DB2 integration for Grafana Cloud

IBM DB2 is a relational database management system designed to store, manage, and retrieve data efficiently. This integration for Grafana Cloud allows users to collect metrics and logs for monitoring an IBM DB2 database.

Metrics include active connections, row operations, bufferpool hit ratio, tablespace usage, average lock wait time, deadlocks, and active locks.

This integration supports IBM DB2 9.7 and onwards.

This integration includes 3 useful alerts and 2 pre-built dashboards to help monitor and visualize IBM DB2 metrics and logs.

Before you begin

For the integration to work properly, you must set up the IBM DB2 Prometheus Exporter to export metrics from IBM DB2.

Activating IBM DB2 database

For DB2 to accurately report metric values, the database being monitored must be “explicitly activated”. Activation ensures that certain metric values are correctly incremented and not periodically reset. However, it does result in a performance impact on the environment DB2 is running in. The size of this impact depends on the system, but activation results in the most accurate data reported by DB2 and, subsequently, this exporter. To explicitly activate a database, connect to DB2 and run the command activate database <dbname> and disconnect. DB2 then correctly increments and stores metrics.

db2
activate database sample
quit

To deactivate a database, connect to db2 and run the command deactivate database <dbname> and disconnect. Doing so resets the metrics reported by DB2. The database must be reactivated for metrics to be properly incremented, stored, and reported by DB2. Note: Whether or not the database is activated only affects DB2’s ability to report metrics, it does not affect DB2’s behavior as a database.

Set up IBM DB2 Exporter

For instructions on running the exporter, refer to the ibm-db2-prometheus-exporter README.

The exporter requires two flags: --dsn, the connection string (data source name) used to connect to the database, and --db, the name of the database to query. Both are required unless you provide them through the IBM_DB2_EXPORTER_DSN and IBM_DB2_EXPORTER_DB environment variables. For example:

./ibm_db2_exporter --db="sample" --dsn="DATABASE=sample;HOSTNAME=localhost;PORT=50000;UID=user;PWD=password;"

Note: The exporter uses a driver that is not compatible with ARM64 architectures. Therefore the exporter cannot be used on an ARM64 machine.

The exporter serves metrics for only one database, so to monitor multiple databases you need to set up multiple exporters. By default, the exporter serves metrics at port 9953 but can be configured to use a different port. Use the flag --web.listen-address=:<port> when running the exporter to serve metrics at a different port. This can be done so that Grafana Alloy can report metrics for multiple databases by scraping from multiple exporters.

Once deployed, Grafana Alloy can scrape the IBM DB2 Exporter.

Install IBM DB2 integration for Grafana Cloud

  1. In your Grafana Cloud stack, click Connections in the left-hand menu.
  2. Find IBM DB2 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 DB2 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 DB2 setup.

Configuration snippets for Grafana Alloy

Simple mode

These snippets are configured to scrape a single IBM DB2 instance running locally with default ports.

First, manually copy and append the following snippets into your alloy configuration file.

Metrics snippets

Alloy
prometheus.scrape "metrics_integrations_integrations_ibm_db2" {
	targets = [{
		__address__ = "localhost:9953",
		instance    = constants.hostname,
	}]
	forward_to = [prometheus.remote_write.metrics_service.receiver]
	job_name   = "integrations/ibm-db2"
}

Logs snippets

linux

Alloy
local.file_match "logs_integrations_integrations_ibm_db2" {
	path_targets = [{
		__address__ = "localhost",
		__path__    = "/home/*/sqllib/db2dump/{DIAG*,db2diag.log}/db2diag.log",
		instance    = constants.hostname,
		job         = "integrations/ibm-db2",
	}]
}

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

	stage.multiline {
		firstline     = "\\d+-\\d+-\\d+-\\d+.\\d+.\\d+.\\d+\\+\\d+\\s[A-Z0-9]+\\s+LEVEL:\\s[a-zA-Z]+"
		max_lines     = 0
		max_wait_time = "3s"
	}
}

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

Advanced mode

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

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

Advanced metrics snippets

Alloy
prometheus.scrape "metrics_integrations_integrations_ibm_db2" {
	targets = [{
		__address__ = "localhost:9953",
		instance    = constants.hostname,
	}]
	forward_to = [prometheus.remote_write.metrics_service.receiver]
	job_name   = "integrations/ibm-db2"
}

To monitor your IBM DB2 instance, you must use a prometheus.scrape component to scrape your IBM DB2 Prometheus endpoint.

Configure the following properties within the prometheus.scrape component’s targets:

  • __address__: The address to your IBM DB2 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 DB2 instance. Make sure this label value is the same for all telemetry data collected for this instance.

If you have multiple IBM DB2 servers to scrape, add a target entry for each under targets within the prometheus.scrape component.

Advanced logs snippets

linux

Alloy
local.file_match "logs_integrations_integrations_ibm_db2" {
	path_targets = [{
		__address__ = "localhost",
		__path__    = "/home/*/sqllib/db2dump/{DIAG*,db2diag.log}/db2diag.log",
		instance    = constants.hostname,
		job         = "integrations/ibm-db2",
	}]
}

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

	stage.multiline {
		firstline     = "\\d+-\\d+-\\d+-\\d+.\\d+.\\d+.\\d+\\+\\d+\\s[A-Z0-9]+\\s+LEVEL:\\s[a-zA-Z]+"
		max_lines     = 0
		max_wait_time = "3s"
	}
}

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

To monitor your IBM DB2 instance logs, you use a combination of the following 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 DB2 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 DB2 instance. Make sure this label value is the same for all telemetry data collected for this instance.

Logs are found where the DB2 instance is located, inside the sqllib directory. For a single member environment, logs are available at /path/to/inst/sqllib/db2dump/db2diag.log. For multi-member environments logs are located at /path/to/inst/sqllib/db2dump/DIAG*/db2diag.log. You can edit the __path__ label for logs to match your environment.

Kubernetes instructions

Dashboards

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

  • IBM DB2 logs
  • IBM DB2 overview

IBM DB2 overview (metrics)

IBM DB2 overview (metrics)

IBM DB2 logs (logs)

IBM DB2 logs (logs)

Alerts

The IBM DB2 integration includes the following useful alerts:

AlertDescription
IBMDB2HighLockWaitTimeWarning: The average amount of time waiting for locks to become free is abnormally large.
IBMDB2HighNumberOfDeadlocksCritical: There are deadlocks occurring in the database.
IBMDB2LogUsageReachingLimitWarning: The amount of log space available for the DB2 instance is running out of space, rotate logs or delete unnecessary storage usage.

Metrics

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

  • ibm_db2_application_active
  • ibm_db2_bufferpool_hit_ratio
  • ibm_db2_deadlock_total
  • ibm_db2_lock_usage
  • ibm_db2_lock_wait_time
  • ibm_db2_log_operations_total
  • ibm_db2_log_usage
  • ibm_db2_row_total
  • ibm_db2_tablespace_usage
  • ibm_db2_up
  • up

Changelog

md
# 1.1.3 - October 2026

- Document the exporter's required `--dsn` and `--db` flags, fix the stray `;` in the `--web.listen-address` flag example, and update the advanced metrics instructions to describe the `prometheus.scrape` component the snippet actually uses instead of a `discovery.relabel` component.

# 1.1.2 - October 2026

- Fix: Set the `job` log label to `integrations/ibm-db2` in the Kubernetes Helm chart snippet. It was incorrectly set to `integrations/apache-activemq`, so logs collected through Kubernetes didn't appear in the IBM DB2 dashboards.

# 1.1.1 - June 2026

- Fixed issue with default filtering selectors

# 1.1.0 - June 2026

- Updated dashboards to follow new stylistic standards
- Added a dedicated logs dashboard `IBM DB2 logs`

# 1.0.0 - December 2023

- Added Grafana Agent Operator configuration snippet to support IBM DB2 in kubernetes cluster
- Added cluster selector to dashboard for kubernetes support
- Added default cluster label to agent config
- Bump version to 1.0.0

# 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 DB2 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 and Cloud tier pricing.