17.9 C
London
Friday, September 6, 2024

Tips on how to synchronize AWS IoT SiteWise property and information throughout AWS accounts


Introduction

As industrial and manufacturing firms embark on their digital transformation journey , they need to leverage superior applied sciences for elevated effectivity, productiveness, high quality management, flexibility, value discount, provide chain optimization, and aggressive benefit within the quickly evolving digital period. AWS clients within the manufacturing and industrial house, more and more leverage AWS IoT SiteWise to modernize their industrial information technique and unlock the complete potential of their operational expertise. AWS IoT SiteWise empowers you to effectively gather, retailer, arrange, and monitor information from industrial tools at scale.It additionally allows you to derive actionable insights, optimize operations, and drive innovation by way of data-driven choices.

The journey usually begins with a Proof of Worth (PoV) case examine in a improvement atmosphere. This method offers you with a chance to discover how information assortment and asset modelling with an answer that features AWS IoT SiteWise will help. As you turn out to be snug with the answer, you might scale extra property or amenities right into a manufacturing atmosphere from staging over time. This weblog publish offers an summary of the structure and pattern code emigrate the property and information in AWS IoT SiteWise from one deployment to a different, whereas making certain information integrity and minimizing operational overhead.

Getting began with AWS IoT SiteWise

Through the PoV part, you determine information ingestion pipelines to stream close to real-time sensor information from on-premises information historians, or OPC-UA servers, into AWS IoT SiteWise. You possibly can create asset fashions that digitally symbolize your industrial tools to seize the asset hierarchy and demanding metadata inside a single facility or throughout a number of amenities. AWS IoT SiteWise offers API operations that can assist you import your asset mannequin information (metadata) from various methods in bulk, reminiscent of course of historians in AWS IoT SiteWise at scale. Moreover, you possibly can outline widespread industrial efficiency indicators (KPIs) utilizing the built-in library of operators and features out there in AWS IoT SiteWise. You may as well create customized metrics which are triggered by tools information on arrival or computed at user-defined intervals.

Establishing a number of non-production environments on a manufacturing facility flooring may be difficult because of legacy networking and strict laws related to the plant flooring – along with delays in {hardware} procurement. Many shoppers transition the identical {hardware} from non-production to manufacturing by designating and certifying the {hardware} for manufacturing use after validation completes.

To speed up and streamline the deployment course of, you want a well-defined method emigrate their IoT SiteWise assets (asset, hierarchies, metrics, transforms, time-series, and metadata) between AWS accounts as a part of your customary DevOps practices.

AWS IoT SiteWise shops information throughout storage tiers that may help coaching machine studying (ML) fashions or historic information evaluation in manufacturing. By this blogpost we offer an overview about migrate the asset fashions, asset hierarchies, and historic time sequence information from the event atmosphere to the staging and manufacturing environments which are hosted on AWS.

Answer Walkthrough

Let’s start by discussing the technical elements of migrating AWS IoT SiteWise assets and information between AWS accounts. We offer a step-by-step information on export and import asset fashions and hierarchies utilizing IoT SiteWise APIs. We additionally talk about switch historic time sequence information utilizing Amazon Easy Storage Service (Amazon S3) and the AWS IoT SiteWise BatchPutAssetPropertyValue API operation.

By following this method, you possibly can promote your AWS IoT SiteWise setup and information by way of the event lifecycle as you scale your industrial IoT functions into manufacturing. The next is an summary of the method:

  1.   AWS IoT Sitewise metadata switch:
    1.  Export AWS IoT SiteWise fashions and property from one AWS account (improvement account) by working a bulk export job. You should use filters to export the fashions and/or property.
    2.  Import the exported fashions and/or property right into a second AWS account (staging account) by working a bulk import job. The import recordsdata should observe the AWS IoT SiteWise metadata switch job schema.
  2. AWS IoT Sitewise telemetry information switch
    1. Use the next API operations emigrate telemetry information throughout accounts:
      1. BatchGetAssetPropertyValueHistory retrieves historic telemetry information from the improvement account.
      2. CreateBulkImportJob ingests the retrieved telemetry information into the staging account.

The information migration steps in our answer make the next assumptions:

  1. The staging account doesn’t have AWS IoT SiteWise property or fashions configured the place it makes use of the identical identify or hierarchy because the improvement account.
  2. You’ll replicate the AWS IoT SiteWise metadata from the improvement account to the staging account.
  3. You’ll transfer the AWS IoT SiteWise telemetry information from the improvement account to the staging account.

