Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents


Alerts define metrics for watching database data and if any metric exceeds its limit then alert is activated and further operation can be executed.

Metrics are configured - the SQL query for getting count of items and limit for checking.

Examples of alerts (also with follow-up operations):

  • when count of failed messages for last 10 minutes exceeds 5 then send email to administrators
  • when count of messages which wait for response from external system for more then 5 minutes exceeds 10 then send email to administrators

Alerts checking is scheduled operation that is determined by alerts.repeatTime configuration parameter - checking is executed every 5 minutes by default.

Alerts configuration

There are the following configuration possibilites:

  • property files (default option)
  • JMX

Properties alerts configuration

There the following property files:

  • alertsCore.cfg (in sc-core module)
  • alerts.cfg (in sc-web-admin module)
  • alerts0.cfg (in specific project module)

 

Tip

Configurations in next files override same configurations in previous files.

 

Property file configuration format and example:

Code Block
###############################################################################
#  Alerts core configuration file.
#
#   There the following property names:
#   - alerts.N.id: unique alert identification (if not defined then order number (=N) is used instead)
#   - alerts.N.limit: limit that must be exceeded to activate alert
#   - alerts.N.sql: SQL query that returns count of items for comparison with limit value
#   - [alerts.N.enabled]: if specified alert is enabled or disabled; enabled is by default
#   - [alerts.N.mail.subject]: notification (email, sms) subject; can be used Java Formatter placeholders (%s = alert ID)
#   - [alerts.N.mail.body]: notification (email, sms) body; can be used Java Formatter placeholders (%d = actual count, %d = limit)
#
###############################################################################

# checks if there is any waiting message that exceeds time limit for timeout
alerts.900.id=WAITING_MSG_ALERT
alerts.900.limit=0
alerts.900.sql=SELECT COUNT(*) FROM message WHERE state = 'WAITING_FOR_RES' AND last_update_timestamp < (current_timestamp - interval '3600 seconds')


Info

Alerts from core module start from 900, project-specific alerts start from 0. This order number is only for better description, doesn't have influence to behaviour.


Warning

SQL queries must be defined for specific database that is use.

JMX alerts configuration

JMX configuration allows change alert limits and enable/disable selected alerts.

Image Added

Spring configuration

Basic configuration follows:

  • inits alerts configuration from property files
  • inits service for executing SQL queries and checking limits
  • inits default listener that sends email to administrators for each alert that will be activated

sp_camel_services.xml:

Code Block
    <bean id="alertsConfiguration" class="org.openhubframework.openhub.core.alerts.AlertsPropertiesConfiguration">
        <constructor-arg ref="confProperties"/>
    </bean>
    <bean id="alertsCheckingService" class="org.openhubframework.openhub.core.alerts.AlertsCheckingServiceDbImpl"/>
    <bean class="org.openhubframework.openhub.core.alerts.EmailAlertListenerSupport"/>

spring-ws-servlet.xml - adding property files:

Code Block
    <bean id="confProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="ignoreResourceNotFound" value="true"/>
        <property name="locations">
            <list>
                <value>classpath:applicationCore.cfg</value>
				...
                <value>classpath:alertsCore.cfg</value>
                <value>classpath:alerts.cfg</value>
                <value>classpath:alerts0.cfg</value>
            </list>
        </property>
    </bean>

Reaction to alert activation

There are listeners org.openhubframework.openhub.spi.alerts.AlertListener which are called when specified alert is activated. 

There is default org.openhubframework.openhub.core.alerts.EmailAlertListenerSupport implementation that  sends email notifications to admin emails.

If you want to implement more actions and you can implement AlertListener or extends default implementation EmailAlertListenerSupport.

Alerts define metrics for watching database data and if any metric exceeds its limit then alert is activated and further operation can be executed.

...

Alerts checking is scheduled operation that is determined by alerts.repeatTime configuration parameter - checking is executed every 5 minutes by default.

Alerts configuration

There are the following configuration possibilites:

  • property files (default option)
  • JMX

Properties alerts configuration

There the following property files:

...

Warning

SQL queries must be defined for specific database that is use.

JMX alerts configuration

JMX configuration allows change alert limits and enable/disable selected alerts.

Spring configuration

Basic configuration follows:

...

Code Block
    <bean id="confProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="ignoreResourceNotFound" value="true"/>
        <property name="locations">
            <list>
                <value>classpath:applicationCore.cfg</value>
				...
                <value>classpath:alertsCore.cfg</value>
                <value>classpath:alerts.cfg</value>
                <value>classpath:alerts0.cfg</value>
            </list>
        </property>
    </bean>

Reaction to alert activation

There are listeners org.openhubframework.openhub.spi.alerts.AlertListener which are called when specified alert is activated. 

...