Send external alert notifications
Alerts are disabled by default and must be explicitly configured, including alert rules and notification mechanisms.
Once enabled you can monitor alerts in the DSE OpsCenter UI and externally. On the DSE OpsCenter Event Log page, in the Activities section, you can find a list of events and alerts that is continuously updated as events are captured and alerts are triggered. For external monitoring, you can send alert notifications to an email address, a URL (including a Slack POST URL integration), or an enterprise reporting system using SNMP traps.
Alerts are triggered by events initiated from the OpsCenter API or UI only; they aren’t triggered by events initiated from the command line.
For example, running the nodetool move operation on the command line doesn’t trigger an alert, but the same operation initiated from the OpsCenter UI (Nodes > List View > Other Actions > Move) does trigger an alert.
Optionally, you can configure OpsCenter to send alerts for selected levels of events or specific clusters.
Alert message fields
All alerts contain information about each captured event.
| Field | Description | Example |
|---|---|---|
|
IP address that originally sent the request through an API call. |
67.169.50.240 |
|
Destination of a STREAMING action. |
10.1.1.11 |
|
Component that caused the event. |
OpsCenter (i.e., restart, start) |
|
OpsCenter user that caused the event. |
opscenter_user |
|
Normal timestamp for the event. |
1311025650414527 |
|
Type of event. |
20 |
|
Customizable subject line of the email alert. |
|
|
Description of the event. |
Garbage Collecting node 10.1.1.13 |
|
Numerical code for the log level. |
1 |
|
Node where the event originated. |
10.1.1.13 |
|
Name of the cluster where the event originated. |
DSEProdCluster |
|
Logging level of the event. |
INFO |
|
Keyspace table (column family) of the metric used for event monitoring. |
test_keyspace.test_table |
|
Datacenter to monitor for events. Setting this field limits event monitoring to the nodes in the specified datacenter. |
dc1 |
|
The storage tier for event monitoring.
A higher number generally indicates a slower disk.
The |
1 |
|
Partition to monitor for events. |
/dev/disk3s5 |
|
Disk to monitor for events. |
disk3 |
|
Applies to the cross datacenter latency metric. Specifies the source datacenter that monitors and reports the metric value for events. |
dc1 |
SNMP traps and the OpsCenter MIB
The Simple Network Management Protocol (SNMP) is a standardized framework for infrastructure monitoring. Organizations use SNMP to monitor the status of their network infrastructure by sending SNMP traps to an enterprise monitoring system, such as those provided by Nagios. Traps send an alert from a monitored device to the SNMP master (such as a Nagios application).
OpsCenter supports SNMP traps (not full SNMP agent) for integration with an agentless monitoring solution.
The OpsCenter SNMP implementation supports sending traps over SNMPv1, SNMPv2c, and SNMPv3 protocols.
The device being monitored is opscenterd, which is the OpsCenter daemon.
SNMP requires importing the OpsCenter Management Information Base (MIB). The OpsCenter MIB is SMIv2-compliant. The fields identified in the trap when using the OpsCenter MIB include the alert message fields and an additional time field.
| Field | Description |
|---|---|
opscAlertLevel |
The ID of the severity level for an alert. |
opscAlertLevelStr |
The string of the severity level for an alert. |
opscAlertMessage |
The description of the event that triggered the alert. |
opscAlertAction |
The numerical type of event that triggered the alert. |
opscAlertCluster |
The name of the cluster on which the event was triggered. |
opscAlertEventSrc |
Alert Event Cluster. The name of the node on which the event was triggered. |
opscAlertSrcNode |
Alert Source Node. The IP of the node on which the event was triggered. |
opscAlertTargNode |
Alert target node. The destination of a STREAMING action. |
opscAlertEpochTime |
The time of event occurrence as a Unix Epoch timestamp. |
opscAlertStrTime |
Alert String Time. The date and time that the event occurred. Timestamp in a human-readable format. |
opscAlertAPISrcIP |
Alert API Source IP. The IP that originally sent the request. |
opscAlertUser |
The OpsCenter user that caused the event. |
Enable SNMP alerts
In DSE OpsCenter, SNMP alerts are configured in an SNMP event plugin configuration file that is stored in the event-plugins subdirectory of your OpsCenter configuration file directory.
The file path depends on your installation type:
-
Package installations:
/etc/opscenter/event-plugins/snmp.conf -
Tarball installations:
INSTALL_DIRECTORY/conf/event-plugins/snmp.conf
The SNMP configuration file can have any name, but it must have the .conf file extension.
If you have multiple SNMP configuration files, each file must have a unique name (snmp1.conf, snmp2.conf) because OpsCenter loads all event plugin configuration files.
Multiple instances of the snmp.conf file results in multiple instances of an event plugin.
Multiple plugin instances facilitate flexibility when setting up alerts to SNMP targets for development and production clusters.
All OpsCenter event plugins support multiple configurations files and subsequent plugin instances.
An SNMP configuration file must contain a valid event plugin identifier ([snmp]).
-
In your OpsCenter installation’s
/event-pluginsdirectory, find the OpsCenter MIB (DATASTAX-OPSCALERT-MIB.txt), and then import the MIB into your preferred infrastructure monitoring application.The MIB is a formal specification of the fields within OpsCenter traps. Installing the MIB is mandatory for using the SNMP traps effectively; without doing so, the field titles will not render properly. Refer to the installation and configuration instructions provided by the application vendor.
-
Edit your OpsCenter
snmp.conffile. -
Enable the SNMP plugin for sending traps:
[snmp] enabled=1 -
Optional: Manually set the engine ID that uniquely identifies the SNMP engine.
By default,
engine_idis commented out, and OpsCenter creates a local engine ID based on the local IP address.If you prefer to manually set the
engine_id, uncommentengine_id, and then change the last four octets (01:02:03:04) of theengine_idstring to a unique octet string for each OpsCenter installation. For example:[snmp] ... engine_id=80:00:00:00:05:50:60:70:80 -
For the
target_ip, enter the IPv4 address of the SNMP receiver. -
Use the default configuration values or modify them as needed.
The following table describes the SNMP configuration options:
SNMP configuration options Description enabledEnables (1) or disables (0) the SNMP plugin instance. Default: 0 (disabled).
levelsComma-delimited list of event severities for which the SNMP plugin should fire. If not specified, all levels are listened for by default. Available options:
-
DEBUG (lowest severity, most verbose)
-
INFO
-
WARN
-
ERROR
-
CRITICAL
-
ALERT (highest severity, least verbose)
clustersComma-delimited list of cluster names for which the plugin should fire. If no cluster is specified, the alert is called for events on all clusters by default.
engine_idSNMP engine ID that uniquely identifies the SNMP engine. The last four octets of the ID (01:02:03:04 by default) must be unique between multiple OpsCenter installations. Default: 80:00:00:00:05:01:02:03:04 for the Octets default format scheme. SNMP version is not relevant to this setting. For more details on SNMP management, see RFC3411.
Format Schemes
The fifth octet in the
engine_iddetermines the format scheme that specifies the nature of the remaining trailing octets. Available format schemes:-
01: IPv4 Address scheme -
02: IPv6 Address scheme -
03: MAC Address scheme -
04: Text Address scheme -
05: Octets scheme (default)
target_ipIPv4 address of the SNMP trap target. Default:
127.0.0.1Only IPv4 is supported.
target_portListening port on the SNMP manager to receive SNMP traps. Default: 162.
use_snmpv3When set to
1, this SNMP plugin instance will use the SNMPv3 configuration options (username,auth_protocol,auth_key,privacy_protocol,privacy_key) with SNMP authentication. When set to0, this SNMP plugin instance will use thecommunity_namewith SNMPv1/2c authentication. Default:0(uses SNMPv1/2c).community_nameSNMPv1/2c-specific configuration. Community name for authentication with the SNMP trap target. Default:
public.userUsername for SNMPv3 authentication. Default:
opscusername.auth_protocolSNMPv3 authentication hashing algorithm. Specifies the authentication protocol to use with SNMPv3. Available options:
-
SHA(default) -
MD5 -
NoAuth
auth_keySNMPv3 authentication key. Authentication key as configured for your OpsCenter installation in your monitoring software. Default:
auth1key.privacy_protocolSNMPv3 privacy protocol. Available standards-compliant options:
-
AES(default) -
DES -
NoPriv
Available Extended Security Options (ESO) from the SNMP Research Group:
-
3DES -
AES192 -
AES256
privacy_keyPrivacy key as configured for your OpsCenter install in your monitoring software. Default:
privkey1. -
Enable SMTP email alerts
DSE OpsCenter can send alerts to email addresses.
In OpsCenter, SMTP email alerts are configured in an email event plugin configuration file that is stored in the event-plugins subdirectory of your OpsCenter configuration file directory.
The file path depends on your installation type:
-
Package installations:
/etc/opscenter/event-plugins/email.conf -
Tarball installations:
INSTALL_DIRECTORY/conf/event-plugins/email.conf
The email configuration file can have any name, but it must have the .conf file extension.
If you have multiple email configuration files, each file must have a unique name (email1.conf, email2.conf) because OpsCenter loads all event plugin configuration files.
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.
An email configuration file must contain a valid event plugin identifier ([email]) and SMTP server configuration.
-
External to OpsCenter, prepare valid SMTP mail accounts to send and receive alerts.
-
On the OpsCenter daemon host, edit the
email.conffile. -
Enable the email plugin:
[email] enabled=1 -
Define the SMTP server configuration, including the host, port (25, or 465 if using SSL), user, and password:
smtp_host=smtp.gmail.com smtp_port=465 smtp_user=mercury@gmail.com smtp_pass=********* -
For secure communications, enable Secure Sockets Layer (SSL) or Transport Layer Security (TLS) protocol on your system.
Typically, SSL is required.
smtp_use_ssl=1 smtp_use_tls=0 -
Configure the sender (
from_addr) and recipients (to_addr) for the alert emails.To send alerts to multiple email addresses, enter the email addresses as a comma-delimited list.
to_addr=dse_admin@acme.com,devOps@acme.com,opsc_admin@acme.com from_addr=mercury@gmail.com -
Customize the template for the email subject and body.
Available options are described in the comments in the
email.conffile.Variables are supported. For example, the following
templateexample uses variables for the cluster name, event message, and event level: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.An email produced from the template populates the values for the specific triggering event. For example:
Hey support staff! Wanted to let you know that TestCluster says, OpsCenter shutting down. This is WARN level, and you may want to check out https://support.lan/opscenter_alerts_guide for further information. -
Optional: Set other configuration values as desired.
For example:
-
alert_instance_id: Set toTrueif you want to include the OpsCenter instance ID in the notification message. -
levels: Specify the the event levels that trigger an alert email. By default, all event levels are included. -
clusters: Specify the clusters for which the email alert config will run. By default, all clusters are included.
See the comments included in your installation’s
email.conffile for guidance on other configuration options.The following
email.confexample sends email alerts with SSL enabled to multiple recipients forWARNandERRORlevel events on all clusters:[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 # When set to `True`, OpsCenter includes its instance ID in the notification. #alert_instance_id=False # 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} -
-
Save the
email.conffile. -
Test the event notifications to verify that the alerts are sent as expected.
Post alerts to a URL
Use the POST URL event plugin to send OpsCenter alert notifications to a URL that is capable of receiving and processing data from POST requests.
For example, a PHP script containing print_r($_POST); echoes the received POST request, such as the following:
POST / HTTP/1.0
Host: localhost
User-Agent: Twisted PageGetter
Content-Length: 184
Content-type: application/x-www-form-urlencoded
connection: close
target_node=None&event_source=OpsCenter&success=None&level=1&level_str=INFO&api_source_ip=None&user=None&time=1400098707681966&action=18&message=OpsCenter+starting+up.&source_node=None
In OpsCenter, POST URL alerts are configured in a POST URL event plugin configuration file that is stored in the event-plugins subdirectory of your OpsCenter configuration file directory.
The file path depends on your installation type:
-
Package installations:
/etc/opscenter/event-plugins/posturl.conf -
Tarball installations:
INSTALL_DIRECTORY/conf/event-plugins/posturl.conf
The POST URL configuration file can have any name, but it must have the .conf file extension.
If you have multiple POST URL configuration files, each file must have a unique name (posturl1.conf, posturl2.conf) because OpsCenter loads all event plugin configuration files.
Multiple instances of the posturl.conf file results in multiple instances of an event plugin.
Multiple plugin instances facilitate flexibility when setting up alerts to different endpoints for development and production clusters.
All OpsCenter event plugins support multiple configurations files and subsequent plugin instances.
A POST URL configuration file must contain a valid event plugin identifier ([posturl]) and the URL for the incoming webhook.
|
OpsCenter can post alerts over HTTP or HTTPS.
Set your preferred protocol by using the |
-
External to OpsCenter, prepare your web server and posting script to receive alerts.
-
If your OpsCenter host is behind a proxy, configure the HTTP proxy settings in the
opscenterd.conffile:[http_proxy_settings] proxy_url = http://your_proxy:port proxy_username = your_proxy_username proxy_password = your_proxy_passwordFor more information about
opscenterd.confand the HTTP proxy settings, see OpsCenter daemon configuration properties (opscenterd.conf). -
On the OpsCenter daemon host, edit the
posturl.conffile. -
Enable the POST URL plugin:
[posturl] enabled=1 -
Set the
urlfield to a valid path to your posting script. -
To use the
curlcommand for alert notification API calls, setenable_curltoTrue. -
Set the
usernameandpasswordfor HTTP Basic authentication. -
Set
post_typeto the POST request content type.Supported content types include
form(default),json, andtemplate. -
Configure the request body for the POST URL using the format
fields=KEY=VALUE.By default, the request body contains the alert message fields and the cluster name, if applicable. To customize the field format and included fields, see the key-value pair examples and explanation in the
posturl.conffile.The following example adds a static custom field by using the
fieldsprefix. You must specify all of the fields to include.fields=message={message} message_type=CRITICALThis following examples show field configurations for each content type. Each example example posts the event message and cluster name.
- Form data example
-
FORM DATA: array ( 'event-msg' => 'OpsCenter starting up.', 'mixedKey' => 'cluster-C1', 'textKey' => 'value', ) - JSON data example
-
JSON DATA: {{ "event-msg": "OpsCenter starting up.", "mixedKey": "cluster:C1", "textKey": "value" }} - Template data example
-
TEMPLATE DATA: {{ "event-msg": "OpsCenter starting up.", "mixedKey": "cluster:C1", "textKey": "value" }}
-
Optional: Set other configuration values as desired.
For example:
-
alert_instance_id: Set toTrueif you want to include the OpsCenter instance ID in the notification message. -
levels: Specify the the event levels that trigger an alert. By default, all event levels are included. -
clusters: Specify the clusters for which the POST URL alert config will run. By default, all clusters are included. -
connection_timeout: Set the timeout for connecting to the web server.
See the comments included in your installation’s
posturl.conffile for guidance on other configuration options.The following
posturl.confexample sends alerts forCRITICALandALERTlevel events on all clusters with no authentication and no modification to the default message contents:[posturl] enabled=1 # levels can be a comma-delimited list of any of the following: # DEBUG,INFO,WARN,ERROR,CRITICAL,ALERT # If left empty, will listen for all levels levels=CRITICAL,ALERT # 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= # the URL to send a HTTP POST to url=https://host/path/to/script # Set a username for basic HTTP authorization #username=foo # Set a password for basic HTTP authorization #password=bar # Set the type of posted data. Available options are `form`, `json`, and `template`. post_type=form # When set to `True`, {product-short} includes its instance ID in the notification. #alert_instance_id=False # Fields specified here will override the default event data fields. # # They must be formatted as key-value pair, with key and value separated by # an equals (=). Each pair after the first must be on its own line, # indented beyond the first line # # You may use tokens found within the default event data for or in # values. For example, some available keys are: # cluster, time, level_str, message, target_node, event_source, success, api_source_ip, user, source_node # Keys must be encapsulated in {brackets}. # #fields=textKey=value # mixedKey=cluster-{cluster} # event-msg={message} -
-
Save the
posturl.conffile. -
Test the event notifications to verify that the alerts are sent as expected.
Post alerts to a Slack channel
Use the POST URL event plugin to send OpsCenter alert notifications to Slack channels.
In OpsCenter, Slack alerts are configured in a Slack POST URL event plugin configuration file that is stored in the event-plugins subdirectory of your OpsCenter configuration file directory.
The file path depends on your installation type:
-
Package installations:
/etc/opscenter/event-plugins/slack_posturl.conf -
Tarball installations:
INSTALL_DIRECTORY/conf/event-plugins/slack_posturl.conf
The Slack configuration file can have any name, but it must have the .conf file extension.
If you have multiple Slack configuration files, each file must have a unique name (slack_posturl1.conf, slack_posturl2.conf) because OpsCenter loads all event plugin configuration files.
Multiple instances of the slack_posturl.conf file results in multiple instances of an event plugin.
Multiple plugin instances facilitate flexibility when setting up alerts to different Slack channels for development and production clusters.
All OpsCenter event plugins support multiple configurations files and subsequent plugin instances.
A Slack configuration file must contain a valid event plugin identifier ([posturl]) and the URL for the incoming webhook.
-
External to OpsCenter, prepare an incoming webhook integration for Slack.
-
In your OpsCenter
/event-plugins/directory, create aslack_posturl.conffile. -
Paste the following template into your
slack_posturl.conffile.The contents of
slack_posturl.confis similar to theposturl.conffile for other HTTP POST alerts. However, for Slack, thepost_typemust betemplate, and the messagetemplatefield must be configured for compatibility with Slack, as shown in the following example.[posturl] 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= # 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= # the URL to send an HTTP POST to url=https://hooks.slack.com/services/your/webhook/url # Set a username for basic HTTP authorization #username=foo # Set a password for basic HTTP authorization #password=bar # Override any headers with comma seperated, key=value pairs # headers=token=abc123, content-type=application/json # The number of seconds before a connection to url or proxy_url # will be aborted due to a timeout. Defaults to 5 seconds. connection_timeout=5 # The number of seconds to wait after sending the POST request before # the request will be aborted due to a timeout. Defaults to the same # value as connection_timeout if not set. #request_timeout=5 # Set the type of posted data. Available options are 'json' or 'form' post_type=template # When set to `True`, OpsCenter includes its instance ID in the notification. #alert_instance_id=False # Fields specified here will override the default event data fields. # # They must be formatted as key-value pair, with key and value separated by # an equals (=). Each pair after the first must be on its own line, # indented beyond the first line # # You may use tokens found within the default event data for or in # values. For example, some available keys are: # cluster, time, level_str, message, target_node, event_source, success, api_source_ip, user, source_node # Keys must be encapsulated in {brackets}. # #fields=textKey=value # mixedKey=cluster-{cluster} # event-msg={message} # Customizable templates for http post data. 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 Each line # beyond the first must be indented. Use with post_type=template, and content-type and other headers must be manually # assigned. # template={{ # "messages":[ # {{ # "type": "link", # "message": "Cluster {cluster} failure - {message}" # "href": "http://opscenter1" # }} # ]}} # Slack accepts messages in specific format. Following template can be used to send messages to slack webhook. # One of the message format accepted by slack: # { # "blocks": [ # { # "type": "section", # "text": { # "type": "mrkdwn", # "text": "This is a message which actually sent to webhook and this must be string" # } # } # ] # } # More messaging formats are explained on https://api.slack.com/messaging/composing # Some available keys are: # node, cluster, datetime, level_str, message, target_node, event_source, success, api_source_ip, user, source_node. # Use with post_type=template, and content-type and other headers must be manually assigned. # Uncomment below template for sending messages over slack webhook template={{ "blocks": [ {{ "type": "section", "text": {{ "type": "mrkdwn", "text" : "cluster: {cluster}, level: {level}, event_source: {event_source}, message: {message}, target_node: {target_node}, api_source_ip: {api_source_ip}, success: {success}, source_node: {source_node}, action: {action}, time: {time}, level_str: {level_str}, user: {user}" }} }} ]}} -
Replace the example
urlvalue with your actual Slack incoming webhook URL. -
Save the
slack_posturl.conffile. -
Test the event notifications to verify that the alerts are sent as expected.
Test event notifications
In the Manage Alert Rules dialog, click Test to verify that your email or POST URL alert configuration is working correctly.
Alternatively, you can use a script to test your event notification configuration. The following example uses a PHP script with the POST URL event plugin to post events to a `/tmp/events`file on the web server host:
-
Create a script file named
postOPSCevents.phpwith the following contents:<?php file_put_contents( '/tmp/events', print_r($_POST,true), FILE_APPEND ); ?> -
Deploy the script.
You might need to restart the web server.
-
In the OpsCenter UI, run a logged event, such as an OpsCenter restart or garbage collection from Dashboard > Cluster > List View.
Check your notification target to verify that the event message was received. If it isn’t received at the target location, check the following:
-
The test event was at a level tracked by the alert configuration. For example, if your configuration tracks
WARNand higher events, but your triggered event was aDEBUGevent, no notification is produced. -
For this POST URL example, check the web server logs and ensure that the script is correctly deployed and accessible.
-
Check whether the event was emitted but not passed on to the final notification target. The following example contains an event that could be posted to
/tmp/eventsin this test scenario:Array ( [api_source_ip ] => 67.169.50.240 [target_node ] => None [event_source ] => OpsCenter [user ] => None [ time ] => 1311025598851602 [action ] => 20 [message ] => Garbage Collecting node 50.1.1.24 [level ] => 1 [source_node ] => 50.1.1.24 [level_str ] => INFO )
-