Live Slicer health data may be made more widely available through the following workflow:
-
A Live Slicer pushes health data to Amazon SNS whenever one of the following conditions occur:
- An alert is generated for a key metric whenever the status of a monitored metric changes from “Healthy” to either “Warning” or “Critical.”
- The status of a key metric resumes “Healthy” status.
-
Amazon SNS broadcasts Live Slicer health data to one or more destination(s) (e.g., mobile device, web server, or Slack).
Get started with Amazon SNS for free through its SNS free tier. Learn more.
The Live Slicer formats health data using JSON. This data may then be filtered via custom code. This article explains how to strip out additional data generated by Amazon SNS via a custom function in Amazon Lambda.
Quick Start
Perform the following steps to set up Live Slicer health notifications:
-
Configure health monitoring for the desired Live Slicer.
Live Slicer health data may only be sent for metrics that are being monitored. For example, a custom monitoring configuration may be used to turn off monitoring and health notifications for one or more metrics for a particular Live Slicer. -
Set up an Amazon SNS topic.
Our service pushes Live Slicer health and failover notifications to the same Amazon SNS topic. -
Configure the Live Slicer to push health notifications to an Amazon SNS topic.
-
Configure Amazon SNS to broadcast health notifications to the desired destination(s). This section explains how to set up Amazon SNS and Lambda to broadcast health notifications to a Slack channel.
Set up an Amazon SNS Topic
Amazon SNS communicates with publishers and subscribers through a “topic.” For the purpose of this article, a Live Slicer will assume the role of a publisher, while a Slack channel will assume the role of the subscriber.
Our service pushes Live Slicer health and failover notifications to the same Amazon SNS topic.
Amazon SNS may be configured to broadcast data to multiple types of subscribers (e.g., web server, mobile device, email, etc.).
Perform the following steps to create a topic:
-
Sign in to the Amazon AWS Management Console. If you don’t have an AWS account, sign up for one.
-
Open the Amazon SNS console.
-
Click Get started.Amazon SNS may require Amazon SES (i.e., Amazon Simple Email Service). Please sign up for the Amazon SES service if an error message appears within the SNS dashboard.
-
From the upper-right corner, change your location to:
US West (Oregon) us-west-2
. -
Click Topics from the side navigation pane.
-
Click Create topic.
-
Click Standard.Our service does not support pushing notifications to a First-In-First-Out (FIFO) topic.
-
In the Name option, assign a unique name (e.g.,
marketing-live-slicer
) to the topic. -
Optional: If notifications will be sent over SMS, set the “Display name” option to the desired name.
-
Expand the Access policy section.
-
From the Define who can publish messages to the topic option, select Only the specified AWS accounts.
-
Set the Only these AWS users option to our AWS account ID:
545191325524
-
Click Create topic.
-
Copy the topic’s ARN.
Configure Communication with Amazon SNS
Both of the following configurations must be defined before the Live Slicer will push health information to Amazon SNS:
-
Create a notification profile that determines when SNS push notifications will be triggered.
-
Assign the above notification profile to each desired Live Slicer.
- Navigate to the Live Slicer Monitoring dashboard. From the main menu, navigate to Services and then click Monitoring 2.0.
- From the Saved Views option, select a Slicer View that contains the desired Live Slicer.
- Click on the desired Live Slicer.
- From the right-hand pane, set the ((Active Notification Profile)) option to the notification profile created in step 1.
-
Define the ARN topic to which Live Slicer health and failover notifications will be sent.
-
Navigate to the Notifications page: From the Live Slicer Monitoring dashboard, navigate to Settings > Notifications.
-
Click Update SNS Topic from the right-hand pane.
-
Set the Update your SNS Topic ARN option to the ARN for the topic created above.
-
Click Save Topic ARN.
-
Integrate Slack with Amazon SNS
Amazon SNS can broadcast notifications to various subscribers (e.g., mobile devices) using different delivery methods (e.g., HTTP, email, AWS Lambda, etc.).
The configuration performed up to this point enables the Live Slicer to send notifications to Amazon SNS. This section explains how to push those notifications from Amazon SNS to a Slack channel. Integrating Amazon SNS with Slack involves the following steps:
- Set up a Slack webhook.
- Create an Amazon Lambda function that subscribes to the Amazon SNS topic.
Set Up a Slack Webhook
Slack requires a webhook to be created before it can post messages from external sources (e.g., Amazon SNS).
Subscribe to an SNS Topic via Amazon Lambda
Amazon SNS needs to be informed of the above webhook before it can send data to a Slack channel. This task can be performed using Amazon Lambda, a compute service that runs code in response to events (e.g., when data is pushed from a Live Slicer to Amazon SNS).
This section creates a Lambda function in Python that performs the following tasks:
- Subscribes to an SNS topic.
- Identifies the Slack webhook through which it will post messages to a Slack channel.
- Strips out data added by Amazon SNS.
You can add custom code to this function to tailor how messages are posted to a Slack channel (e.g., filter notifications by Live Slicer).
Create a Lambda Function
Perform the following steps to create a Lambda function:
-
Open the Amazon Lambda console.
-
Click Get Started Now.
-
Click Blank Function.
-
Click the dashed box and then select SNS as the trigger for this function.
-
Verify that the SNS topic created earlier in this article is selected in the SNS topic option.
-
Mark the Enable trigger option.
-
Click Next.
-
Configure the Lambda function :
-
Name: Set the
Name
option to the name of the function (e.g.,forward_to_slack
). -
Description: Set the
Description
option to a brief description for the purpose of the function (e.g.,Send Live Slicer information to a Slack channel.
). -
Runtime: Set the
Runtime
option toPython 2.7
. -
Code: Set the Lambda function code option to the following code:python1import json2import urllib234def forward_to_slack(event, context):5 # The URL for your Slack Channel's webhook6 url = "https://hooks.slack.com/services/ABCDE1234/FGHIJ5678/KLMNOPQRSTUV901234567890"78 # Format the message9 try:10 # Try to navigate to the Message that was sent via SNS and strip out the11 # rest of the delivery information12 slack_data = {"text": str(event['Records'][0]['Sns']['Message'])}13 except:14 slack_data = {"text": str(event)}1516 # Dump the json to prepare it for sending17 data = json.dumps(slack_data)1819 # Create the request20 req = urllib2.Request(url, data)2122 # Send request23 urllib2.urlopen(req)Update the webhook URL defined in the code to point to the one copied in the Setting up a Slack Webhook section.
-
Handler: Set the Handler option to
lambda_function.
and then append the name of the function defined in the Name option (e.g.,lambda_function.forward_to_slack
). -
Role: Set the Role option to Create new role from template(s).
-
Role name: Set the Role name option to the name that will be assigned to the new role (e.g.,
lambda_basic_execution
). -
Click Next.
-
-
Amazon Lambda will now allow you to review the function that will be created. Verify the correct SNS topic has been selected and that the Lambda function configuration.
-
Click Create function. Amazon Lambda will now automatically post health data to a Slack channel as it is provided by a Live Slicer.
Notification Data Format
Once an alert is triggered or upon resuming “Healthy” status, a Live Slicer sends information that describes the change in JSON format. Each parameter sent in this health notification is described below.
Parameter | Description |
---|---|
slicer_owner_username | Indicates the email address through which the Live Slicer authenticates to the system. This email address is defined by the username setting in the Live Slicer configuration file (i.e., uplynk.conf ). |
old_metric_health | Indicates the state of the metric identified by the metric_name parameter prior to this change in status. Valid values are: - healthy: Metric did not meet or exceed its warning or critical threshold. - warning: Metric met or exceeded its warning threshold, but remained below its critical threshold. - critical: Metric met or exceeded its critical threshold. - neutral: Monitoring information is unavailable because the Live Slicer was inactive. |
metric_critical_threshold | Indicates the threshold that must be met before the metric identified by the metric_name parameter enters a critical state. This threshold is defined in the monitoring rule assigned to the Live Slicer. Examples: - 8 frames : Threshold value is 8, unit is “frames”. - None seconds : No threshold defined, unit is “seconds”. - null : Metric cannot be assigned a critical threshold value. |
current_metric_health | Indicates the current state of the metric identified by the metric_name parameter. Valid values are: - healthy: Metric did not meet or exceed its warning or critical threshold. - warning: Metric met or exceeded its warning threshold, but remained below its critical threshold. - critical: Metric met or exceeded its critical threshold. |
slicer_current_health | Indicates the current health of the Live Slicer defined in the slicer parameter. Valid values are: - healthy: Live Slicer is not experiencing warning or critical levels for any monitored metric. - warning: Live Slicer is experiencing warning levels for one or more monitored metrics. - critical: Live Slicer is experiencing critical levels for one or more monitored metrics. |
slicer | Indicates the name of the Live Slicer that pushed the current health notification. |
metric_warning_threshold | Indicates the threshold that must be met before the metric identified by the metric_name parameter enters a warning state. This threshold is defined in the monitoring rule assigned to the Live Slicer. Examples: - 8 frames: Threshold value is 8, unit is “frames”. - None seconds: No threshold defined, unit is “seconds”. - null: Metric cannot be assigned a warning threshold value. |
current_metric_value | Indicates the metric’s value at the time defined by the utc_time parameter. Examples: - 8 frames: Metric’s value is 8, unit is “frames”. - TS unicast :1234 1920x1080: Description of the signal for “Signal Status” when a signal is detected. - no signal: Reported for “Signal Status” when a signal is not detected. |
utc_time | Indicates the date and time (UTC) at which the change in metric health took place. Syntax: YYYY-MM-DD hh:mm:ss.ffffff Sample value: 2017-01-16 19:40:53.605533 |
metric_name | Identifies the metric that triggered the change in Live Slicer health. |
Sample Health Notification Data
The following sample data indicates that the Live Slicer’s signal was restored allowing it to resume “healthy” status.
JSON
1{2 "slicer_owner_username": "joe@mycompany.com",3 "old_metric_health": "critical",4 "metric_critical_threshold": null,5 "current_metric_health": "healthy",6 "slicer_current_health": "healthy",7 "slicer": "MySlicer",8 "metric_warning_threshold": null,9 "current_metric_value": "TS unicast :1234 1920x1080",10 "utc_time": "2017-01-16 19:35:49.105642",11 "metric_name": "Signal Status"12}