The Internet of Things on AWS – Official Blog

Empowering operations: A scalable remote asset health monitoring solution

Looking for ways to monitor the health of industrial remote assets and create a centralized dashboard? Perhaps your remote industrial assets are connected or ready to connect to AWS, but you haven’t decided on how to present the data to operators and maintenance teams. Industrial remote assets are many and from different technological eras. Industrial customers need ways to equally visualize and monitor the status of those assets. Operation teams can then rely on a comprehensive dashboard and alerts to activate maintenance teams or remote actions, improving uptime and efficiency. In this blog post, you will learn how to use the data ingested to AWS IoT Core to enable field teams with a centralized Grafana dashboard and alerts table.

Overview

This blog will work with a simulated dataset, the dataset will represent 10 remote pumping stations. You will build the end-to-end solution and running deployment scripts from the AWS Command Line Interface (AWS CLI). The goal of this post is to show the step-by-step process of building a remote asset monitoring solution in AWS. We have built an architecture which is scalable, completely serverless, and composed of an IoT data ingestion service. We are using AWS IoT Core for ingestion and simulation, AWS IoT SiteWise for asset modeling, and Amazon Managed Grafana for a centralized dashboard and alerts. In addition, you will interact with Amazon Simple Notification Service (Amazon SNS), where alarms assigned to different subscribers.

Scalable Architecture for Remote Asset health monitoring solution

This is the scalable architecture you will build in this blog. (Note: the Amazon Elastic Compute Cloud (Amazon EC2) instance is a simulation environment only)

Prerequisites

An AWS account is required to setup and execute the steps in this blog, AWS service will be configured, and you must have the necessary Identity and Access Management (IAM) permission to do the following:

  • Setup of an Amazon EC2 instance through Cloud9 environment for the IoT Device Simulator. The Amazon EC2 instance must have a role associated, which allows administrator access to the following services:
    • AWS IoT Core
    • AWS IoT SiteWise
    • AWS Managed Grafana
    • Amazon SNS
  • Access to IAM to create a role (or pre-created role).
  • An email box for the notification subscription.
  • Work from a region which supports all the services pre-listed, we recommend us-east-1.

Getting the environment ready

Create AWS Cloud9 environment

  1. Log into the AWS Cloud9 console.
  2. Click Create environment.
  3. Enter the name IoT Simulator and click next.
  4. Select Create a new EC2 instance (direct access).
  5. Select Instance type t3.small.
  6. Select Amazon Linux 2 and click Next step.
  7. Click Create environment. The instance will start and the AWS Cloud9 environment will be ready for work. Note: You will execute commands from the AWS Cloud9 environment. Make sure the role attached to your Cloud9 provisioned instance has rights to execute AWS CLI commands for all services utilized in this blog. You can verify it from the Amazon EC2 console (go to  AWS Cloud9your environmentsselect IoT SimulatorView details → Click on instances in EC2. From EC2 select the AWS Cloud9 instance →  Actions →  Security → and Modify IAM role. At this point, you can check which is assigned to the instance, select a pre-created role or create a new one).
  8. This step will clone the scripts and sample files we created for this blog post. From the terminal run the following commands:
    git clone https://github.com/aws-samples/aws-iot-remote-asset-health-monitoring.git
    cd aws-iot-remote-asset-health-monitoring

    chmod +x bootstrap.sh
    ./bootstrap.sh

Start Simulator for AWS IoT Core ingestion

We have prepared a script to create the IoT Thing with the required resources for the simulation.

  1. Now execute the following commands:
    python create_thing.py
    nohup ./start.sh > iotconnection.log 2>&1 &
  2. Navigate to AWS IoT CoreTestMQTT test client
  3. Got to Subscribe to a topic, type # and click Subscribe. You will see messages arriving under Topic as below:
    The payload represents 10 pumping stations with different locations and anomalies. You will use part of the simulated values to build assets and dashboards.

Ingesting data into AWS IoT SiteWise

Creating IAM role for SiteWise ingestion rules

  1. Log into IAM (Identy Access managment)Roles and click Create Role
  2. Select Custom trust policy and paste the below JSON snippet, click Next.
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Principal": {
                    "Service": "iot.amazonaws.com"
                },
                "Action": "sts:AssumeRole"
            }
        ]
    }
  3. In Permissions search for SiteWise and select the policy AWSIoTSiteWiseFullAccess and click next.
  4. In Role Details, name the role with the following name “ iot_to_sitewise” and Create a Role.
  5. Click on View Role
  6. Copy and save the Role ARN, as you will need it to run the rule creation script.

Creating Rules to publish to AWS IoT SiteWise

