Sending alerts from applications
See also Sending alerts about servers and applications.
Applications can send alerts via email, Microsoft Teams, Slack, or the web UI. To send alerts, generate a stream of type AlertEvent and use it as the input for a subscription (a kind of target).
The syntax for subscriptions is:
CREATE SUBSCRIPTION name USING [ EmailAdapter | SlackAlertAdapter | TeamsAlertAdapter | WebAlertAdapter] (<properties>) INPUT FROM <stream of type Global.AlertEvent>
Alerts generated by the WebAlertAdapter appear only in the alert counter in the upper right corner of some pages of the Striim web UI. This delivery method is suitable mostly for development purposes since the counter may be reset before the user sees an alert. You do not need to specify any properties for this adapter.
Email Adapter properties
The EmailAdapter properties are:
property | type | default value | notes |
---|---|---|---|
bccEmailList | java.lang.String | "bcc" address(es) for the alerts (separate addresses with commas) or | |
ccEmailList | java.lang.String | "cc" address(es) for the alerts (separate addresses with commas) or | |
contentType | java.lang.String | text/html; charset=utf-8 | the other supported value is |
emailList | java.lang.String | "to" address(es) for the alerts (separate addresses with commas) or | |
senderEmail | java.lang.String | "from" address for the alerts (if this is not a valid, monitored mailbox, the alert text should instruct the user not to reply) or | |
smtp_auth | Boolean | True | set to False if the SMTP server does not require authentication, in which case leave smtpUser and stmpPassword blank |
smtpPassword | com.webaction. security.Password | password for the SMTP account (see Encrypted passwords); leave blank if smtpUser is not specified | |
smtpPropertiesName | string | a Striim property set containing SMTP server properties (any properties specified in the EmailAdapter override those in the property set) | |
smtpUrl | string |
| |
smtpUser | string | user name of the account on the SMTP server; leave blank if authentication is not required | |
starttls_enable | Boolean | False | set to True if required by the SMTP server |
subject | string | subject line for the alerts | |
threadCount | int | 4 | number of threads on the Striim server to be used to send alerts |
userids | java.lang.String | Striim user(s) to receive alerts at the email address(es) specified in their Striim account properties or |
The following would create a property set smtpprop
which could then be specified as the value for smtpPropertiesName:
CREATE PROPERTYSET smtpprop ( SMTPUSER:'xx@example.com', SmtpPassword:'secret', smtpurl:'smtp.example.com', threadCount:"5", senderEmail:"alertsender@example.com" );
Slack Alert Adapter properties
The SlackAlertAdapter properties are:
property | description |
---|---|
Channel Name | Name of the channel where the Slack alert adapter posts alert messages. |
OAuth Token | Slack bot user OAuth authorization token for the Slack workspace. |
See Configure Slack to receive alerts from Striim for more about these properties.
Teams Alert Adapter properties
The TeamsAlertAdapter properties are:
property | description |
---|---|
Channel URL | A URL that specifies a channel in Microsoft Teams. |
Client ID | A unique identifier for a specific Microsoft Teams application. |
Client Secret | A secret key that authenticates the client. |
Refresh Token | A unique token that enables the generation of a new Client Secret/Refresh Token pair. |
See Configure Teams to receive alerts from Striim for more about these properties.
AlertEvent fields
The input stream for a subscription must use the AlertEvent type. Its fields are:
field | type | notes |
---|---|---|
name | string | reserved |
keyVal | string | For any given keyVal, an alert will be sent on for the first event with a flag value of |
severity | string | valid values: |
flag | string | valid values: |
message | string | Specify the text of the alert, typically passed from a log entry. When the target is Microsoft teams, the message must not contain newlines. |
The following sample code (based on PosApp) generates both types of alerts:
CREATE STREAM AlertStream OF Global.AlertEvent; CREATE CQ GenerateAlerts INSERT INTO AlertStream SELECT n.CompanyName, m.MerchantId, CASE WHEN m.Status = 'OK' THEN 'info' ELSE 'warning' END, CASE WHEN m.Status = 'OK' THEN 'cancel' ELSE 'raise' END, CASE WHEN m.Status = 'OK' THEN 'Merchant ' + n.companyName + ' count of ' + m.count + ' is back between ' + ROUND_DOUBLE(m.lowerLimit,0) + ' and ' + ROUND_DOUBLE(m.upperLimit,0) WHEN m.Status = 'TOOHIGH' THEN 'Merchant ' + n.companyName + ' count of ' + m.count + ' is above upper limit of ' + ROUND_DOUBLE(m.upperLimit,0) WHEN m.Status = 'TOOLOW' THEN 'Merchant ' + n.companyName + ' count of ' + m.count + ' is below lower limit of ' + ROUND_DOUBLE(m.lowerLimit,0) ELSE '' END FROM MerchantTxRateWithStatusStream m, NameLookup n WHERE m.merchantId = n.merchantId; CREATE SUBSCRIPTION PosAppEmailAlert USING EmailAdapter ( SMTPUSER:'sender@example.com', SMTPPASSWORD:'********', smtpurl:'smtp.gmail.com', starttls_enable:'true', subject:"test subject", emailList:"recipient@example.com,recipient2.example.com", senderEmail:"alertsender@example.com" ) INPUT FROM AlertStream; CREATE SUBSCRIPTION PosAppWebAlert USING WebAlertAdapter( ) INPUT FROM AlertStream;
When a merchant's status changes to TOOLOW or TOOHIGH, Striim will send an alert such as, "WARNING - alert from Striim - POSUnusualActivity - 2013-12-20 13:55:14 - Merchant Urban Outfitters Inc. count of 12012 is below lower limit of 13304.347826086958." The "raise" value for the flag field instructs the subscription not to send another alert until the status returns to OK.
Using field values in email alerts
When sending alerts with the EmailAdapter, you can populate the subject, sender address, and recipient addresses with values from the fields of the subscription's input stream.
To do this, first create a custom alert stream with the extra fields you want to use. The first five fields must be identical to Global.AlertEvent. To those, you may add fields containing the subjects, sender addresses, and recipient addresses.
CREATE TYPE CustomEmailAlert ( name String, keyVal String, severity String, flag String, message String, emailsubject String, senderEmail String, receipientList String ); CREATE STREAM CustomAlertStream OF CustomEmailAlert;
Reference the subject, sender, and recipient fields in the EmailAdapter properties as follows:
CREATE SUBSCRIPTION alertSubscription USING EmailAdapter ( smtpurl:'localhost:25', subject: '%emailsubject%', senderEmail:, emailList: ) INPUT FROM MyAlertStream; CREATE SUBSCRIPTION PosAppCustomEmailAlert USING EmailAdapter ( SMTPUSER:'sender@example.com', SMTPPASSWORD:'********', smtpurl:'smtp.gmail.com', starttls_enable:'true', subject:'%emailsubject%', emailList:'%receipientlist%', senderEmail:'%senderEmaiId%' ) INPUT FROM AlertStream;
You do not need to use all three. For example, you could populate only emailList with field values:
subject:"test subject", emailList:'%receipientlist%', senderEmail:"alertsender@example.com"
The values in the recipientlist field may include multiple email addresses separated by commas (no spaces).