Enable SMTP email alerts
OpsCenter can send alerts to multiple email addresses.
To enable email alerts, edit the CONFIG_LOCATION.event-plugins/email.conf file and provide valid SMTP server host and port information.
For information about the CONFIG_LOCATION, see Default file locations for package installations.
The email configuration file can have any name provided the file has the .conf file extension, contains the valid event plugin identifier [email], and resides in the event-plugins directory location.
All configuration files are loaded, so you must differentiate the file names such as email1.conf and email2.conf.
Multiple instances of the email.conf file results in multiple instances of an event plugin.
Multiple plugin instances facilitate flexibility when setting up alerts to different email recipients for development and production clusters.
All OpsCenter event plugins support multiple configurations files and subsequent plugin instances.
-
Make sure that you have valid SMTP mail accounts to send and receive alerts.
-
On the OpsCenter daemon host, edit the
email.conffile. -
Set
enabledto1. -
Provide valid values for your SMTP
host,port(25, or 465 if using SSL),user, andpassword. -
For secure communications, enable Secure Sockets Layer (SSL) or Transport Layer Security (TLS) protocol on your system. Typically, SSL is required.
-
Provide valid values for the
to_addrandfrom_addremail addresses. Theto_addrvalue is the account that will receive alerts.To send alerts to multiple email addresses, enter the email addresses as a comma-delimited list.
-
Set the specific levels of alerts to send. The default is to listen for all levels.
-
Specify the clusters for which the email alert config will run. The default is to call the alert for events on all clusters.
-
Customize the template for the email subject and message body as desired. Available options are described in the config file comments.
-
Save the configuration file and restart the OpsCenter daemon.
Example email.conf
The following email.conf example configures email alerts to multiple recipients for warnings and errors on all clusters and SSL enabled:
[email]
# set to 1 to enable email
enabled=1
# levels can be comma-delimited list of any of the following:
# DEBUG,INFO,WARN,ERROR,CRITICAL,ALERT
# If left empty, will listen for all levels
levels=WARN,ERROR
# clusters is a comma-delimited list of cluster names for which
# this alert config will be eligible to run.
# If left empty, this alert will be called for events on all clusters
clusters=
smtp_host=smtp.gmail.com
smtp_port=465
smtp_user=mercury@gmail.com
smtp_pass=*********
smtp_use_ssl=1
smtp_use_tls=0
smtp_retries=1
smtp_timeout=5
to_addr=dse_admin@acme.com,devOps@acme.com,opsc_admin@acme.com
from_addr=mercury@gmail.com
# Customizable templates for subject and body. The key specified in {}'s must map to the items provided in json map at the end of
# the emails. For example, some available keys are:
# node, cluster, datetime, level_str, message, target_node, event_source, success, api_source_ip, user, source_node
# more advanced formatting options explained here: https://docs.python.org/2/library/string.html#formatspec
subject=[{level_str}] OpsCenter Event on {cluster} - {message}
template=Message: {message}
Time: {datetime}
Level: {level_str}
Cluster: {cluster}
Node: {node}
User: {user}
Example template with variables
Given the following custom email template example:
template=Hey support staff! Wanted to let you know that {cluster} says, {message} This is
{level_str} level, and you may want to check out https://support.lan/opscenter_alerts_guide for further information.
The resulting email alert would look similar to the following:
