deep dive on aws iot
TRANSCRIPT
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Vadim Jelezniakov | Dev Manager, AWS IoT
19 April 2016
IoT on AWS
Deep Dive
Goal: Answer these questions
1. How do I extract value from my device data?
Using IoT rules engine to process your data
2. How do I visualize my device data?
Connecting the rules engine to Elasticsearch/Kibana
3. How do I generate predictions?
Using Amazon Machine Learning predict function in
your IoT rules
AWS IoT
Back to the questions
1. How do I extract value from my device data?
Using IoT rules engine to process messages
2. How do I visualize my device data?
Connecting the rules engine to Elasticsearch/Kibana
3. How do I generate predictions ?
Using Amazon Machine Learning predict function in
your IoT rules
Rules Engine
Rules engine: Extracting value from messages
• Filter messages with certain criteria
• Transform the payload of messages
• React based on messages
• Move messages to other topics
• Move messages to other systems
• Predict changes based on trends
What is a rule?
ruleArn: arn:aws:iot:<region>:<account_id>:rule/<uniq_rule_name>
rule:
• ruleName: human-readable name
• description: human-readable description
• ruleDisabled: true/false
• sql: e.g. SELECT * FROM ‘pm/topic’
• actions:
• action 1:
• action 2:
What is a rule?
• ruleName: human-readable name
• description: human-readable description
• ruleDisabled: true/false
• sql: e.g. SELECT * FROM ‘pm/topic’
• actions:
• action 1:
• action 2:
What is a rule?
• ruleName: human-readable name
• description: human-readable description
• ruleDisabled: true/false
• sql: e.g. SELECT * FROM ‘pm/topic’
• actions:
• action 1:
• action 2:
Rules engine: Filter and transform
• Filter messages with certain criteria
• Transform the payload of messages
• React based on messages
• Move messages to other topics
• Move messages to other systems
• Predict changes based on trends
Rules engine: Filter and transform
• SQL
• SELECT * FROM topic WHERE condition
• SELECT status.space_id AS room_id FROM
'iot/tempSensors/#' WHERE temp > 50
• Functions (in SELECT or WHERE)
• String manipulation (regex support)
• Mathematical operations
• Context-based helper functions
• Crypto support
• UUID, timestamp, rand, etc.
Rules engine: React and move
• Filter messages with certain criteria
• Transform the payload of messages
• React based on messages
• Move messages to other topics
• Move messages to other systems
• Predict changes based on trends
Rules engine: React (and move)
"rule": {
"ruleName": "republishPredictions”,
"ruleDisabled": false,
"sql": "SELECT no AS id, cycle AS c_number FROM 'pm/topic' WHERE failure = 1",
"description": "Republish ids of engines that are predicted to fail within 30 cycles",
"actions": [
{
"republish": {
"topic": "pm/failures",
"roleArn": "arn:aws:iam::012345678901:role/iot-actions-role”
}
}
],
}
Rules engine: React (and move)
"rule": {
"ruleName": "republishPredictions”,
"ruleDisabled": false,
"sql": "SELECT no AS id, cycle AS c_number FROM 'pm/topic' WHERE failure = 1",
"description": "Republish ids of engines that are predicted to fail within 30 cycles",
"actions": [
{
"republish": {
"topic": "pm/failures",
"roleArn": "arn:aws:iam::012345678901:role/iot-actions-role”
}
}
],
}
Rules engine: Move messages to other systems
• Filter messages with certain criteria
• Transform the payload of messages
• React based on messages
• Move messages to other topics
• Move messages to other systems
• Predict changes based on trends
Rules engine: Move messages to other
systems
Invoke a Lambda function
Put object in an S3 bucket
Insert, update a
DynamoDB table
Publish to an SNS topic
or endpoint
Publish to a Kinesis stream
Publish to Firehose
Republish to AWS IoT
Publish to Elasticsearch
Capture a CloudWatch
metric or change an alarm
Write to SQS queue
1. How do I extract value from my device data?
Using IoT rules engine to process messages
2. How do I visualize my device data?
Connecting the rules engine to Elasticsearch/Kibana
3. How do I generate predictions?
Using Amazon Machine Learning predict function in
your IoT rules
1. How do I extract value from my device data ?
Using IoT Rules Engine to process messages
2. How do I visualize my device data?
Connecting the rules engine to Elasticsearch/Kibana
3. How do I generate predictions ?
Using Amazon Machine Learning (AML) predict
function in your IoT Rules
ElasticSearch Integration - New
Basic flow for using Elasticsearch
1. Configure your Elasticsearch domain
2. Use an IoT rule to send device data to the
Elasticsearch domain you configured
3. Use Kibana to visualize your device data
AWS IoT Elasticsearch demo
1. How do I extract value from my device data?
Using IoT rules engine to process messages
2. How do I visualize my device data?
Connecting the rules engine to Elasticsearch/Kibana
3. How do I generate predictions?
Using Amazon Machine Learning predict function in
your IoT rules
1. How do I extract value from my device data ?
Using IoT Rules Engine to process messages
2. How do I visualize my device data ?
Connecting the Rules Engine to ElasticSearch / Kibana
3. How do I generate predictions?
Using Amazon Machine Learning predict function in
your IoT rules
Failures are often hard to predict
Importance of the good predictions
Right balance depends on risk/cost ratio:
1. Predict a failure too soon = replacing a part
that doesn’t need repair yet – loss
2. No prediction = risk of sustaining a bigger loss
Amazon ML Predict Function
Basic flow for using predictions
1. Use an IoT rule to forward device data to S3
2. Train your Amazon ML model using the data from
S3
3. Use an IoT rule to:
• Obtain predicted value from real-time prediction
endpoint in Amazon ML
• Emit a CloudWatch metric (or trigger an alarm)
4. Use an IoT rule to emit details of a predicted failure
AWS IoT predict function for Amazon ML
machinelearning_predict(
'ml-XXXXXX',
'arn:aws:iam::<account_id>:role/<role>',
*).predictedLabel
ml-XXXXXX – Amazon ML predictor you trained
account_id – your account ID
role – a role in your account that:
• Has access to Amazon ML
• Part of a trust relationship b/w your account and IoT
AWS IoT predict demo
More fun with WebSockets:
predict.vadimj.io
Summary
• Extract value from device data: rules engine
• Visualize your data: rules engine with
Elasticsearch/Kibana integration
• Using predictions: machinelearning_predict()
Thank You!@vadimj