Use Time Series Insights to visualize telemetry sent from the Device Simulation solution accelerator

The Device Simulation solution accelerator lets you generate telemetry from simulated devices to test your IoT solutions. This how-to guide shows you how to visualize and analyze the simulated telemetry using a Time Series Insights environment.

Prerequisites

To follow the steps in this how-to guide, you need an active Azure subscription. If you don't have an Azure subscription, create a free account before you begin.

The steps in this how-to guide assume you've deployed the Device Simulation solution accelerator to your Azure subscription. If you haven't deployed Device Simulation yet, see Device Simulation deployment on GitHub.

This article assumes the name of your solution accelerator is contoso-simulation. Replace contoso-simulation with the name of your solution accelerator as you complete the following steps.

Use Azure Cloud Shell

Azure hosts Azure Cloud Shell, an interactive shell environment that you can use through your browser. You can use either Bash or PowerShell with Cloud Shell to work with Azure services. You can use the Cloud Shell preinstalled commands to run the code in this article without having to install anything on your local environment.

To start Azure Cloud Shell:

Option Example/Link
Select Try It in the upper-right corner of a code block. Selecting Try It doesn't automatically copy the code to Cloud Shell. Example of Try It for Azure Cloud Shell
Go to https://shell.azure.com, or select the Launch Cloud Shell button to open Cloud Shell in your browser. Launch Cloud Shell in a new window
Select the Cloud Shell button on the menu bar at the upper right in the Azure portal. Cloud Shell button in the Azure portal

To run the code in this article in Azure Cloud Shell:

  1. Start Cloud Shell.

  2. Select the Copy button on a code block to copy the code.

  3. Paste the code into the Cloud Shell session by selecting Ctrl+Shift+V on Windows and Linux or by selecting Cmd+Shift+V on macOS.

  4. Select Enter to run the code.

Create a consumer group

You need to create a dedicated consumer group in your IoT hub to stream telemetry to Time Series Insights. An event source in Time Series Insights should have the exclusive use of an IoT Hub consumer group.

The following steps use the Azure CLI in the Azure Cloud Shell to create the consumer group:

  1. The IoT hub is one of several resources created when you deployed the Device Simulation solution accelerator. Execute the following command find the name of your IoT hub - remember to use the name of your solution accelerator:

    az resource list --resource-group contoso-simulation -o table
    

    The IoT hub is the resource of type Microsoft.Devices/IotHubs.

  2. Add a consumer group called devicesimulationtsi to the hub. In the following command use the name of your hub and solution accelerator:

    az iot hub consumer-group create --hub-name contoso-simulation7d894 --name devicesimulationtsi --resource-group contoso-simulation
    

    You can now close the Azure Cloud Shell.

Create a new Time Series Insights environment

Azure Time Series Insights is a fully managed analytics, storage, and visualization service for managing IoT-scale time-series data in the cloud. To create a new Time Series Insights environment:

  1. Sign in to the Azure portal.

  2. Select Create a resource > Internet of Things > Time Series Insights:

    New Time Series Insights

  3. To create your Time Series Insights environment in the same resource group as your solution accelerator, use the values in the following table:

    Setting Value
    Environment Name The following screenshot uses the name Contoso-TSI. Choose your own unique name when you complete this step.
    Subscription Select your Azure subscription in the drop-down.
    Resource group contoso-simulation. Use the name of your solution accelerator.
    Location This example uses East US. Create your environment in the same region as your Device simulation accelerator.
    Sku S1
    Capacity 1

    Create Time Series Insights

    Note

    Adding the Time Series Insights environment to the same resource group as the solution accelerator means that it's deleted when you delete the solution accelerator.

  4. Click Create. It can take a few minutes for the environment to be created.

Create event source

Create a new event source to connect to your IoT hub. Use the consumer group you created in the previous steps. A Time Series Insights event source requires a dedicated consumer group not in use by another service.

  1. In the Azure portal, navigate to your new Time Series Environment.

  2. On the left, click Event Sources:

    View Event Sources

  3. Click Add:

    Add Event Source

  4. To configure your IoT hub as a new event source, use the values in the following table:

    Setting Value
    Event source Name The following screenshot uses the name contoso-iot-hub. Use your own unique name when you complete this step.
    Source IoT Hub
    Import option Use IoT Hub from available subscriptions
    Subscription ID Select your Azure subscription in the drop-down.
    Iot hub name contoso-simulation7d894. Use the name of your IoT hub from your Device Simulation solution accelerator.
    Iot hub policy name iothubowner
    Iot hub policy key This field is populated automatically.
    Iot hub consumer group devicesimulationtsi
    Event serialization format JSON
    Timestamp property name Leave blank

    Create Event Source

  5. Click Create.

Note

You can grant additional users access to the Time Series Insights explorer.

Start a simulation

Before you use Time Series Insights explorer, configure the Device Simulation solution accelerator to generate some telemetry. The following screenshot, shows a running simulation with 10 chiller devices:

Running device simulation

Time Series Insights explorer

The Time Series Insights explorer is a web app you can use to visualize your telemetry.

  1. In the Azure portal, select the Time Series Insights Overview tab.

  2. To open the Time Series Insights explorer web app, click Go to Environment:

    Time Series Insights explorer

  3. In the time selection panel, select Last 30 minutes from the quick times menu and click Search:

    Time Series Insights explorer search

  4. In the terms panel on the left, select temperature as the Measure and iothub-connection-device-id as the Split By value:

    Screenshot that shows the Time Series Insights "terms" panel, with the "Measure" and "Split by" values highlighted.

  5. Right-click on the chart and select Explore events:

    Time Series Insights explorer events

  6. The event data shows in a grid:

    Time Series Insights explorer table

  7. Click the perspective view button:

    Time Series Insights explorer perspective

  8. Click + to add a new query to the perspective:

    Time Series Insights explorer Add Query

  9. Select Last 30 minutes as the time span, Humidity as the Measure, and iothub-connection-device-id as the Split By value:

    Time Series Insights explorer query

  10. Click the perspective view button to view your device telemetry dashboard:

    Time Series Insights explorer dashboard

Clean up resources

If you plan to explore further, leave the solution accelerator deployed.

If you no longer need the solution accelerator, delete it from the Provisioned solutions page, by selecting it, and then clicking Delete Solution.

If you added the Time Series Insights environment to the solution accelerator's resource group, it is automatically deleted when you delete the solution accelerator. Otherwise you must manually remove the Time Series Insights environment from the Azure portal.

Next Steps

To learn more about how to explore and query data in the Time Series Insights explorer, see Azure Time Series Insights explorer.