Setting up email alerts for replication

You can receive email alerts for errors or status changes in your replication environment by setting up the Replication Alert Monitor within IBM® Data Replication for Availability.

Before you begin

To enable alerts:

  • For IBM Integrated Analytics System, configure an email server. See ap config command for details. If you are running replication in Db2® Warehouse, the email server is configured automatically when you enable monitoring.
  • Ensure that you have unique replication user IDs on both the source and target databases with DBADM authority.
  • Run all scripts while logged in as dsadm.

About this task

The monitor program (also known as asnmon) is included in the Db2 common container. It runs in the source database and monitors the status of the replication capture and apply programs. The program monitors for alert conditions, which are conditions in the replication environment that trigger email alerts.

The following alert conditions are available:

qcapture_status When the capture program is not running.
qcapture_errors When the capture program issues an error message.
qapply_status When the apply program is not running.
qapply_errors Whether the apply program issues an error message.
qapply_exceptions When the apply program logs an exception for row changes that could not be applied because of a conflict or SQL error.
qapply_eelatency When the end-to-end latency of replicated transactions exceeded a set threshold. The default is 60 seconds.

When an alert is triggered, the monitor program sends an email to one or more email addresses that you specify when you enable the program. The alert emails continue hourly until the condition is resolved.

For more detailed information on the monitor program, see Replication Alert Monitor, which covers the non-containerized version of the monitor program. Note that some options are different.

Procedure

  1. On the source system, use a Docker container bash shell to run the bludr-config-source-asnmon.sh script to configure monitoring of the source database.

    You can edit and use the following command:

    /opt/ibm/bludr/scripts/bin/bludr-config-source-asnmon.sh -s source_hostname -p source_dbport -d source_dbname -m y -e email_list -u db_user

    Where:

    • source_hostname is the hostname of the server where the source database is located.
    • source_dbport is the port number that is used for connections to the source database.
    • source_dbname is the source database name.
    • email_list is a list of email addresses where you want monitor alerts for events that occur on the source database to be sent. Separate addresses with commas but no spaces.
    • db_user is your replication user ID.
  2. On the source system, run the bludr-config-target-asnmon.sh script to configure monitoring of the target database.
    /opt/ibm/bludr/scripts/bin/bludr-config-target-asnmon.sh -t target_hostname -p target_dbport -d target_dbname -m y -e email_list -u db_user

    Where:

    • target_hostname is the hostname of the server where the target database is located.
    • target_dbport is the port number that is used for connections to the target database.
    • target_dbname is the target database name.
    • email_list is a list of email addresses where you want monitor alerts for events that occur on the target database to be sent. Separate addresses with a space.
    • db_user is your replication user ID.
    After you run the scripts, the monitor automatically begins running and scanning for changes to alert conditions.
  3. To change the latency threshold or email contact list, use the IBM Data Replication for Availability REST APIs.
    For example, to change the default threshold for the qapply_eelatency alert condition, use the post /dr/v1/health/asnmon/alert/configure/{dbHost}/{dbPort}/{dbName}/{alertMonitorName} API call.

    Figure 1 shows the API calls that are available for asnmon.

    Figure 1. REST API calls for asnmon
    REST API console showing the APIs that are available for the monitor program
  4. To suspend or resume the monitor program or check its state, run the bludr-manage-asnmon.sh script on the source database.

    For example:

    /opt/ibm/bludr/scripts/bin/bludr-manage-asnmon.sh --suspend
    /opt/ibm/bludr/scripts/bin/bludr-manage-asnmon.sh --resume
    /opt/ibm/bludr/scripts/bin/bludr-manage-asnmon.sh --state
    For more details, see bludr-manage-asnmon.sh script.