- 最新
- 投票最多
- 评论最多
I believe there is no direct integration, but you can do live data export from Monitron into an Amazon Kinesis data stream. From this stream, you can use AWS Lambda to process the data and push it into AWS IoT SiteWise.
Hi, Thanks for your suggestion, so I started doing that, but it is not working. Here is what I did hopefully some one can help me resolve the issue with it.
I started by defining requirements for lambda function.
I started with Live data export in Monitron and created "on demand" Kinesis Data Stream to be used for lambda trigger.
Then I created a Role for Lambda, I added these permission: AWSIoTSiteWiseFullAccess, AWSIoTSiteWiseMonitorPortalAccess, AWSKeyManagementServicePowerUser, AWSLambdaKinesisExecutionRole.
Then I created the python Lambda function as the following:
import json
import base64
import uuid
import time
import boto3
def map_sitewise_data(kinesis_data):
"""Map incoming Kinesis data into Sitewise data objects"""
data = json.loads(kinesis_data)
return {
'value': {
'doubleValue': data['Temperature']
},
'timestamp': {
'timeInSeconds': int(time.time()),
'offsetInNanos': 0
},
'quality': 'GOOD'
}
def lambda_handler(event, context):
# Incoming event is Kinesis data from Monitron
print(event)
# List used to send data to Sitewise
temp_list = []
# Loop through the list of records
for record in event['Records']:
# Kinesis data is base64 encoded so decode here
payload = base64.b64decode(record['kinesis']['data'])
print("Decoded payload: " + str(payload))
# Map data for Sitewise
mapped_data = map_sitewise_data(payload)
# Append mapped data to list
temp_list.append(mapped_data)
# Sitewise section
# Use temp_list as the "entries" value
sitewise = boto3.client('iotsitewise')
try:
response = sitewise.batch_put_asset_property_value(
entries=[
{
'entryId': str(uuid.uuid4()),
'propertyAlias': 'Monitron_VTS_1/Temperature',
'propertyValues': [mapped_data]
},
]
)
print(response)
except Exception as error:
# Log errors
print(error)
It is still not working and I don't see any streams in SiteWise. I appreciate any suggestions.
相关内容
- 已提问 2 个月前
- AWS 官方已更新 2 年前
- AWS 官方已更新 2 年前
- AWS 官方已更新 3 年前
Hi Maryam, looking at the code I see you are referring values that don't exist within the event coming from Monitron. For example within the function
map_sitewise_data
to read the temperature you must first check ifdata['eventType'] == 'measurement'
and then get the temperature reading fromdata['eventPayload']['features']['temperature']
. You can view the data schema form the CloudWatch logs when you printed them out or view them from the documentationThere is also an AWS Sample repository with a working example of processing Monitron events for SiteWise in a Lambda function.
Thank you so much Gary, it worked, Thanks a lot.