You can find more on how to create IoT rules in AWS IoT Core Documentation and how to configure Actions to publish to AWS IoT SiteWise at AWS IoT SiteWise Documentation. In this blog, you will use the AWS CLI commands to create the rules from your AWS Cloud9 environment. We have prepared a python script which will create the rules using the previously created IAM role.

  1. Go to your AWS Cloud9 environment, from the ~/environment/aws-iot-remote-asset-health-monitoring directory. Now run the following command:
    python create_iotrules.py -r <the Role Arn here>
    This script creates the IoT rules to ingest the simulation data into AWS IoT SiteWise. (Note: The policy used for this demonstration is over permissive and shouldn’t be used in a production environment, for more information on scoping down policies check this AWS IoT policies overly permissive)
  2. Now navigate to AWS IoT CoreMessage RoutingRules
    You will see the rules at the console as Active as below.
  3. Now navigate to AWS IoT SiteWiseData streams
    AWS IoT SiteWise Data Streams is where ingested data, which is not yet assigned to an asset is automatically stored. For more information on Data Streams follow this link. Now verify the data arriving in AWS IoT SiteWise and being update periodically, you can also filter through all Alias prefix, use the /pumpingstation/{n} and All data streams to observe the data.

Asset model and Assets in AWS IoT SiteWise

Creating Asset Model

  1. Navigate to AWS IoT SiteWiseModels and click on Create model
  2. Configure your model as following, note that it is important to respect the syntax (including upper case and lower case, we recommend coping and pasting through this section) as that will influence on the auto asset generation.
    • Name: PumpingStation;
    • Description: This is the digital model representation of all pumping station
    • Measurement definitions:
      • name: Temperature; Unit:F; Data type: Integer
      • name: Humidity; Unit:%; Data type: Integer
      • name: Pressure; Unit: PSI; Data type: Integer
      • name: Vibration; Unit: Hz; Data type: Integer
      • name: Flow; Unit: m3/s; Data type: Integer
      • name: rpm; Unit: rpm; Data type: Integer
      • name: Voltage; Unit: V; Data type: Integer
      • name: Amperage; Unit: A; Data type: Integer
      • name: Fan; Unit: on/off; Data type: Boolean
      • name: Location; Unit: State; Data type: String
    • Finish by clicking on Create model, you will have your mode available on the list.
  3. Now your model will show as follows, copy the model ID and save it for the next steps, as we will need as an input for the creation scripts.

Creating Assets

  1. The next step is creating Assets from the model PumpingStation, for this step you will be running a python script which will automatically create 10 pumping station and associate the available Data stream to its match asset measurement. For more information on how to create Assets from Asset model refer to the AWS IoT SiteWise Documentation.
  2. Navigate back to the AWS Cloud9 environment.
  3. From the ~/environment/aws-iot-remote-asset-health-monitoring directory, execute the following commands:
    From your AWS Cloud9 terminal execute the following command:
    python create_iotsitewise_assets.py -i <your model Id here>
    The Script will run for about 5 minutes. You can watch the responses from the AWS CLI commands.
  4. Go to AWS IoT SiteWiseAssets and confirm that all pumping stations were created and are active as below.
  5. Select one of the Pumping Stations and go to measurements. Now confirm that your data is arriving in AWS IoT SiteWise and being updated periodically.

Creating Dashboards in Amazon Managed Grafana

Creating Amazon SNS notification

Before we work with Amazon Managed Grafana, we recommend that you create and configure the notification channel. Amazon Managed Grafana can directly send notifications to Amazon SNS given the ARN for the Amazon SNS Topic.

  1. Navigate to Amazon SNS (amazon.com) Topics and click on Create Topic
    Select Standard, Name it : All_Pumping_Stations
  2. Go to Access policy, and Select Everyone in both options, publish and subscribe, and click Create.(Note: an over-permissive policy is not recommended beyond this simulation environment)
  3. Navigate to your newly create topic All_Pumping_Stations and click on Create subscription.
  4. Select Email, under Endpoint add your test email address, and click create subscription.
  5. The Subscription will show as Pending confirmation Status, within a minute you will receive a confirmation link in your test email, after accepting it the subscription is ready. (shown as below).
  6. Copy the ARN for the topic and save it for later on your clipboard.

