├── Images
├── Architecture.PNG
├── IotHubRoutes.PNG
├── IotHubEndpoints.PNG
├── TimeSeriesInsights.png
├── IotHubHumidityRoute.PNG
├── Time Series Dashboard.PNG
├── TimeSeriesInsights-Queries.PNG
└── TimeSeriesInsights-EventSources.PNG
├── AzureIoTEdgeFunctions
├── HumidityFilterFunction
│ ├── host.json
│ ├── Docker
│ │ ├── windows-nano
│ │ │ └── Dockerfile
│ │ └── linux-x64
│ │ │ ├── Dockerfile
│ │ │ └── Dockerfile.debug
│ ├── EdgeHubTrigger-Csharp
│ │ ├── function.json
│ │ └── run.csx
│ └── deployment.json
└── TemperatureFilterFunction
│ ├── host.json
│ ├── Docker
│ ├── windows-nano
│ │ └── Dockerfile
│ └── linux-x64
│ │ ├── Dockerfile
│ │ └── Dockerfile.debug
│ ├── EdgeHubTrigger-Csharp
│ ├── function.json
│ └── run.csx
│ └── deployment.json
├── CHANGELOG.md
├── AzureFunctions
├── HttpTemperatureAlert
│ ├── index.js
│ └── function.json
├── HttpHumidityAlertV2
│ ├── function.json
│ └── run.csx
└── HttpHumidityAlert
│ ├── function.json
│ └── run.csx
├── Scripts
└── install_IOT_components.sh
├── .github
├── ISSUE_TEMPLATE.md
└── PULL_REQUEST_TEMPLATE.md
├── LICENSE.md
├── CONTRIBUTING.md
├── .gitignore
└── README.md
/Images/Architecture.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tikyau/Azure-Functions-IoT-TimeSeries-Analytics/master/Images/Architecture.PNG
--------------------------------------------------------------------------------
/Images/IotHubRoutes.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tikyau/Azure-Functions-IoT-TimeSeries-Analytics/master/Images/IotHubRoutes.PNG
--------------------------------------------------------------------------------
/Images/IotHubEndpoints.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tikyau/Azure-Functions-IoT-TimeSeries-Analytics/master/Images/IotHubEndpoints.PNG
--------------------------------------------------------------------------------
/Images/TimeSeriesInsights.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tikyau/Azure-Functions-IoT-TimeSeries-Analytics/master/Images/TimeSeriesInsights.png
--------------------------------------------------------------------------------
/Images/IotHubHumidityRoute.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tikyau/Azure-Functions-IoT-TimeSeries-Analytics/master/Images/IotHubHumidityRoute.PNG
--------------------------------------------------------------------------------
/Images/Time Series Dashboard.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tikyau/Azure-Functions-IoT-TimeSeries-Analytics/master/Images/Time Series Dashboard.PNG
--------------------------------------------------------------------------------
/Images/TimeSeriesInsights-Queries.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tikyau/Azure-Functions-IoT-TimeSeries-Analytics/master/Images/TimeSeriesInsights-Queries.PNG
--------------------------------------------------------------------------------
/Images/TimeSeriesInsights-EventSources.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tikyau/Azure-Functions-IoT-TimeSeries-Analytics/master/Images/TimeSeriesInsights-EventSources.PNG
--------------------------------------------------------------------------------
/AzureIoTEdgeFunctions/HumidityFilterFunction/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "watchDirectories": [ "Shared" ],
3 | "functionTimeout": "00:05:00",
4 | "functions": [ "EdgeHubTrigger-Csharp" ]
5 | }
--------------------------------------------------------------------------------
/AzureIoTEdgeFunctions/TemperatureFilterFunction/host.json:
--------------------------------------------------------------------------------
1 | {
2 | "watchDirectories": [ "Shared" ],
3 | "functionTimeout": "00:05:00",
4 | "functions": [ "EdgeHubTrigger-Csharp" ]
5 | }
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [project-title] Changelog
2 |
3 |
4 | # x.y.z (yyyy-mm-dd)
5 |
6 | *Features*
7 | * ...
8 |
9 | *Bug Fixes*
10 | * ...
11 |
12 | *Breaking Changes*
13 | * ...
14 |
--------------------------------------------------------------------------------
/AzureIoTEdgeFunctions/HumidityFilterFunction/Docker/windows-nano/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM microsoft/azureiotedge-functions-binding:1.0-preview
2 |
3 | ENV AzureWebJobsScriptRoot=c:\\approot
4 |
5 | ARG EXE_DIR=.
6 |
7 | COPY $EXE_DIR/ c:\\approot
--------------------------------------------------------------------------------
/AzureIoTEdgeFunctions/TemperatureFilterFunction/Docker/windows-nano/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM microsoft/azureiotedge-functions-binding:1.0-preview
2 |
3 | ENV AzureWebJobsScriptRoot=c:\\approot
4 |
5 | ARG EXE_DIR=.
6 |
7 | COPY $EXE_DIR/ c:\\approot
--------------------------------------------------------------------------------
/AzureIoTEdgeFunctions/HumidityFilterFunction/Docker/linux-x64/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM microsoft/azureiotedge-functions-binding:1.0-preview
2 |
3 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot
4 |
5 | ARG EXE_DIR=.
6 |
7 | COPY $EXE_DIR/ /home/site/wwwroot
--------------------------------------------------------------------------------
/AzureIoTEdgeFunctions/TemperatureFilterFunction/Docker/linux-x64/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM microsoft/azureiotedge-functions-binding:1.0-preview
2 |
3 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot
4 |
5 | ARG EXE_DIR=.
6 |
7 | COPY $EXE_DIR/ /home/site/wwwroot
--------------------------------------------------------------------------------
/AzureIoTEdgeFunctions/HumidityFilterFunction/Docker/linux-x64/Dockerfile.debug:
--------------------------------------------------------------------------------
1 | FROM microsoft/azureiotedge-functions-binding:1.0-preview
2 |
3 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot
4 |
5 | ARG EXE_DIR=.
6 |
7 | RUN apt-get update
8 |
9 | RUN apt-get install -y unzip procps
10 |
11 | RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg
12 |
13 | COPY $EXE_DIR/ /home/site/wwwroot
--------------------------------------------------------------------------------
/AzureIoTEdgeFunctions/TemperatureFilterFunction/Docker/linux-x64/Dockerfile.debug:
--------------------------------------------------------------------------------
1 | FROM microsoft/azureiotedge-functions-binding:1.0-preview
2 |
3 | ENV AzureWebJobsScriptRoot=/home/site/wwwroot
4 |
5 | ARG EXE_DIR=.
6 |
7 | RUN apt-get update
8 |
9 | RUN apt-get install -y unzip procps
10 |
11 | RUN curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg
12 |
13 | COPY $EXE_DIR/ /home/site/wwwroot
--------------------------------------------------------------------------------
/AzureIoTEdgeFunctions/HumidityFilterFunction/EdgeHubTrigger-Csharp/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "type": "edgeHubTrigger",
5 | "name": "messageReceived",
6 | "InputName": "input1",
7 | "direction": "in"
8 | },
9 | {
10 | "type": "edgeHub",
11 | "name": "output",
12 | "outputName": "alertOutput",
13 | "batchSize": 10,
14 | "direction": "inout"
15 | }
16 | ]
17 | }
--------------------------------------------------------------------------------
/AzureIoTEdgeFunctions/TemperatureFilterFunction/EdgeHubTrigger-Csharp/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "type": "edgeHubTrigger",
5 | "name": "messageReceived",
6 | "InputName": "input1",
7 | "direction": "in"
8 | },
9 | {
10 | "type": "edgeHub",
11 | "name": "output",
12 | "outputName": "alertOutput",
13 | "batchSize": 10,
14 | "direction": "inout"
15 | }
16 | ]
17 | }
--------------------------------------------------------------------------------
/AzureFunctions/HttpTemperatureAlert/index.js:
--------------------------------------------------------------------------------
1 | module.exports = function (context, req) {
2 |
3 | context.log(req.body);
4 | var body = JSON.stringify(req.body);
5 | var message = {
6 | "personalizations": [{ "to": [{"email": "YOURE_E_MAIL_HERE"}]}],
7 | from: { email: "iot@alert.com" },
8 | subject: "[IoT] Temperature Alert",
9 | content: [{
10 | type: 'text/plain',
11 | value: body
12 | }]
13 | };
14 | context.bindings.message = message;
15 | context.done();
16 | };
--------------------------------------------------------------------------------
/AzureFunctions/HttpHumidityAlertV2/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "name": "req",
6 | "type": "httpTrigger",
7 | "direction": "in"
8 | },
9 | {
10 | "name": "$return",
11 | "type": "http",
12 | "direction": "out"
13 | },
14 | {
15 | "type": "sendGrid",
16 | "name": "messages",
17 | "apiKey": "SendGridAttribute.ApiKey",
18 | "direction": "out"
19 | }
20 | ],
21 | "disabled": false
22 | }
--------------------------------------------------------------------------------
/AzureFunctions/HttpHumidityAlert/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "name": "req",
6 | "type": "httpTrigger",
7 | "direction": "in"
8 | },
9 | {
10 | "name": "message",
11 | "type": "sendGrid",
12 | "direction": "out",
13 | "apiKey": "SendGridAttribute.ApiKey",
14 | "to": "YOUR_E_MAIL_HERE",
15 | "from": "iot@alert.com",
16 | "subject": "IoT Humidity Alert"
17 | },
18 | {
19 | "name": "$return",
20 | "type": "http",
21 | "direction": "out"
22 | }
23 | ],
24 | "disabled": false
25 | }
--------------------------------------------------------------------------------
/AzureFunctions/HttpTemperatureAlert/function.json:
--------------------------------------------------------------------------------
1 | {
2 | "bindings": [
3 | {
4 | "authLevel": "function",
5 | "type": "httpTrigger",
6 | "direction": "in",
7 | "name": "req"
8 | },
9 | {
10 | "type": "http",
11 | "direction": "out",
12 | "name": "res"
13 | },
14 | {
15 | "type": "sendGrid",
16 | "name": "message",
17 | "apiKey": "SendGridAttribute.ApiKey",
18 | "to": "YOUR_E_MAIL_HERE",
19 | "from": "iot@alert.com",
20 | "subject": "IoT Temperature Alert",
21 | "direction": "out"
22 | }
23 | ],
24 | "disabled": false
25 | }
--------------------------------------------------------------------------------
/Scripts/install_IOT_components.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | CONN_STR="$1"
4 |
5 | echo 'Recieved connection string '$CONN_STR
6 |
7 | sudo apt-get update
8 |
9 | #Install docker
10 | echo 'Downloading docker'
11 | curl -fsSL get.docker.com -o get-docker.sh
12 |
13 | echo 'Installing docker'
14 | sudo sh get-docker.sh
15 |
16 | #install python 2.7 pip
17 | sudo apt-get install python-pip -y
18 |
19 | #install IOT Edge runtime
20 | sudo pip install -U azure-iot-edge-runtime-ctl
21 |
22 | if [ ! -z $CONN_STR ]; then
23 | echo 'Attempting to setup device with connection string {'$CONN_STR'}'
24 | sudo iotedgectl setup --connection-string "$CONN_STR" --auto-cert-gen-force-no-passwords
25 |
26 | echo 'starting up device.'
27 | sudo iotedgectl start
28 | else
29 | echo 'No connection string set, exiting.'
30 | fi
31 |
--------------------------------------------------------------------------------
/AzureFunctions/HttpHumidityAlert/run.csx:
--------------------------------------------------------------------------------
1 | #r "SendGrid"
2 |
3 | using System;
4 | using System.Net;
5 | using SendGrid.Helpers.Mail;
6 |
7 | public static HttpResponseMessage Run(HttpRequestMessage req, out Mail message , TraceWriter log)
8 | {
9 | log.Info("C# HTTP trigger function processed a request.");
10 | var data = req.Content.ReadAsStringAsync().Result;
11 |
12 | log.Info("data: " + data);
13 |
14 | message = new Mail
15 | {
16 | Subject = "IoT Humidity Alert"
17 | };
18 |
19 | var personalization = new Personalization();
20 | personalization.AddTo(new Email("YOUR_E_MAIL_HERE"));
21 |
22 | Content content = new Content
23 | {
24 | Type = "text/plain",
25 | Value = data
26 | };
27 | message.AddContent(content);
28 | message.AddPersonalization(personalization);
29 |
30 | return req.CreateResponse(HttpStatusCode.OK, "Result" );
31 | }
--------------------------------------------------------------------------------
/AzureFunctions/HttpHumidityAlertV2/run.csx:
--------------------------------------------------------------------------------
1 | #r "Newtonsoft.Json"
2 | #r "SendGrid"
3 |
4 | using System.Net;
5 | using Microsoft.AspNetCore.Mvc;
6 | using Microsoft.Extensions.Primitives;
7 | using Newtonsoft.Json;
8 | using SendGrid.Helpers.Mail;
9 | using System.Text;
10 |
11 | public async static Task Run(HttpRequest req, IAsyncCollector messages, TraceWriter log)
12 | {
13 | log.Info("SendGrid message");
14 | using (StreamReader reader = new StreamReader(req.Body, Encoding.UTF8))
15 | {
16 | var body = await reader.ReadToEndAsync();
17 | var message = new SendGridMessage();
18 | message.AddTo("technicians@iot.com");
19 | message.AddContent("text/html", body);
20 | message.SetFrom("iot@alert.com");
21 | message.SetSubject("[Alert] IoT Hub Notrtification");
22 | await messages.AddAsync(message);
23 | return (ActionResult)new OkObjectResult("The E-mail has been sent.");
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
4 | > Please provide us with the following information:
5 | > ---------------------------------------------------------------
6 |
7 | ### This issue is for a: (mark with an `x`)
8 | ```
9 | - [ ] bug report -> please search issues before submitting
10 | - [ ] feature request
11 | - [ ] documentation issue or request
12 | - [ ] regression (a behavior that used to work and stopped in a new release)
13 | ```
14 |
15 | ### Minimal steps to reproduce
16 | >
17 |
18 | ### Any log messages given by the failure
19 | >
20 |
21 | ### Expected/desired behavior
22 | >
23 |
24 | ### OS and Version?
25 | > Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)
26 |
27 | ### Versions
28 | >
29 |
30 | ### Mention any other details that might be useful
31 |
32 | > ---------------------------------------------------------------
33 | > Thanks! We'll be in touch soon.
34 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## Purpose
2 |
3 | * ...
4 |
5 | ## Does this introduce a breaking change?
6 |
7 | ```
8 | [ ] Yes
9 | [ ] No
10 | ```
11 |
12 | ## Pull Request Type
13 | What kind of change does this Pull Request introduce?
14 |
15 |
16 | ```
17 | [ ] Bugfix
18 | [ ] Feature
19 | [ ] Code style update (formatting, local variables)
20 | [ ] Refactoring (no functional changes, no api changes)
21 | [ ] Documentation content changes
22 | [ ] Other... Please describe:
23 | ```
24 |
25 | ## How to Test
26 | * Get the code
27 |
28 | ```
29 | git clone [repo-address]
30 | cd [repo-name]
31 | git checkout [branch-name]
32 | npm install
33 | ```
34 |
35 | * Test the code
36 |
37 | ```
38 | ```
39 |
40 | ## What to Check
41 | Verify that the following are valid
42 | * ...
43 |
44 | ## Other Information
45 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Microsoft Corporation. All rights reserved.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE
--------------------------------------------------------------------------------
/AzureIoTEdgeFunctions/HumidityFilterFunction/deployment.json:
--------------------------------------------------------------------------------
1 | {
2 | "moduleContent": {
3 | "$edgeAgent": {
4 | "properties.desired": {
5 | "schemaVersion": "1.0",
6 | "runtime": {
7 | "type": "docker",
8 | "settings": {
9 | "minDockerVersion": "v1.25",
10 | "loggingOptions": ""
11 | }
12 | },
13 | "systemModules": {
14 | "edgeAgent": {
15 | "type": "docker",
16 | "settings": {
17 | "image": "microsoft/azureiotedge-agent:1.0-preview",
18 | "createOptions": ""
19 | }
20 | },
21 | "edgeHub": {
22 | "type": "docker",
23 | "status": "running",
24 | "restartPolicy": "always",
25 | "settings": {
26 | "image": "microsoft/azureiotedge-hub:1.0-preview",
27 | "createOptions": ""
28 | }
29 | }
30 | },
31 | "modules": {
32 | "TemperatureFilterFunction": {
33 | "version": "1.0",
34 | "type": "docker",
35 | "status": "running",
36 | "restartPolicy": "always",
37 | "settings": {
38 | "image": "/:",
39 | "createOptions": "{}"
40 | }
41 | }
42 | }
43 | }
44 | },
45 | "$edgeHub": {
46 | "properties.desired": {
47 | "schemaVersion": "1.0",
48 | "routes": {
49 | "route": "FROM /* INTO $upstream"
50 | },
51 | "storeAndForwardConfiguration": {
52 | "timeToLiveSecs": 7200
53 | }
54 | }
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/AzureIoTEdgeFunctions/TemperatureFilterFunction/deployment.json:
--------------------------------------------------------------------------------
1 | {
2 | "moduleContent": {
3 | "$edgeAgent": {
4 | "properties.desired": {
5 | "schemaVersion": "1.0",
6 | "runtime": {
7 | "type": "docker",
8 | "settings": {
9 | "minDockerVersion": "v1.25",
10 | "loggingOptions": ""
11 | }
12 | },
13 | "systemModules": {
14 | "edgeAgent": {
15 | "type": "docker",
16 | "settings": {
17 | "image": "microsoft/azureiotedge-agent:1.0-preview",
18 | "createOptions": ""
19 | }
20 | },
21 | "edgeHub": {
22 | "type": "docker",
23 | "status": "running",
24 | "restartPolicy": "always",
25 | "settings": {
26 | "image": "microsoft/azureiotedge-hub:1.0-preview",
27 | "createOptions": ""
28 | }
29 | }
30 | },
31 | "modules": {
32 | "TemperatureFilterFunction": {
33 | "version": "1.0",
34 | "type": "docker",
35 | "status": "running",
36 | "restartPolicy": "always",
37 | "settings": {
38 | "image": "/:",
39 | "createOptions": "{}"
40 | }
41 | }
42 | }
43 | }
44 | },
45 | "$edgeHub": {
46 | "properties.desired": {
47 | "schemaVersion": "1.0",
48 | "routes": {
49 | "route": "FROM /* INTO $upstream"
50 | },
51 | "storeAndForwardConfiguration": {
52 | "timeToLiveSecs": 7200
53 | }
54 | }
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/AzureIoTEdgeFunctions/HumidityFilterFunction/EdgeHubTrigger-Csharp/run.csx:
--------------------------------------------------------------------------------
1 | #r "Microsoft.Azure.Devices.Client"
2 | #r "Newtonsoft.Json"
3 |
4 |
5 | using System.IO;
6 | using Microsoft.Azure.Devices.Client;
7 | using Newtonsoft.Json;
8 |
9 | public static async Task Run(Message messageReceived, IAsyncCollector output, TraceWriter log)
10 | {
11 | // Threshold for Humidity
12 | const int humidityThreshold = 24;
13 |
14 | byte[] messageBytes = messageReceived.GetBytes();
15 | var messageString = System.Text.Encoding.UTF8.GetString(messageBytes);
16 |
17 | if (!string.IsNullOrEmpty(messageString))
18 | {
19 | // Get the body of the message and deserialize it
20 | var messageBody = JsonConvert.DeserializeObject(messageString);
21 |
22 | // Check for humidity value
23 | if (messageBody != null && messageBody.ambient.humidity > humidityThreshold)
24 | {
25 | // We will send the message to the output as the temperature value is greater than the threashold
26 | var filteredMessage = new Message(messageBytes);
27 | // We need to copy the properties of the original message into the new Message object
28 | foreach (KeyValuePair prop in messageReceived.Properties)
29 | {
30 | filteredMessage.Properties.Add(prop.Key, prop.Value);
31 | }
32 | // We are adding a new property to the message to indicate it is a humidty alert
33 | filteredMessage.Properties.Add("MessageType", "HumidityAlert");
34 | // Send the message
35 | await output.AddAsync(filteredMessage);
36 | log.Info("Received and transferred a message with temperature above the threshold");
37 | }
38 | }
39 | }
40 |
41 | // Objects representing the message we are getting from IoT Devices
42 | class MessageBody
43 | {
44 | public Machine machine {get;set;}
45 | public Ambient ambient {get; set;}
46 | public string timeCreated {get; set;}
47 | }
48 | class Machine
49 | {
50 | public double temperature {get; set;}
51 | public double pressure {get; set;}
52 | }
53 | class Ambient
54 | {
55 | public double temperature {get; set;}
56 | public int humidity {get; set;}
57 | }
--------------------------------------------------------------------------------
/AzureIoTEdgeFunctions/TemperatureFilterFunction/EdgeHubTrigger-Csharp/run.csx:
--------------------------------------------------------------------------------
1 | #r "Microsoft.Azure.Devices.Client"
2 | #r "Newtonsoft.Json"
3 |
4 |
5 | using System.IO;
6 | using Microsoft.Azure.Devices.Client;
7 | using Newtonsoft.Json;
8 |
9 | public static async Task Run(Message messageReceived, IAsyncCollector output, TraceWriter log)
10 | {
11 | // Temperature Threshold
12 | const int temperatureThreshold = 25;
13 |
14 | byte[] messageBytes = messageReceived.GetBytes();
15 | var messageString = System.Text.Encoding.UTF8.GetString(messageBytes);
16 |
17 | if (!string.IsNullOrEmpty(messageString))
18 | {
19 | // Get the body of the message and deserialize it
20 | var messageBody = JsonConvert.DeserializeObject(messageString);
21 |
22 | // Check temperature value
23 | if (messageBody != null && messageBody.machine.temperature > temperatureThreshold)
24 | {
25 | // We will send the message to the output as the temperature value is greater than the threashold
26 | var filteredMessage = new Message(messageBytes);
27 | // We need to copy the properties of the original message into the new Message object
28 | foreach (KeyValuePair prop in messageReceived.Properties)
29 | {
30 | filteredMessage.Properties.Add(prop.Key, prop.Value);
31 | }
32 | // We are adding a new property to the message to indicate it is a temperature alert
33 | filteredMessage.Properties.Add("MessageType", "Alert");
34 | // Send the message
35 | await output.AddAsync(filteredMessage);
36 | log.Info("Received and transferred a message with temperature above the threshold");
37 | }
38 | }
39 | }
40 |
41 | // Objects representing messages we are getting from IoT Devices
42 | class MessageBody
43 | {
44 | public Machine machine {get;set;}
45 | public Ambient ambient {get; set;}
46 | public string timeCreated {get; set;}
47 | }
48 | class Machine
49 | {
50 | public double temperature {get; set;}
51 | public double pressure {get; set;}
52 | }
53 | class Ambient
54 | {
55 | public double temperature {get; set;}
56 | public int humidity {get; set;}
57 | }
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to [project-title]
2 |
3 | This project welcomes contributions and suggestions. Most contributions require you to agree to a
4 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
5 | the rights to use your contribution. For details, visit https://cla.microsoft.com.
6 |
7 | When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
8 | a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
9 | provided by the bot. You will only need to do this once across all repos using our CLA.
10 |
11 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
12 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
13 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
14 |
15 | - [Code of Conduct](#coc)
16 | - [Issues and Bugs](#issue)
17 | - [Feature Requests](#feature)
18 | - [Submission Guidelines](#submit)
19 |
20 | ## Code of Conduct
21 | Help us keep this project open and inclusive. Please read and follow our [Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
22 |
23 | ## Found an Issue?
24 | If you find a bug in the source code or a mistake in the documentation, you can help us by
25 | [submitting an issue](#submit-issue) to the GitHub Repository. Even better, you can
26 | [submit a Pull Request](#submit-pr) with a fix.
27 |
28 | ## Want a Feature?
29 | You can *request* a new feature by [submitting an issue](#submit-issue) to the GitHub
30 | Repository. If you would like to *implement* a new feature, please submit an issue with
31 | a proposal for your work first, to be sure that we can use it.
32 |
33 | * **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr).
34 |
35 | ## Submission Guidelines
36 |
37 | ### Submitting an Issue
38 | Before you submit an issue, search the archive, maybe your question was already answered.
39 |
40 | If your issue appears to be a bug, and hasn't been reported, open a new issue.
41 | Help us to maximize the effort we can spend fixing issues and adding new
42 | features, by not reporting duplicate issues. Providing the following information will increase the
43 | chances of your issue being dealt with quickly:
44 |
45 | * **Overview of the Issue** - if an error is being thrown a non-minified stack trace helps
46 | * **Version** - what version is affected (e.g. 0.1.2)
47 | * **Motivation for or Use Case** - explain what are you trying to do and why the current behavior is a bug for you
48 | * **Browsers and Operating System** - is this a problem with all browsers?
49 | * **Reproduce the Error** - provide a live example or a unambiguous set of steps
50 | * **Related Issues** - has a similar issue been reported before?
51 | * **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be
52 | causing the problem (line of code or commit)
53 |
54 | You can file new issues by providing the above information at the corresponding repository's issues link: https://github.com/[organization-name]/[repository-name]/issues/new].
55 |
56 | ### Submitting a Pull Request (PR)
57 | Before you submit your Pull Request (PR) consider the following guidelines:
58 |
59 | * Search the repository (https://github.com/[organization-name]/[repository-name]/pulls) for an open or closed PR
60 | that relates to your submission. You don't want to duplicate effort.
61 |
62 | * Make your changes in a new git fork:
63 |
64 | * Commit your changes using a descriptive commit message
65 | * Push your fork to GitHub:
66 | * In GitHub, create a pull request
67 | * If we suggest changes then:
68 | * Make the required updates.
69 | * Rebase your fork and force push to your GitHub repository (this will update your Pull Request):
70 |
71 | ```shell
72 | git rebase master -i
73 | git push -f
74 | ```
75 |
76 | That's it! Thank you for your contribution!
77 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # MSTest test Results
33 | [Tt]est[Rr]esult*/
34 | [Bb]uild[Ll]og.*
35 |
36 | # NUNIT
37 | *.VisualState.xml
38 | TestResult.xml
39 |
40 | # Build Results of an ATL Project
41 | [Dd]ebugPS/
42 | [Rr]eleasePS/
43 | dlldata.c
44 |
45 | # .NET Core
46 | project.lock.json
47 | project.fragment.lock.json
48 | artifacts/
49 | **/Properties/launchSettings.json
50 |
51 | *_i.c
52 | *_p.c
53 | *_i.h
54 | *.ilk
55 | *.meta
56 | *.obj
57 | *.pch
58 | *.pdb
59 | *.pgc
60 | *.pgd
61 | *.rsp
62 | *.sbr
63 | *.tlb
64 | *.tli
65 | *.tlh
66 | *.tmp
67 | *.tmp_proj
68 | *.log
69 | *.vspscc
70 | *.vssscc
71 | .builds
72 | *.pidb
73 | *.svclog
74 | *.scc
75 |
76 | # Chutzpah Test files
77 | _Chutzpah*
78 |
79 | # Visual C++ cache files
80 | ipch/
81 | *.aps
82 | *.ncb
83 | *.opendb
84 | *.opensdf
85 | *.sdf
86 | *.cachefile
87 | *.VC.db
88 | *.VC.VC.opendb
89 |
90 | # Visual Studio profiler
91 | *.psess
92 | *.vsp
93 | *.vspx
94 | *.sap
95 |
96 | # TFS 2012 Local Workspace
97 | $tf/
98 |
99 | # Guidance Automation Toolkit
100 | *.gpState
101 |
102 | # ReSharper is a .NET coding add-in
103 | _ReSharper*/
104 | *.[Rr]e[Ss]harper
105 | *.DotSettings.user
106 |
107 | # JustCode is a .NET coding add-in
108 | .JustCode
109 |
110 | # TeamCity is a build add-in
111 | _TeamCity*
112 |
113 | # DotCover is a Code Coverage Tool
114 | *.dotCover
115 |
116 | # Visual Studio code coverage results
117 | *.coverage
118 | *.coveragexml
119 |
120 | # NCrunch
121 | _NCrunch_*
122 | .*crunch*.local.xml
123 | nCrunchTemp_*
124 |
125 | # MightyMoose
126 | *.mm.*
127 | AutoTest.Net/
128 |
129 | # Web workbench (sass)
130 | .sass-cache/
131 |
132 | # Installshield output folder
133 | [Ee]xpress/
134 |
135 | # DocProject is a documentation generator add-in
136 | DocProject/buildhelp/
137 | DocProject/Help/*.HxT
138 | DocProject/Help/*.HxC
139 | DocProject/Help/*.hhc
140 | DocProject/Help/*.hhk
141 | DocProject/Help/*.hhp
142 | DocProject/Help/Html2
143 | DocProject/Help/html
144 |
145 | # Click-Once directory
146 | publish/
147 |
148 | # Publish Web Output
149 | *.[Pp]ublish.xml
150 | *.azurePubxml
151 | # TODO: Comment the next line if you want to checkin your web deploy settings
152 | # but database connection strings (with potential passwords) will be unencrypted
153 | *.pubxml
154 | *.publishproj
155 |
156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
157 | # checkin your Azure Web App publish settings, but sensitive information contained
158 | # in these scripts will be unencrypted
159 | PublishScripts/
160 |
161 | # NuGet Packages
162 | *.nupkg
163 | # The packages folder can be ignored because of Package Restore
164 | **/packages/*
165 | # except build/, which is used as an MSBuild target.
166 | !**/packages/build/
167 | # Uncomment if necessary however generally it will be regenerated when needed
168 | #!**/packages/repositories.config
169 | # NuGet v3's project.json files produces more ignorable files
170 | *.nuget.props
171 | *.nuget.targets
172 |
173 | # Microsoft Azure Build Output
174 | csx/
175 | *.build.csdef
176 |
177 | # Microsoft Azure Emulator
178 | ecf/
179 | rcf/
180 |
181 | # Windows Store app package directories and files
182 | AppPackages/
183 | BundleArtifacts/
184 | Package.StoreAssociation.xml
185 | _pkginfo.txt
186 |
187 | # Visual Studio cache files
188 | # files ending in .cache can be ignored
189 | *.[Cc]ache
190 | # but keep track of directories ending in .cache
191 | !*.[Cc]ache/
192 |
193 | # Others
194 | ClientBin/
195 | ~$*
196 | *~
197 | *.dbmdl
198 | *.dbproj.schemaview
199 | *.jfm
200 | *.pfx
201 | *.publishsettings
202 | orleans.codegen.cs
203 |
204 | # Since there are multiple workflows, uncomment next line to ignore bower_components
205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
206 | #bower_components/
207 |
208 | # RIA/Silverlight projects
209 | Generated_Code/
210 |
211 | # Backup & report files from converting an old project file
212 | # to a newer Visual Studio version. Backup files are not needed,
213 | # because we have git ;-)
214 | _UpgradeReport_Files/
215 | Backup*/
216 | UpgradeLog*.XML
217 | UpgradeLog*.htm
218 |
219 | # SQL Server files
220 | *.mdf
221 | *.ldf
222 | *.ndf
223 |
224 | # Business Intelligence projects
225 | *.rdl.data
226 | *.bim.layout
227 | *.bim_*.settings
228 |
229 | # Microsoft Fakes
230 | FakesAssemblies/
231 |
232 | # GhostDoc plugin setting file
233 | *.GhostDoc.xml
234 |
235 | # Node.js Tools for Visual Studio
236 | .ntvs_analysis.dat
237 | node_modules/
238 |
239 | # Typescript v1 declaration files
240 | typings/
241 |
242 | # Visual Studio 6 build log
243 | *.plg
244 |
245 | # Visual Studio 6 workspace options file
246 | *.opt
247 |
248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
249 | *.vbw
250 |
251 | # Visual Studio LightSwitch build output
252 | **/*.HTMLClient/GeneratedArtifacts
253 | **/*.DesktopClient/GeneratedArtifacts
254 | **/*.DesktopClient/ModelManifest.xml
255 | **/*.Server/GeneratedArtifacts
256 | **/*.Server/ModelManifest.xml
257 | _Pvt_Extensions
258 |
259 | # Paket dependency manager
260 | .paket/paket.exe
261 | paket-files/
262 |
263 | # FAKE - F# Make
264 | .fake/
265 |
266 | # JetBrains Rider
267 | .idea/
268 | *.sln.iml
269 |
270 | # CodeRush
271 | .cr/
272 |
273 | # Python Tools for Visual Studio (PTVS)
274 | __pycache__/
275 | *.pyc
276 |
277 | # Cake - Uncomment if you are using it
278 | # tools/**
279 | # !tools/packages.config
280 |
281 | # Telerik's JustMock configuration file
282 | *.jmconfig
283 |
284 | # BizTalk build output
285 | *.btp.cs
286 | *.btm.cs
287 | *.odx.cs
288 | *.xsd.cs
289 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # IoT Alerting System Powered by Azure IoT Edge, Azure Functions and Time Series Insights
2 |
3 | ## Overview
4 |
5 | **IoT Alerting System** helps to monitor temperature and humidity conditions to inform responsible technicians for unexpected changes in the values using time-series analysis techniques.
6 |
7 | The project has the following architecture:
8 |
9 | 
10 |
11 | A group of devices is monitoring machine temperature and ambient humidity. On the devices are deployed **two functions - one for monitoring machine temperature and another one for ambient humidity**. The functions monitor if the values are above predefined threshold and if so, send the data to a **IoT Hub**. In the IoT Hub the data is filtered and it is sent to one of the configured **Event Hubs** to persist in **Time Series Insights** or pass it for aggregation by **Azure Stream Analytics**. If there are more events than predefined threshold in **Azure Stream Analytics** an **Azure Function** is triggered to send an email to the responsible technician.
12 |
13 | A walkthrough for building the project is provided below.
14 |
15 | ## Walkthrough
16 |
17 | ### 1. Setting Up Edge Devices
18 |
19 | Finding and using a real IoT device is sometimes difficult so we will use Azure VM instead.
20 |
21 | Please follow the instructions in this tutorial to [deploy Azure IoT Edge runtime on Azure Linux VM](https://docs.microsoft.com/en-us/azure/iot-edge/tutorial-simulate-device-linux "deploy Azure IoT Edge runtime on Azure Linux VM").
22 |
23 | ### 2. Azure Function on IoT Edge
24 |
25 | Next, we will deploy our first Azure Function that will be responsible for monitoring machines temperature. For that step follow the tutorial for [deploying Azure Function to IoT Edge](https://docs.microsoft.com/en-us/azure/iot-edge/tutorial-deploy-function "deploying Azure Function to IoT Edge"). You can find all required assets for this function in the folder [Temperature Filter Function](https://github.com/Azure-Samples/Azure-Functions-IoT-TimeSeries-Analytics/tree/master/AzureIoTEdgeFunctions/TemperatureFilterFunction "Temperature Filter Function")
26 |
27 | Source Code for functions:
28 |
29 | ```csharp
30 |
31 | #r "Microsoft.Azure.Devices.Client"
32 | #r "Newtonsoft.Json"
33 |
34 | using System.IO;
35 | using Microsoft.Azure.Devices.Client;
36 | using Newtonsoft.Json;
37 |
38 | public static async Task Run(Message messageReceived, IAsyncCollector output, TraceWriter log)
39 | {
40 | // Temperature Threshold
41 | const int temperatureThreshold = 25;
42 | byte[] messageBytes = messageReceived.GetBytes();
43 | var messageString = System.Text.Encoding.UTF8.GetString(messageBytes);
44 |
45 | if (!string.IsNullOrEmpty(messageString))
46 | {
47 | // Get the body of the message and deserialize it
48 | var messageBody = JsonConvert.DeserializeObject(messageString);
49 |
50 | // Check temperature value
51 | if (messageBody != null && messageBody.machine.temperature > temperatureThreshold)
52 | {
53 | // We will send the message to the output as the temperature value is greater than the threashold
54 | var filteredMessage = new Message(messageBytes);
55 | // We need to copy the properties of the original message into the new Message object
56 | foreach (KeyValuePair prop in messageReceived.Properties)
57 | {
58 | filteredMessage.Properties.Add(prop.Key, prop.Value);
59 | }
60 | // We are adding a new property to the message to indicate it is a temperature alert
61 | filteredMessage.Properties.Add("MessageType", "Alert");
62 | // Send the message
63 | await output.AddAsync(filteredMessage);
64 | log.Info("Received and transferred a message with temperature above the threshold");
65 | }
66 | }
67 | }
68 |
69 | ```
70 | The second function will monitor ambient humidity. You can follow the same tutorial for [deploying Azure Function to IoT Edge](https://docs.microsoft.com/en-us/azure/iot-edge/tutorial-deploy-function "deploying Azure Function to IoT Edge") with a few modifications:
71 |
72 | * In **Create a function project** change the function code to below. You can find all required assets for this function in the folder [Humidity Filter Function](https://github.com/Azure-Samples/Azure-Functions-IoT-TimeSeries-Analytics/tree/master/AzureIoTEdgeFunctions/HumidityFilterFunction "Humidity Filter Function"):
73 |
74 | ```csharp
75 | ...
76 |
77 | public static async Task Run(Message messageReceived, IAsyncCollector output, TraceWriter log)
78 | {
79 | // Threshold for Humidity
80 | const int humidityThreshold = 24;
81 |
82 | byte[] messageBytes = messageReceived.GetBytes();
83 | var messageString = System.Text.Encoding.UTF8.GetString(messageBytes);
84 |
85 | if (!string.IsNullOrEmpty(messageString))
86 | {
87 | ...
88 |
89 | // Check for humidity value
90 | if (messageBody != null && messageBody.ambient.humidity > humidityThreshold)
91 | {
92 | ...
93 |
94 | filteredMessage.Properties.Add("MessageType", "HumidityAlert");
95 | // Send the message
96 | await output.AddAsync(filteredMessage);
97 | log.Info("Received and transferred a message with ambient humidity above the threshold");
98 | }
99 | }
100 | }
101 |
102 | ```
103 |
104 |
105 | * Modify the IoT Hub routes to the following configuration:
106 |
107 | ```json
108 | {
109 | "routes": {
110 | "sensorToFilter": "FROM /messages/modules/tempSensor/outputs/temperatureOutput INTO BrokeredEndpoint(\"/modules/temperatureFilter/inputs/input1\")",
111 | "sensorToHumidityFilter": "FROM /messages/modules/tempSensor/outputs/temperatureOutput INTO BrokeredEndpoint(\"/modules/humidityFilter/inputs/input1\")",
112 | "filterToIoTHub": "FROM /messages/modules/temperatureFilter/outputs/* INTO $upstream",
113 | "humidityFilterToIoTHub": "FROM /messages/modules/humidityFilter/outputs/* INTO $upstream"
114 | }
115 | }
116 | ```
117 |
118 | ### 3. Configure IoT Hub
119 |
120 | Next, the connections to the 3 Event Hub instances need to be configured. These Event Hub instances will be responsible for getting the data from IoT Hub and passing it along for further processing.
121 |
122 | IoT Hub Endpoints will be defined for each of the Event Hubs as shown below:
123 |
124 | 
125 |
126 | Next, the rules for routing data to the correct IoT Hub instance are defined. The final configuration looks like:
127 |
128 | 
129 |
130 | Next configure the humidity route:
131 |
132 | 
133 |
134 | Two of the Event Hubs are connected to Stream Analytics Jobs that are aggregating the values and based on a predefined threshold trigger built using an Azure Function for sending an email.
135 |
136 | Below is the Azure Stream Analytics job for humidity:
137 |
138 | ```sql
139 | SELECT
140 | System.TimeStamp AS Time,
141 | COUNT(*) AS [Count]
142 | INTO
143 | humidityout
144 | FROM
145 | humidity TIMESTAMP BY TIMECREATED
146 | GROUP BY
147 | TumblingWindow(second, 180)
148 | HAVING
149 | [Count] >= 5
150 | ```
151 |
152 | Below is the Azure Stream Analytics job for temperature:
153 |
154 | ```sql
155 | SELECT
156 | System.TimeStamp AS Time,
157 | COUNT(*) AS [Count]
158 | INTO
159 | AlertOutput
160 | FROM
161 | temperature TIMESTAMP BY TIMECREATED
162 | GROUP BY
163 | TumblingWindow(second, 180)
164 | HAVING
165 | [Count] >= 5
166 | ```
167 |
168 | ### 4. Azure Functions for Alerting
169 |
170 | An email will be sent when there are:
171 | - More than 5 elevated temperature events within a 3 minute window.
172 | - More than 5 ambient humidity events within a 3 minute window.
173 |
174 | Azure Stream Analytics has first party integration with Azure Functions. Using Azure Function Runtime v2, follow these [steps](https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions "Configure Azure Function App to use runtime version 2") to configure your Function App. The code for the function is below:
175 |
176 | ```csharp
177 | #r "Newtonsoft.Json"
178 | #r "SendGrid"
179 |
180 | using System.Net;
181 | using Microsoft.AspNetCore.Mvc;
182 | using Microsoft.Extensions.Primitives;
183 | using Newtonsoft.Json;
184 | using SendGrid.Helpers.Mail;
185 | using System.Text;
186 |
187 | public async static Task Run(HttpRequest req, IAsyncCollector messages, TraceWriter log)
188 | {
189 | log.Info("SendGrid message");
190 | using (StreamReader reader = new StreamReader(req.Body, Encoding.UTF8))
191 | {
192 | var body = await reader.ReadToEndAsync();
193 | var message = new SendGridMessage();
194 | message.AddTo("technicians@iot.com");
195 | message.AddContent("text/html", body);
196 | message.SetFrom("iot@alert.com");
197 | message.SetSubject("[Alert] IoT Hub Notrtification");
198 | await messages.AddAsync(message);
199 | return (ActionResult)new OkObjectResult("The E-mail has been sent.");
200 | }
201 | }
202 | ```
203 |
204 | Configure the function in function.json file:
205 |
206 | ```json
207 | {
208 | "bindings": [
209 | {
210 | "authLevel": "function",
211 | "name": "req",
212 | "type": "httpTrigger",
213 | "direction": "in"
214 | },
215 | {
216 | "name": "$return",
217 | "type": "http",
218 | "direction": "out"
219 | },
220 | {
221 | "type": "sendGrid",
222 | "name": "messages",
223 | "apiKey": "SendGridAttribute.ApiKey",
224 | "direction": "out"
225 | }
226 | ],
227 | "disabled": false
228 | }
229 | ```
230 |
231 | This function requires that you set a SendGrid key using the App Setting property called "SendGridAttribute.ApiKey" inside the Function App. In the Azure portal you can create free account for SendGrid with 20 000 email per month.
232 |
233 | All the assets for the email function can be found [here](https://github.com/Azure-Samples/Azure-Functions-IoT-TimeSeries-Analytics/tree/master/AzureFunctions/HttpHumidityAlertV2 "Folder for Azure Function responsible for sending emails")
234 |
235 |
236 | ### 5. Analyzing Data with Time Series Insights
237 |
238 | IoT Hub sends all recieved events to an instance of Event Hub. This Event Hub is configured to be a source of data for a [Time Series Insights](https://azure.microsoft.com/en-us/services/time-series-insights/) instance:
239 |
240 | 
241 |
242 | Time Series Insights was built with IoT scenarios in mind. It combines familiar SQL syntax and powerful visualization capabilities in one product designed for massive data throughput.
243 |
244 | Time Series Insights automatically parses the data and shows a default graph for event count:
245 |
246 | 
247 |
248 | To configure multiple queries whose graphs can overlay:
249 |
250 | 
251 |
252 | This can be done by cloning a query and modifying it. But it is recommended to plot each query on separate part of dashboard for better visibility:
253 |
254 | 
255 |
256 | **Congratulations! You have just built complete IoT solution including edge logic, IoT Hub, alerting email functions and detailed data view powered by Time Series Insights!**
257 |
--------------------------------------------------------------------------------