1: Migrate AWS IoT SiteWise fashions and property throughout AWS accounts

Figure 1: Architecture to migrate AWS IoT SiteWise metadata across AWS accounts

Determine 1: Structure emigrate AWS IoT SiteWise metadata throughout AWS accounts

AWS IoT SiteWise helps bulk operations with property and fashions. The metadata bulk operations assist to:

  1.  Export AWS IoT SiteWise fashions and property from the improvement account by working a bulk export job. You possibly can select what to export while you configure this job. For extra info, see Export metadata examples.
    1.  Export all property and asset fashions, and filter your property and asset fashions.
    2. Export property and filter your property.
    3. Export asset fashions and filter your asset fashions.
  2. Import AWS IoT SiteWise fashions and property into the staging account by working a bulk import job. Just like the export job, you possibly can select what to i­­mport. For extra info, see Import metadata examples.
    1. The import recordsdata observe a particular format. For extra info, see AWS IoT SiteWise metadata switch job schema.

2: Migrate AWS IoT SiteWise telemetry information throughout AWS accounts

AWS IoT SiteWise helps ingesting excessive quantity historic information utilizing the CreateBulkImportJob API operation emigrate telemetry information from the improvement account to the staging account.

Figure 2: Architecture to migrate AWS IoT SiteWise telemetry data across AWS accounts

Determine 2: Structure emigrate AWS IoT SiteWise telemetry information throughout AWS accounts

2.1 Retrieve information from the improvement account utilizing BatchGetAssetPropertyValueHistory

AWS IoT SiteWise has information and SQL API operations to retrieve telemetry outcomes. You should use the export file from the Export AWS IoT SiteWise fashions and property by working a bulk export job step to get an inventory of AWS IoT SiteWise asset IDs and property IDs to question utilizing the BatchGetAssetPropertyValueHistory API operation. The next pattern code demonstrates retrieving information for the final two days:

import boto3
import csv
import time
import uuid
"""
Connect with the IoT SiteWise API and outline the property and properties 
to retrieve information for.
"""
sitewise = boto3.shopper('iotsitewise')
# restrict for less than 10 AssetIds/PropertyIDs/EntryIDs per API name
asset_ids = ['a1','a2','a3'] 
property_ids = ['b1','b2','b3']

"""
Get the beginning and finish timestamps for the date vary of historic information
to retrieve. At the moment set to the final 2 days.
""" 
# Convert present time to Unix timestamp (seconds since epoch)
end_time = int(time.time()) 
# Begin date 2 days in the past
start_time = end_time - 2*24*60*60
"""
Generate an inventory of entries to retrieve property worth historical past.
Loops by way of the asset_ids and property_ids lists, zipping them 
collectively to generate a singular entry for every asset-property pair.
Every entry incorporates a UUID for the entryId, the corresponding 
assetId and propertyId, and the beginning and finish timestamps for 
the date vary of historic information.
"""
entries = []
for asset_id, property_id in zip(asset_ids, property_ids):
  entry = {
    'entryId': str(uuid.uuid4()),
    'assetId': asset_id, 
    'propertyId': property_id,
    'startDate': start_time,
    'endDate': end_time,
    'qualities': [ "GOOD" ],
  }
  entries.append(entry)
