12
The Zen of IoT and Azure Stream Analytics Jeff Prosise [email protected]

The Zen of IoT and Azure Stream Analytics€¦ · The Internet of Things (IoT) Currently 20 billion devices connected to the Internet By 2020, the number will grow to 50 billion or

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Zen of IoT and Azure Stream Analytics€¦ · The Internet of Things (IoT) Currently 20 billion devices connected to the Internet By 2020, the number will grow to 50 billion or

The Zen of IoT and Azure Stream Analytics

Jeff Prosise

[email protected]

Page 2: The Zen of IoT and Azure Stream Analytics€¦ · The Internet of Things (IoT) Currently 20 billion devices connected to the Internet By 2020, the number will grow to 50 billion or

The Internet of Things (IoT)

Currently 20 billion devices connected

to the Internet

By 2020, the number will grow to 50

billion or more

Power meters and health-monitoring devices

Wall thermostats, wind turbines, and solar farms

Cars, delivery trucks, traffic lights, and drones

EVERYTHING will be connected

How do you process all that data?

How do you process it in real time?

Page 3: The Zen of IoT and Azure Stream Analytics€¦ · The Internet of Things (IoT) Currently 20 billion devices connected to the Internet By 2020, the number will grow to 50 billion or

Connected Cows

Breeding cattle is a tough business

Fujitsu wired cows with Fitbits and used Azure

Stream Analytics to monitor steps

Stream Analytics alerts farmer when cow

enters estrus ("heat") with 95% accuracy

Boosted insemination rates from 30% to 65%

https://www.youtube.com/watch?v=oY0mxwySaSo

http://mnc.ms/24mxadh

"Hot" cowNormal cow

Page 4: The Zen of IoT and Azure Stream Analytics€¦ · The Internet of Things (IoT) Currently 20 billion devices connected to the Internet By 2020, the number will grow to 50 billion or

Azure Stream Analytics

Highly scalable service for analyzing data in motion

Analyze data streaming from IoT devices and other sources

Scales easily using Streaming Units (1 SU ~= 1 MB/sec)

Supports SQL-like query language for data analysis

Event Hubs

Blob Storage

Azure SQL Database

Blob Storage

Event Hubs

Other Output SinksStream Analytics

IoT Hubs

Page 5: The Zen of IoT and Azure Stream Analytics€¦ · The Internet of Things (IoT) Currently 20 billion devices connected to the Internet By 2020, the number will grow to 50 billion or

Azure Stream Analytics at Work

Page 6: The Zen of IoT and Azure Stream Analytics€¦ · The Internet of Things (IoT) Currently 20 billion devices connected to the Internet By 2020, the number will grow to 50 billion or

Stream Analytics Query Language

SQL-like language for querying live data streams

Subset of T-SQL

Supports bigint, float, nvarchar(max), datetime, record, and array

Supports SELECT, FROM, WHERE, GROUP BY, and other common Data Manipulation Language (DML)

statements

Supports COUNT, AVG, DATEDIFF, and other common functions

Supports extensions such as TIMESTAMP BY and System.Timestamp

Supports temporal grouping of events via "windowing"

Reference located at https://msdn.microsoft.com/en-

us/library/azure/dn834998.aspx

Page 7: The Zen of IoT and Azure Stream Analytics€¦ · The Internet of Things (IoT) Currently 20 billion devices connected to the Internet By 2020, the number will grow to 50 billion or

Querying a Data Stream

SELECT EntryTime, TollId, LicensePlateFROM EntryDataWHERE Make = 'Honda' AND State = 'NJ'

Page 8: The Zen of IoT and Azure Stream Analytics€¦ · The Internet of Things (IoT) Currently 20 billion devices connected to the Internet By 2020, the number will grow to 50 billion or

JOINing Two Data Streams

SELECT EN.TollId, EN.EntryTime, EX.ExitTime, EN.LicensePlate, DATEDIFF(minute, EN.EntryTime, EX.ExitTime) AS MinutesFROM EntryData EN TIMESTAMP BY EntryTimeJOIN ExitData EX TIMESTAMP BY ExitTimeON EN.TollId = EX.TollId AND EN.LicensePlate = EX.LicensePlateAND DATEDIFF(minute, EN, EX) BETWEEN 0 AND 15

Page 9: The Zen of IoT and Azure Stream Analytics€¦ · The Internet of Things (IoT) Currently 20 billion devices connected to the Internet By 2020, the number will grow to 50 billion or

Windowing

Core requirement for stream-processing systems for counting or aggregating

events in a specified time period

Tumbling Window Hopping Window Sliding Window

Page 10: The Zen of IoT and Azure Stream Analytics€¦ · The Internet of Things (IoT) Currently 20 billion devices connected to the Internet By 2020, the number will grow to 50 billion or

Using TumblingWindow

SELECT System.Timestamp AS Time, COUNT(*) FROM EntryDataTIMESTAMP BY EntryTimeWHERE TollId = 1 AND State = 'NY'GROUP BY TumblingWindow(minute,5)

Page 11: The Zen of IoT and Azure Stream Analytics€¦ · The Internet of Things (IoT) Currently 20 billion devices connected to the Internet By 2020, the number will grow to 50 billion or

Using SlidingWindow

SELECT DateAdd(minute,-5,System.TimeStamp) AS [Start Time],System.TimeStamp AS [End Time], TollId, COUNT(*)

FROM EntryData TIMESTAMP BY EntryTimeWHERE State = 'NJ'GROUP BY TollId, SlidingWindow(minute, 5)HAVING COUNT(*) > 1

Page 12: The Zen of IoT and Azure Stream Analytics€¦ · The Internet of Things (IoT) Currently 20 billion devices connected to the Internet By 2020, the number will grow to 50 billion or

Building an End-to-End Solution

Step 1: Create an event hub for input

Step 2: Build an app to transmit events to the event hub

Step 3: Create and configure a Stream Analytics job

Step 4: Create an event hub for output

Step 5: Build an app to connect to the output hub

Step 6: Analyze a live data stream