Configuring Alerts

To enable alert generation, HERO uses a built-in alerting framework that can be customized with different logics. For example, you can decide that an alert is generated when one of the environments is in error or warning status.

The customization is managed by a JavaScript file in which your can develop the logic for triggering an alert, and the action that the alert must run like, for example, sending an email, or executing a command on the machine that generated the alert.

 

To configure alerts, run the following steps:

 

  1. To enable alerts by email, add the following settings to the dashboard.properties file located in the  <BUILD_DIR>\CONFIGURATION\HERO directory:

 

 

alertSmtpEmail

The sender email account [Example: username@gmail.com] .

alertSmtpPassword

The password associated to the sender email account.

smtpPasswordEncrypted

Set encryption for the alertSmtpPassword. Can be "true" or "false". If smtp is configured through HERO installation script, the value of smtpPasswordEncrypted parameter is set to "true" (default value).  If you configure smtp manually, you must set smtpPasswordEncrypted to "false".

alertSmtpServer

Fully qualified hostname of the SMTP Server that will be used by HERO to send alerts by email [Example: smtp.gmail.com]

alertSmtpPort

The port of the SMTP mail server.

smtpTlsEnabled

Set the TLS enablement for smtp client while establishing a connection from HERO. Can be "true" or "false". Default value is "true".

 

 

  1. You can implement the alert logic by properly setting the file Alert.js located in the <BUILD_DIR>\CONFIGURATION\HERO\Alerting. The file is composed of three sections:

Alerts

doStandardAlerts function

doAlerts function

 

The Alerts section is a list of objects that define different kind of alerts and is used by the doStandardAlert function.

The doStandardAlert function checks the alerts. When it finds the alert matching with the just happened event, it returns the alert and the framework runs the action that has been defined for that alert.

 

Alerts structure:

 

[

{

        "component": "ENV",          //Only works with ENV,

        "state": "ERROR",   //The trigger state, this can be: ERROR, WARNING, or SUCCESS

        "action": "SEND_EMAIL",    //Only works with SEND_EMAIL

        "subject": "Environment in error",  //the email subject

        "message": "message1",     //the email message

        "targets": user1@email.com;user2@email.com      // email addresses

},

{

        "component": "ENV",

        "state": "WARNING",

        "action": "SEND_EMAIL",

        "subject": "Environment in warning",

        "message": "message2",

        "targets": "user3@email.com"

             

},

{.

 .

}

]

 

For each alert, the message element contains specific variables that are replaced automatically by the system. For example, by setting:

 

 "message": "The environment %ENV_NAME% type %ENV_TYPE% is in error"

 

The target user will receive an email containing the name and type of the environment in error.

 

The doStandardAlerts function has the following parameters:

componentType: the type of the component

oldStatus: the previous status of the component

newStatus: the current status of the component

Variables: an object containing a list of useful information for the alerts

 

  1. You can optionally configure Alerts in an advanced way, by using the doAlerts function. The doAlerts function has the same parameters of the doStandardAlerts function. However, it is not used to return alert objects but to execute the alerts directly from the .js file. The doAlerts function exposes two actions:

 AlertManager.runAction(command, machineId) which runs the shell command on the machine identified by the machineId

 AlertManager.sendEmail(subject, targets, message) which sends an email to all the targets defined by its parameters, where:

targets is a string with all the email addresses separated by semicolon: "user1@email.com; user2@gmail.com"

subject is the subject of the email that will be sent

message is the email content and can be written in html

 

Leave feedback