Creating Amazon Managed Grafana workspace

    1. Navigate to AWS Grafana Console , click on Create workspace
    2. Name: all_pumping_stations, Click next
    3. Select AWS Single Sign-On (If AWS Single Sign-On is not enabled, you must enable it, follow this link for instructions. Amazon Managed Grafana also supports SAML authentication, you can find more information here)
    4. Select Service managed, Click next
    5. Select Current account
    6. Under Data sources select AWS IoT SiteWise
    7. Under Notification channels, select Amazon SNS, Click Next
    8. Click Create Workspace
    9. Once your workspace is ready status under Authentication, you must assign a new user to your workspace. Click on Assign new user or group.
    10. If you have enable AWS Single Sign-On (SSO), you will then see a user or group, select it and click Assign User, then Select the same user or group, and go to Actions and make Admin
      Navigate back to AWS Grafana ConsoleAll workspacesall_pumping_stations, look for the Grafana workspace URL and click on it.
    11. A new tab will open and you see the login page as below. Log in and you are ready for the next step.

Configuring Amazon Managed Grafana notification channel

  1. In your Grafana workspace Navigate to Alerting Notification channels.
  2. Click on Add Channel.
    • Name : all_pumping_stations
    • Type : AWS SNS
    • Topic : <Paste the topic ARN from the previous section>. If you need to locate it again, Navigate to Simple Notification ServiceTopics all_pumping_stations, the ARN is located under details.
    • Auth Provider: Workspace IAM Role
    • Message Body Format: Text
    • Under Notification setting, select Default
    • Click Save. (Optionally, you can also click on the test to make sure your notification channel is correctly setup)

Configuring Grafana Data sources

  1. In your Grafana workspace Navigate to ConfigurationData Sources
  2. Click on Add data Source.
  3. Search for AWS IoT SiteWise and click on it
  4. Under Connection Details keep the default except for Default Region. Select the region where you built your SiteWise assets.
  5. Click Save & test

Creating Dashboards in Amazon Managed Grafana

For the monitoring dashboards and alerts we have created a python script which will automatically deploy one dashboard for each pumping station.

  1. Navigate to AWS Grafana ConsoleWorkspacesall_pumping_stations
  2. Look for the Grafana workspace URL and copy the ID before .grafana, as shown below.
  3. Go to your AWS Cloud9 environment, from the ~/environment/aws-iot-remote-asset-health-monitoring directory, run the following command:
    python create_grafana_dashboards.py -i <your workspace ID here> -r <your Model ID here>
  4. After the script is finished, navigate to the Grafana WorkspaceDashboardsBrowse, confirm that all dashboards have been successfully created and the simulation data is being ingested as shown below.
  5. Navigate to pumpingstation9/Status/Time_series dashboard and confirm the temperature is high, and the alert is active. For this simulation data set, the Pumping Station 9 presents the anomalous temperature and triggers an alert to the notification channel every 2 minutes. Optionally navigate to any other pumping station dashboard and compare them.
  6. Now navigate to AlertingAlert rules, and check that all the other alerts are healthy.

Conclusion

In this blog, you learned how to use AWS IoT SiteWise to collect and organize data from remote industrial assets. And with Amazon Managed Grafana operators can notified about key issues, with alarms and alerts delivered to them when equipment behaves anomalously or operates outside of expected operating limits. With the solution described in this blog, you can implement a reliable and scalable field-to-cloud Industrial IoT (IIoT) solution on AWS for use cases such as asset remote asset monitoring. Also, the architecture example provides further connectivity with other AWS services, allowing integration with automation services and data sources.

Clean Up

Be sure to clean up the work in this blog to avoid charges. Delete the following resources when finished in this order:

  1. AWS Manage Grafana → Workspace, and delete the workspace created for the work.
  2. Simple Notification Service → Topic, and delete the topic created for the work.
  3. AWS IoT SiteWise → Assets and delete Assets.
  4. AWS IoT SiteWise → Data Streams, and delete all data streams related to the work.
  5. AWS IoT SiteWise → Model, and delete the Model created for the work.
  6. AWS IoT → Message routing → Rules, and Delete rules created for the role.
  7. AWS Cloud9 → Your environments and delete the environment.

About the Authors

Yuri Chamarelli is an Amazon Web Services Solution Architect (AWS) based out of the United States. As an IoT specialist, he focuses on helping customers build with AWS IoT and accomplish their business outcomes. Yuri is a Controls engineer with over 10 years of experience in IT/OT systems and has helped several customers with Industrial transformation and Industrial automation projects throughout many industries.

 

 

 

Seibou Gounteni is a Specialist Solutions Architect for IoT at Amazon Web Services (AWS). He helps customers architect, develop, operate scalable and highly innovative solutions using the depth and breadth of AWS platform capabilities to deliver measurable business outcomes. Seibou is an instrumentation engineer with over 10 years of experience in digital platforms, smart manufacturing, energy management, industrial automation and IT/OT systems across a diverse range of industries.