"""
Generate entries dictionary to map entry IDs to the complete entry information 
for retrieving property values by entry ID.
"""
entries_dict = {entry['entryId']: entry for entry in entries}
"""
The snippet under retrieves asset property worth historical past from AWS IoT SiteWise utilizing the
`batch_get_asset_property_value_history` API name. The retrieved information is then
processed and written to a CSV file named 'values.csv'.
The script handles pagination through the use of the `nextToken` parameter to fetch
subsequent pages of knowledge. As soon as all information has been retrieved, the script
exits the loop and closes the CSV file.
"""
token = None
with open('values.csv', 'w') as f:
  author = csv.author(f)
  whereas True:
    """
    Make API name, passing entries and token if on subsequent name.
    """
    if not token:
      property_history = sitewise.batch_get_asset_property_value_history(
          entries=entries
      )
    else:
      property_history = sitewise.batch_get_asset_property_value_history(
          entries=entries,
          nextToken=token
      )
    """
    Course of success entries, extracting values into an inventory of dicts.
    """
    for entry in property_history['successEntries']:
        entry_id = entry['entryId']
        asset_id = entries_dict[entry_id]['assetId']
        property_id = entries_dict[entry_id]['propertyId']
        for history_values in entry['assetPropertyValueHistory']:
          value_dict = history_values.get('worth')
          values_dict = {
            'ASSET_ID': asset_id,
            'PROPERTY_ID': property_id,
            'DATA_TYPE': str(listing(value_dict.keys())[0]).higher().substitute("VALUE", ""),
            'TIMESTAMP_SECONDS': history_values['timestamp']['timeInSeconds'],
            'TIMESTAMP_NANO_OFFSET': history_values['timestamp']['offsetInNanos'],
            'QUALITY': 'GOOD',
            'VALUE': value_dict[list(value_dict.keys())[0]],
          }
          author.writerow(listing(values_dict.values()))
    """
    Verify for subsequent token and break when pagination is full.
    """  
    if 'nextToken' in property_history:
      token = property_history['nextToken']
    else:
      break

2.2 Ingest information to the staging account utilizing CreateBulkImportJob

Use the values.csv file to import information into AWS IoT SiteWise utilizing the CreateBulkImportJob API operation. Outline the next parameters whilst you create an import job utilizing CreateBulkImportJob. For a code pattern, see CreateBulkImportJob within the AWS documentation.

  1. Substitute the adaptive-ingestion-flag with true or false. For this train, set the worth to true.
    1. By setting the worth to true, the majority import job does the next:
      1. Ingests new information into AWS IoT SiteWise.
      2. Calculates metrics and transforms, and helps notifications for information with a time stamp that’s inside seven days.
    2.  In case you have been to set the worth to false, the majority import job ingests historic information into AWS IoT SiteWise.
  2. Substitute the delete-files-after-import-flag with true to delete the info from the Amazon S3 information bucket after ingesting into AWS IoT SiteWise heat tier storage. For extra info, see Create a bulk import job (AWS CLI).

Clear Up

After you validate the leads to the staging account, you possibly can delete the info from the improvement account utilizing AWS IoT SiteWise DeleteAsset and DeleteAssetModel API operations. Alternatively, it’s possible you’ll proceed to make use of the improvement account to proceed different improvement and testing actions with the historic information.

Conclusion

On this weblog publish, we addressed the problem industrial clients face when scaling their AWS IoT SiteWise deployments. We mentioned transferring from PoV to manufacturing throughout a number of vegetation and manufacturing strains and the way AWS IoT SiteWise addresses these challenges. Migrating metadata (reminiscent of asset fashions, asset/enterprise hierarchies, and historic telemetry information) between AWS accounts ensures constant information context. It additionally helps selling Industrial IoT property and information by way of the event lifecycle. For added particulars please see Bulk operations with property and fashions.

Creator biographies

JoysonLewis.jpg

Joyson Neville Lewis

Joyson Neville Lewis is a Sr. IoT Information Architect with AWS Skilled Companies. Joyson labored as a Software program/Information engineer earlier than diving into the Conversational AI and Industrial IoT house. He assists AWS clients to materialize their AI visions utilizing Voice Assistant/Chatbot and IoT options.

Anish Kunduru.jpg

Anish Kunduru

Anish Kunduru is an IoT Information Architect with AWS Skilled Companies. Anish leverages his background in stream processing, R&D, and Industrial IoT to help AWS clients scale prototypes to production-ready software program.

Ashok Padmanabhan.jpg

Ashok Padmanabhan

Ashok Padmanabhan is a Sr. IoT Information Architect with AWS Skilled Companies. Ashok primarily works with Manufacturing and Automotive to design and construct Trade 4.0 options.

Avik Ghosh.jpg

Avik Ghosh

Avik is a Senior Product Supervisor on the AWS Industrial IoT workforce, specializing in the AWS IoT SiteWise service. With over 18 years of expertise in expertise innovation and product supply, he makes a speciality of Industrial IoT, MES, Historian, and large-scale Trade 4.0 options. Avik contributes to the conceptualization, analysis, definition, and validation of AWS IoT service choices.

Latest news
Related news

LEAVE A REPLY

Please enter your comment!
Please enter your name here