Migration procedure for Amazon IoT SiteWise alarms in Amazon IoT Events - Amazon IoT Events
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

End of support notice: On May 20, 2026, Amazon end support for Amazon IoT Events. After May 20, 2026, you will no longer be able to access the Amazon IoT Events console or Amazon IoT Events resources. For more information, visit this Amazon IoT Events end of support.

Migration procedure for Amazon IoT SiteWise alarms in Amazon IoT Events

This section describes alternative solutions that deliver similar alarm functionality as you migrate away from Amazon IoT Events.

For Amazon IoT SiteWise properties that use Amazon IoT Events alarms, you can migrate to a solution using CloudWatch alarms. This approach provides robust monitoring capabilities with established SLAs and additional features like anomaly detection and grouped alarms.

Comparing architectures

The current Amazon IoT Events alarm configuration for Amazon IoT SiteWise properties requires creating AssetModelCompositeModels in the asset model, as described in Define external alarms in Amazon IoT SiteWise in the Amazon IoT SiteWise User Guide. Modifications to the new solution are typically managed through the Amazon IoT Events console.

The new solution provides alarm management by leveraging CloudWatch alarms. This approach uses Amazon IoT SiteWise notifications to publish property data points to Amazon IoT Core MQTT topics, which are then processed by a Lambda function. The function transforms these notifications into CloudWatch metrics, enabling alarm monitoring through CloudWatch's alarming framework.

Purpose Solution Differences

Data source – Property data from Amazon IoT SiteWise

Amazon IoT SiteWise MQTT notifications

Replaces direct IoT Events integration with MQTT notifications from Amazon IoT SiteWise properties

Data processing – Transforms property data

Lambda function

Processes Amazon IoT SiteWise property notifications and converts them to CloudWatch metrics

Alarm evaluation – Monitors metrics and triggers alarms

Amazon CloudWatch alarms

Replaces Amazon IoT Events alarms with CloudWatch alarms, offering additional features like anomaly detection

Integration – Connection with Amazon IoT SiteWise

Amazon IoT SiteWise external alarms

Optional capability to import CloudWatch alarms back into Amazon IoT SiteWise as external alarms

Step 1: Enable MQTT notifications on the asset property

If you are using Amazon IoT Events integrations for Amazon IoT SiteWise alarms, you can turn on MQTT notifications for each property to monitor.

  1. Follow the Configure alarms on assets in Amazon IoT SiteWise procedure until you each the step to Edit the asset model's properties.

  2. For each property to migrate, change the MQTT Notification status to ACTIVE.

    A screenshot showing the placement of the MQTT notification status dropdown in the Amazon IoT SiteWise console.
  3. Note the topic path to which the alarm publishes for each modified alarm attribute.

For more information, see the following documentation resources:

Step 2: Create an Amazon Lambda function

Create an Lambda function for reading the TQV array published by the MQTT topic and publish individual values to CloudWatch. We’ll use this Lambda function as a destination action to trigger in Amazon IoT Core Message Rules.

  1. Open the Amazon Lambda console.

  2. Choose Create function.

  3. Enter a name for the Function name.

  4. Select NodeJS 22.x as the Runtime.

  5. In the Change default execution role dropdown, choose Use existing role, and then select the IAM role that you created in earlier steps.

    Note

    This procedure assumes that you've already migrated your detector model. If you don't have an IAM role, see .

  6. Choose Create function.

  7. Paste in the following code snippet after replacing the hard coded constants.

    import json import boto3 from datetime import datetime # Initialize CloudWatch client cloudwatch = boto3.client('cloudwatch') def lambda_handler(message, context): try: # Parse the incoming IoT message # Extract relevant information asset_id = message['payload']['assetId'] property_id = message['payload']['propertyId'] # Process each value in the values array for value in message['payload']['values']: # Extract timestamp and value timestamp = datetime.fromtimestamp(value['timestamp']['timeInSeconds']) metric_value = value['value']['doubleValue'] quality = value.get('quality', 'UNKNOWN') # Publish to CloudWatch response = cloudwatch.put_metric_data( Namespace='IoTSiteWise/AssetMetrics', MetricData=[ { 'MetricName': f'Property_your-property-id', 'Value': metric_value, 'Timestamp': timestamp, 'Dimensions': [ { 'Name': 'AssetId', 'Value': 'your-asset-id' }, { 'Name': 'Quality', 'Value': quality } ] } ] ) return { 'statusCode': 200, 'body': json.dumps('Successfully published metrics to CloudWatch') } except Exception as e: print(f'Error processing message: {str(e)}') return { 'statusCode': 500, 'body': json.dumps(f'Error: {str(e)}') }

Step 3: Create Amazon IoT Core message routing rule

  • Follow the Tutorial: Republishing an MQTT message procedure entering the following information when prompted:

    1. Name message routing rule SiteWiseToCloudwatchAlarms.

    2. For the query, you can use the following:

      SELECT * FROM '$aws/sitewise/asset-models/your-asset-model-id/assets/your-asset-id/properties/your-property-id'
    3. In Rule actions, select the Lambda action to send the data generated from Amazon IoT SiteWise to CloudWatch. For example:

      A screenshot showing the rule action for the Lambda function.

Step 4: View CloudWatch metrics

As you ingest data to Amazon IoT SiteWise, the property selected earlier in Step 1: Enable MQTT notifications on the asset property, the routes data to the Lambda function we created in Step 2: Create an Amazon Lambda function. In this step, you can check to see the Lambda sending your metrics to CloudWatch.

  1. Open the CloudWatch Amazon Web Services Management Console.

  2. In the left navigation, choose Metrics, then All metrics.

  3. Choose an alarm's URL to open it.

  4. Under the Source tab, the CloudWatch output looks similar to this example. This source information confirms that the metric data is feeding into CloudWatch.

    { "view": "timeSeries", "stacked": false, "metrics": [ [ "IoTSiteWise/AssetMetrics", "Property_your-property-id-hash", "Quality", "GOOD", "AssetId", "your-asset-id-hash", { "id": "m1" } ] ], "region": "your-region" }

Step 5: Create CloudWatch alarms

Follow the Create a CloudWatch alarm based on a static threshold procedure in the Amazon CloudWatch User Guide to create alarms for each relevant metric.

Note

There are many options for alarm configuration in Amazon CloudWatch For more information on CloudWatch alarms, see Using Amazon CloudWatch alarms in the Amazon CloudWatch User Guide.

Step 6: (Optional) import the CloudWatch alarm into Amazon IoT SiteWise

You can configure CloudWatch alarms to send data back to Amazon IoT SiteWise using CloudWatch alarm actions and Lambda. This integration enables you to view alarm states and properties in the SiteWise Monitor portal.

  1. Configure the external alarm as a property in an asset model. For more information, see Define external alarms in Amazon IoT SiteWise in the Amazon IoT SiteWise User Guide.

  2. Create a Lambda function that uses the BatchPutAssetPropertyValue API found in the Amazon IoT SiteWise User Guide to send alarm data to Amazon IoT SiteWise.

  3. Set up CloudWatch alarm actions to invoke your Lambda function when alarm states change. For more information, see the Alarm actions section in the Amazon CloudWatch User Guide.