Tutorial: Configuring Alert Rules

Overview

This section shows how to use TIBCO LiveView™ Desktop to configure two alerts for a data table in the Hello LiveView sample project shipped with TIBCO LiveView. To follow this example, load and run Hello LiveView sample using the Import Samples and Community Content dialog.

Add a New Alert

Hello LiveView has three alerts configured against the ItemsSales table.

  • Low inventory on Item publishes a row in the LVAlerts table when the quantityRemaining field of the ItemsSales table is less than 30.

  • Out of Item publishes a row in the LVAlerts table when the quantityRemaining field of the ItemsSales table is zero.

  • Trim ItemsSales table deletes rows older than five minutes from the ItemsSales table.

Follow these steps to create an alert against the ItemsSales table from LiveView Desktop and publish the alert to the LVAlerts table.

  1. In the LiveView Desktop Tables pane, right-click the ItemsSales table and select Alert Rules.

    This opens the Alert Rules dialog with the ItemsSales table selected.

  2. Click the Add button. This opens the Configure Alert Rule dialog. By default, the Enabled check box is selected, the Severity is set to 3 (Medium), and the Immediately radio button is selected for the Execute actions field.

    1. Set the Name field to Running low on toys!.

    2. Set the Message field to Running low on $Item in $category. The expressions $Item and $category perform text substitutions when the alert rule is executed and return the value of the Item and category fields from the row of the ItemsSales table that meets the alert conditions.

    3. Enter the query predicate category='toy' and quantityRemaining < 40 in the Condition field.

    4. Select the check box for After executing actions, suppress subsequent execution for and enter 10 for the seconds field.

      The top part of the window now looks like the following:

    5. In the Actions pane, click the Add button and select Publish Alert. This opens the Alert Action window.

    6. By default, the Alert key radio button is set to Generated, the Message field is set to Use default rule message, and the Recipient field is set to asterisk (*). Click OK to save the action. The Actions pane now looks like this:

      Notice the Enabled check box is selected by default. As soon as you click OK, the Low Inventory alert is saved and enabled.

  3. Click OK. The dialog box Validating Rule on the Server appears momentarily before you return to the Alert Rules window. LiveView Server validates alert rules before saving them. If the rule is not correctly configured, you are returned to the Configure Alert Rule window.

    The alert rule you just created is now visible in the window.

  4. Click Close. This returns you to LiveView Desktop.

  5. Double-click LVAlerts in the Tables pane of LiveView Desktop. This opens the LVAlerts table in a tab. You can see that the alert you just created is populating this table.

    Since published alerts are stored in a LiveView Table, the table is populated during a LiveView Server session. Every new LiveView Server session starts populating the table.

Add a Delete Rows Alert

You can also delete rows with an alert action. For example, you may want to control the number of rows published to the LVAlerts table. This example deletes all the rows of the LVAlerts table when it gets larger than 30 rows.

Warning

The delete rows action works on the running LiveView Server instance. Deleted rows cannot be recovered, so use this action with care.

  1. Click the system tables icon () in the tables view to show the system tables.

  2. Right-click the LiveViewStatistics table and select Alert Rules.

  3. Click Add.

  4. Configure the alert rule as shown here:

    The LiveViewStatistics table is a system table that display information about the LiveView Server instance. The RecordCount field shows the number of rows in each LiveView table. Note that the alert will fire as the alert conditions turn to true; if your LVAlerts table already has more than 30 rows the alert will not fire.

  5. Click the Add button and select Delete Rows. The Alert Action dialog opens.

  6. In the Table field, select LVAlerts.

  7. In the query field, enter LastModified < now()-seconds(30).

  8. Click OK.