

Amazon Monitron is no longer open to new customers. Existing customers can continue to use the service as normal. For capabilities similar to Amazon Monitron, see our [blog post](https://aws.amazon.com/blogs/machine-learning/maintain-access-and-consider-alternatives-for-amazon-monitron).

# Amazon Monitron Kinesis data export v2
Exporting your data with Kinesis v2

 You can export incoming measurement data and the corresponding inference results from Amazon Monitron and perform real-time analysis. Data export streams live data to Kinesis. 

**Topics**
+ [

## Exporting your data to a Kinesis stream
](#exporting-stream-procedure-v2)
+ [

## Editing live data export settings
](#edit-live-export-v2)
+ [

## Stopping a live data export
](#stop-kinesis-export-v2)
+ [

## Viewing data export errors
](#viewing-kinesis-export-errors-v2)
+ [

## Using server-side encryption for the Kinesis stream
](#data-export-server-side-encryption-v2)
+ [

# Monitoring with Amazon CloudWatch Logs
](data-export-cloudwatch-logs-v2.md)
+ [

# Storing exported data in Amazon S3
](kinesis-store-S3-v2.md)
+ [

# Processing data with Lambda
](data-export-lambda-v2.md)
+ [

# Understanding the v2 data export schema
](data-export-schema-v2.md)
+ [

# Migration from Kinesis v1 to v2
](migration-from-v1-to-v2.md)

## Exporting your data to a Kinesis stream


1. From your project's main page, near the bottom of the page, on the right, choose **Start live data export**.

1. Under **Select Kinesis data stream**, do one of the following:
   + Enter the name of an existing stream in the search box. Then skip to Step 5.
   +  Choose **Create a new data stream**. 

1. On the **Create data stream** page, under **Data stream configuration**, enter your data stream name.

1. Under Data stream capacity, choose your capacity mode:
   + If your data stream’s throughput requirements are unpredictable and variable, choose **On-demand**.
   + If you can reliably estimate the throughput requirements of your data stream, choose **Provisioned**. Then, under provisioned shards, enter the number of shards you want to create, or choose the **Shard estimator**.

1. Choose **Create data stream**.

## Editing live data export settings


To edit your live data export settings:

1. Open the Amazon Monitron console.

1. Choose **Projects** from the navigation pane.

1. If you have multiple projects, choose the project for which you want to edit the export settings.

1. From the main page for your project, under **Live data export**, from the **Actions** dropdown menu, choose **Edit live data export settings**.

## Stopping a live data export


1. Open the Amazon Monitron console.

1. Choose **Projects** from the navigation pane.

1. If you have multiple projects, choose the project for which you want to edit the export settings.

1. From the main page for your project, under **Live data export**, from the **Actions** dropdown menu, choose **Stop live data export**.

1. In the pop-up window, choose **Stop**.

## Viewing data export errors


To view the error messages in the CloudWatch Logs interface:
+ On the Amazon Monitron console, from the main page for your project, under **Live data export**, choose **CloudWatch log group**.

## Using server-side encryption for the Kinesis stream


You can enable server-side encryption for your Kinesis stream before setting up Kinesis data export. However, if server-side encryption is enabled after Kinesis data export is set up, Amazon Monitron will not be able to publish to the stream. That's because Amazon Monitron will not have permission to call [kms:GenerateDataKey](https://docs.aws.amazon.com/kms/latest/APIReference/API_GenerateDataKey.html) so that it can encrypt data sent to Kinesis.

To work around this, follow the instructions under [Editing live data export settings](#edit-live-export-v2), but without changing the configuration. This will associate the encryption you have set up with your export configuration.

# Monitoring with Amazon CloudWatch Logs


You can monitor Amazon Monitron live data export using Amazon CloudWatch Logs. When a measurement fails to export, Amazon Monitron will send a log event to your CloudWatch Logs. You can also set up a metric filter on the error log to generate metrics and set up alarms. An alarm can watch for certain thresholds and send notifications or take actions when those thresholds are met. For more information, see [the CloudWatch User Guide](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html).

Amazon Monitron sends log events to the /aws/monitron/data-export/\$1HASH\$1ID\$1 log group.

The log event has the following JSON format:

```
{
    "assetName": "string",
    "destination": "string",
    "errorCode": "string",
    "errorMessage": "string",
    "eventId": "string",
    "eventType": "string",
    "positionName": "string",
    "projectName": "string",
    "projectId": "string",
    "sensorId": "string",
    "gatewayId": "string",
    "siteName": "string",
    "timestamp": "string"
}
```

assetName  
+ The asset name displayed in the app
+ Type: String

destination  
+ The ARN of the Kinesis data stream
+ Type: String
+ Pattern: arn:aws:kinesis:\$1\$1REGION\$1\$1:\$1\$1AWS\$1ACCOUNT\$1ID\$1\$1:stream/\$1\$1STREAM\$1NAME\$1\$1 

errorCode  
+ The error code
+ Type: String
+ Valid Values: `INTERNAL_SEVER_ERROR | KINESIS_RESOURCE_NOT_FOUND | KINESIS_PROVISIONED_THROUGHPUT_EXCEEDED | KMS_ACCESS_DENIED | KMS_NOT_FOUND | KMS_DISABLED | KMS_INVALID_STATE | KMS_THROTTLING`

errorMessage  
+ The detailed error message
+ Type: String

eventId  
+ The unique event ID corresponding to each measurement export
+ Type: String

eventType  
+ The current event type
+ Type: String
+ Valid values: `measurement` ` | gatewayConnected` ` | gatewayDisconnected` ` | sensorConnected` ` | sensorDisconnected` ` | assetStateTransition` 

positionName  
+ The sensor position name displayed in the app
+ Type: String

projectName  
+ The project name displayed in the app and console
+ Type: String

  

projectID  
+ The unique project ID corresponding to the Amazon Monitron project
+ Type: String

sensorID  
+ The physical ID of the sensor from which the measurement is sent
+ Type: String

gatewayID  
+ The physical ID of the gateway used to transmit data to the Amazon Monitron service
+ Type: String

siteName  
+ The site name displayed in the app
+ Type: String

timestamp  
+ The timestamp when the measurement is received by the Amazon Monitron service in UTC
+ Type: String
+ Pattern: yyyy-mm-dd hh:mm:ss.SSS

# Storing exported data in Amazon S3


If you want to store your exported data in Amazon S3, use the following procedure.

**Topics**
+ [

## Configuring Kinesis manually in the console
](#kinesis-configure-console-v2)

## Configuring Kinesis manually in the console


1. Sign in to the AWS Management Console and open the Kinesis console at https://console.aws.amazon.com/kinesis.

1. Choose **Delivery streams** in the navigation pane.

1. Choose **Create delivery stream**.

1. For Source, select **Amazon Kinesis Data Streams**.

1. For Destination, select **Amazon S3**.

1. Under **Source settings, Kinesis data stream**, enter the ARN of your Kinesis data stream.

1. Under **delivery stream name**, enter the name of your Kinesis data stream.

1. Under **Desination settings**, choose an Amazon S3 bucket or enter a bucket URI.

1. (optional) Enable dynamic partitioning using inline parsing for JSON. This option is appropriate if you want to partition streaming measurement data based on source information and timestamp. For example:
   + Choose **Enabled** for **Dynamic partitioning**.
   + Choose **Enabled** for **New line delimiter**.
   + Choose **Enabled** for **Inline parsing for JSON**.
   + Under **Dynamic partitioning keys**, add:    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/Monitron/latest/user-guide/kinesis-store-S3-v2.html)

1. Choose **Apply dynamic partitioning keys** and confirm the generated Amazon S3 bucket prefix is `!{partitionKeyFromQuery:project}/!{partitionKeyFromQuery:site}/!{partitionKeyFromQuery:time}/`.

1. In Amazon S3, objects will use the following key format: `/project={projectName}/site={siteName}/time={yyyy-mm-dd 00:00:00}/{filename}`.

1. Choose **Create delivery stream**.

# Processing data with Lambda


**Topics**
+ [

## Step 1: Create the [IAM role](https://docs.aws.amazon.com//lambda/latest/dg/lambda-intro-execution-role.html) that gives your function permission to access AWS resources
](#data-export-lambda-v2-1)
+ [

## Step 2: Create the Lambda function
](#create-lambda-function-v2)
+ [

## Step 3: Configure the Lambda function
](#configure-lambda-function-v2)
+ [

## Step 4: Enable Kinesis trigger in AWS Lambda console
](#configure-kinesis-trigger-v2)

## Step 1: Create the [IAM role](https://docs.aws.amazon.com//lambda/latest/dg/lambda-intro-execution-role.html) that gives your function permission to access AWS resources


1. Open the [roles page](https://console.aws.amazon.com/iam/home?#/roles) in the IAM console.

1. Choose **Create role**.

1. On the **Select trusted entity** page, do the following:
   + In **Trusted entity type**, choose **AWS service**.
   + In **Use case**, for **Service or use case** choose **Lambda**.
   + Choose **Next**.  
![\[IAM role creation interface showing trusted entity selection with AWS service option chosen.\]](http://docs.aws.amazon.com/Monitron/latest/user-guide/images/lambda-role-1.png)

1. In the **Add permissions** page, do the following: 
   + In **Permissions policies**, choose AWSLambdaKinesisExecutionRole (and AWSKeyManagementServicePowerUser if the Kinesis stream is encrypted).
   + Leave the configurations in **Set permissions boundary** as is.
   + Choose **Next**.  
![\[Add permissions interface showing AWSLambdaKinesisExecutionRole policy selected for a new role.\]](http://docs.aws.amazon.com/Monitron/latest/user-guide/images/lambda-role-2.png)

1. In the **Name, review, and create** page, do the following: 
   + In **Role details**, for **Role name**, enter a name for your role. For example *lambda-kinesis-role*. You can also choose to add an optional **Description**.
   + Leave the settings for **Step 1: Select trusted entities** and **Step 2: Add permissions** as is. You can choost to add tags in **Step 3: Add tags** to keep track of your resources.  
![\[IAM role creation interface showing name, review, and create steps with role details and permissions.\]](http://docs.aws.amazon.com/Monitron/latest/user-guide/images/lambda-create-role.png)

1. Select **Create role**.

## Step 2: Create the Lambda function


1. Open the **Functions** page in the Lambda console.

1. Choose **Create function**.

1. Choose **Use a blueprint**.

1. In the **Blueprints** search bar, search and choose **kinesis-process-record (nodejs)** or **kinesis-process-record-python**.

1. Choose **Configure**.  
![\[Create function interface with options to author from scratch, use a blueprint, or select container image.\]](http://docs.aws.amazon.com/Monitron/latest/user-guide/images/lambda-create-function.png)

## Step 3: Configure the Lambda function


1. Choose **Function name**

1. Choose the role created in the first step as the **Execution role**.

1. Configure Kinesis trigger.

   1. Choose your Kinesis stream.

   1. Click **Create function**.  
![\[Lambda function configuration form with basic information and Kinesis trigger settings.\]](http://docs.aws.amazon.com/Monitron/latest/user-guide/images/lambda-kinesis-trigger.png)

## Step 4: Enable Kinesis trigger in AWS Lambda console


1. On the **Configuration** tab, choose **Triggers**.

1. Check the box next to the name of the Kinesis stream and choose **Enable**.  
![\[Lambda function configuration page with Triggers tab and Kinesis stream trigger highlighted.\]](http://docs.aws.amazon.com/Monitron/latest/user-guide/images/kinesis-process-record-lambda.png)

The blueprint used in this example only consumes log data from the selected stream. You can further edit Lambda function code later to complete a more complicated task. 

# Understanding the v2 data export schema


 Each measurement data, its corresponding inference result, gateway connect/disconnect, and sensor connect/disconnect events are exported as one Kinesis data stream record in JSON format. 

**Topics**
+ [

## v2 schema format
](#data-export-schema-format-v2)
+ [

## v2 schema parameters
](#data-export-schema-parameters-v2)

## v2 schema format


```
{
    "timestamp": "string",
    "eventId": "string",
    "version": "2.0",
    "accountId": "string",
    "projectName": "string",
    "projectId": "string",
    "eventType": "measurement|gatewayConnected|gatewayDisconnected|sensorConnected|sensorDisconnected|assetStateTransition",
    // measurement
    "eventPayload": {
        "siteName": "string",
        "assetName": "string",
        "positionName": "string",
        "companyName": "string",
        "geoLocation": {
            "latitude": number,
            "longitude": number
        },
        "address": "string",
        "serialNumber": "string",
        "make": "string",
        "model": "string",
        "assetPositionURL": "string",
        "sensor": {
            "physicalId": "string",
            "rssi": number
        },
        "gateway": {
            "physicalId": "string"
        },
        "sequenceNo": number,
        "features": {
            "acceleration": {
                "band0To6000Hz": {
                    "xAxis": {
                        "rms": number
                    },
                    "yAxis": {
                        "rms": number
                    },
                    "zAxis": {
                        "rms": number
                    }
                },
                "band10To1000Hz": {
                    "totalVibration": {
                        "absMax": number,
                        "absMin": number,
                        "crestFactor": number,
                        "rms": number
                    },
                    "xAxis": {
                        "rms": number
                    },
                    "yAxis": {
                        "rms": number
                    },
                    "zAxis": {
                        "rms": number
                    }
                }
            },
            "velocity": {
                "band10To1000Hz": {
                    "totalVibration": {
                        "absMax": number,
                        "absMin": number,
                        "crestFactor": number,
                        "rms": number
                    },
                    "xAxis": {
                        "rms": number
                    },
                    "yAxis": {
                        "rms": number
                    },
                    "zAxis": {
                        "rms": number
                    }
                }
            },
            "temperature": number
        }
        "models": {
            "temperatureML": {
                "previousPersistentClassificationOutput": "string",
                "persistentClassificationOutput": "string",
                "pointwiseClassificationOutput": "string"
            },
            "vibrationISO": {
                "isoClass": "string",
                "mutedThreshold": "string",
                "previousPersistentClassificationOutput": "string",
                "persistentClassificationOutput": "string",
                "pointwiseClassificationOutput": "string"
            },
            "vibrationML": {
                "previousPersistentClassificationOutput": "string",
                "persistentClassificationOutput": "string",
                "pointwiseClassificationOutput": "string"
            }
        },
        "assetPositionId": "string"
    }
    
    // sensorConnected
    "eventPayload": {
        "siteName": "string",
        "assetName": "string",
        "positionName": "string",
        "companyName": "string",
        "geoLocation": {
            "latitude": number,
            "longitude": number
        },
        "address": "string",
        "serialNumber": "string",
        "make": "string",
        "model": "string",
        "assetPositionURL": "string",
        "sensor": {
            "physicalId": "string"
        },
        "assetPositionId": "string"
    }
    
    // sensorDisconnected
    "eventPayload": {
        "siteName": "string",
        "assetName": "string",
        "positionName": "string",
        "companyName": "string",
        "geoLocation": {
            "latitude": number,
            "longitude": number
        },
        "address": "string",
        "serialNumber": "string",
        "make": "string",
        "model": "string",
        "assetPositionURL": "string",
        "sensor": {
            "physicalId": "string"
        },
        "assetPositionId": "string"
    }
    
    // gatewayConnected
    "eventPayload": {
        "siteName": "string",
        "gatewayName": "string",
        "gatewayListURL": "string",
        "companyName": "string",
        "geoLocation": {
            "latitude": number,
            "longitude": number
        },
        "address": "string",
        "gateway": {
            "physicalId": "string"
        }
    }
    
    // gatewayDisconnected
    "eventPayload": {
        "siteName": "string",
        "gatewayName": "string",
        "gatewayListURL": "string",
        "companyName": "string",
        "geoLocation": {
            "latitude": number,
            "longitude": number
        },
        "address": "string",
        "gateway": {
            "physicalId": "string"
        }
    }
    
    // assetStateTransition
    "eventPayload": {
        "siteName": "string",
        "assetName": "string",
        "positionName": "string",
        "companyName": "string",
        "geoLocation": {
            "latitude": number,
            "longitude": number
        },
        "address": "string",
        "serialNumber": "string",
        "make": "string",
        "model": "string",
        "assetPositionURL": "string",
        "sensor": {
            "physicalId": "string"
        },
        "assetTransitionType": "measurement|userInput",
        "assetState": {
            "newState": "string",
            "previousState": "string"
        },
        "closureCode": {
            "failureMode": "string",
            "failureCause": "string",
            "actionTaken": "string",
            "resolvedModels": list<"string">
        },
        "assetPositionId": "string"
    }
}
```

## v2 schema parameters


 The Amazon Monitron Kinesis data export schema v2 includes the following schema parameters. Some parameters are updates from v1 and some are unique to v2. For example, `siteName` was a first-level parameter in v1. In v2, it is a second-level parameter that can be found under the `eventPayload` entity. 

timestamp  
+ The timestamp when the measurement is received by Amazon Monitron service in UTC
+ Type: String
+ Pattern: yyyy-mm-dd hh:mm:ss.SSS

eventId  
+ The unique data export event ID assigned for each measurement. Can be used to deduplicate the Kinesis stream records received.
+ Type: String

version  
+ Schema version
+ Type: String
+ Value: 1.0 or 2.0

accountId  
+ The 12-digit AWS account ID for your Monitron project
+ Type: String

projectName  
The project name displayed in the app and console.  
Type: String

projectId  
The unique ID of your Amazon Monitron project.  
Type: String

eventType  
+ The current event stream. Each event type will have a dedicated `eventPayload` format.
+ Type: String
+ Possible values: `measurement`, `gatewayConnected`, `gatewayDisconnected`, `sensorConnected`, `sensorDisconnected`, `assetStateTransition`.

**`eventType: measurement`**

eventPayload.features.acceleration.band0To6000Hz.xAxis.rms  
+ The root mean square of the acceleration observed in the frequency band 0–6000 Hz in the x axis
+ Type: Number
+ Unit: m/s^2

eventPayload.features.acceleration.band0To6000Hz.yAxis.rms  
+ The root mean square of the acceleration observed in the frequency band 0–6000 Hz in the y axis
+ Type: Number
+ Unit: m/s^2

eventPayload.features.acceleration.band0To6000Hz.zAxis.rms  
+ The root mean square of the acceleration observed in the frequency band 0–6000 Hz in the z axis
+ Type: Number
+ Unit: m/s^2

eventPayload.features.acceleration.band10To1000Hz.resultantVector.absMax  
+ The absolute maximum acceleration observed in the frequency band 10–1000 Hz
+ Type: Number
+ Unit: m/s^2

eventPayload.features.acceleration.band10To1000Hz.resultantVector.absMin  
+ The absolute minimum acceleration observed in the frequency band 10–1000 Hz
+ Type: Number
+ Unit: m/s^2

eventPayload.features.acceleration.band10To1000Hz.resultantVector.crestFactor  
+ The acceleration crest factor observed in the frequency band 10–1000 Hz
+ Type: Number

eventPayload.features.acceleration.band10To1000Hz.resultantVector.rms  
+ The root mean square of the acceleration observed in the frequency band 10–1000 Hz
+ Type: Number
+ m/s^2

eventPayload.features.acceleration.band10To1000Hz.xAxis.rms  
+ The root mean square of the acceleration observed in the frequency band 10–1000 Hz in the x axis
+ Type: Number
+ m/s^2

eventPayload.features.acceleration.band10To1000Hz.yAxis.rms  
+ The root mean square of the acceleration observed in the frequency band 10–1000 Hz in the y axis
+ Type: Number
+ m/s^2

eventPayload.features.acceleration.band10To1000Hz.zAxis.rms  
+ The root mean square of the acceleration observed in the frequency band 10–1000 Hz in the z axis
+ Type: Number
+ m/s^2

eventPayload.features.temperature  
+ The temperature observed
+ Type: Number
+ °C/degC

eventPayload.features.velocity.band10To1000Hz.resultantVector.absMax  
+ The absolute maximum velocity observed in the frequency band 10–1000 Hz
+ Type: Number
+ mm/s

eventPayload.features.velocity.band10To1000Hz.resultantVector.absMin  
+ The absolute minimum velocity observed in the frequency band 10–1000 Hz
+ Type: Number
+ mm/s

eventPayload.features.velocity.band10To1000Hz.resultantVector.crestFactor  
+ The velocity crest factor observed in the frequency band 10–1000 Hz
+ Type: Number

eventPayload.features.velocity.band10To1000Hz.resultantVector.rms  
+ The root mean square of the velocity observed in the frequency band 10–1000 Hz
+ Type: Number
+ mm/s

eventPayload.features.velocity.band10To1000Hz.xAxis.rms  
+ The root mean square of the velocity observed in the frequency band 10–1000 Hz in the x axis
+ Type: Number
+ mm/s

eventPayload.features.velocity.band10To1000Hz.yAxis.rms  
+ The root mean square of the velocity observed in the frequency band 10–1000 Hz in the y axis
+ Type: Number
+ mm/s

eventPayload.features.velocity.band10To1000Hz.zAxis.rms  
+ The root mean square of the velocity observed in the frequency band 10–1000 Hz in the z axis
+ Type: Number
+ mm/s

eventPayload.sequenceNo  
+ The measurement sequence number
+ Type: Number

eventPayload.assetPositionId  
+ The identifier of the sensor position for which the measurement is sent.
+ Type: String

eventPayload.companyName  
+ The name of the company using the asset.
+ Type: String

eventPayload.geoLocation.latitude  
+ The latitude of the site's physical location.
+ Type: Number

eventPayload.geoLocation.longitude  
+ The longitude of the site's physical location.
+ Type: Number

eventPayload.address  
+ The address of the site.
+ Type: String

eventPayload.serialNumber  
+ The serial number of the asset.
+ Type: String

eventPayload.make  
+ The make of the asset.
+ Type: String

eventPayload.model  
+ The model of the asset.
+ Type: String

`eventType: sensorConnected`

siteName  
+ The site name displayed in the app
+ Type: String

assetName  
+ The asset name displayed in the app
+ Type: String

positionName  
+ The sensor position name displayed in the app
+ Type: String

assetPositionURL  
+ The sensor URL displayed in the app
+ Type: String

physicalID  
+ The physical ID of the sensor from which the measurement is sent
+ Type: String

eventPayload.assetPositionId  
+ The identifier of the sensor position whose state changed.
+ Type: String

eventPayload.companyName  
+ The name of the company using the asset.
+ Type: String

eventPayload.geoLocation.latitude  
+ The latitude of the site's physical location.
+ Type: Number

eventPayload.geoLocation.longitude  
+ The longitude of the site's physical location.
+ Type: Number

eventPayload.address  
+ The address of the site.
+ Type: String

eventPayload.serialNumber  
+ The serial number of the asset.
+ Type: String

eventPayload.make  
+ The make of the asset.
+ Type: String

eventPayload.model  
+ The model of the asset.
+ Type: String

`eventType: sensorDisconnected`

siteName  
+ The site name displayed in the app
+ Type: String

assetName  
+ The asset name displayed in the app
+ Type: String

positionName  
+ The sensor position name displayed in the app
+ Type: String

assetPositionURL  
+ The sensor URL displayed in the app
+ Type: String

physicalID  
+ The physical ID of the sensor from which the measurement is sent
+ Type: String

eventPayload.assetPositionId  
+ The identifier of the sensor position whose state changed.
+ Type: String

eventPayload.companyName  
+ The name of the company using the asset.
+ Type: String

eventPayload.geoLocation.latitude  
+ The latitude of the site's physical location.
+ Type: Number

eventPayload.geoLocation.longitude  
+ The longitude of the site's physical location.
+ Type: Number

eventPayload.address  
+ The address of the site.
+ Type: String

eventPayload.serialNumber  
+ The serial number of the asset.
+ Type: String

eventPayload.make  
+ The make of the asset.
+ Type: String

eventPayload.model  
+ The model of the asset.
+ Type: String

 `eventType: gatewayConnected` 

eventPayload.siteName  
+ The site name displayed in the app
+ Type: String

eventPayload.gatewayName  
+ The name of the gateway as displayed in the app
+ Type: String

eventPayload.gatewayListURL  
+ The gateway URL displayed in the app
+ Type: String

eventPayload.gateway.physicalID  
+ The physical ID of the gateway just connected to transmit data to the Amazon Monitron service
+ Type: String

eventPayload.companyName  
+ The name of the company using the asset.
+ Type: String

eventPayload.geoLocation.latitude  
+ The latitude of the site's physical location.
+ Type: Number

eventPayload.geoLocation.longitude  
+ The longitude of the site's physical location.
+ Type: Number

eventPayload.address  
+ The address of the site.
+ Type: String

`eventType: gatewayDisconnected`

siteName  
+ The site name displayed in the app
+ Type: String

gatewayName  
+ The name of the gateway as displayed in the app
+ Type: String

gatewayListURL  
+ The gateway URL displayed in the app
+ Type: String

physicalID  
+ The physical ID of the gateway just connected to transmit data to the Amazon Monitron service
+ Type: String

eventPayload.companyName  
+ The name of the company using the asset.
+ Type: String

eventPayload.geoLocation.latitude  
+ The latitude of the site's physical location.
+ Type: Number

eventPayload.geoLocation.longitude  
+ The longitude of the site's physical location.
+ Type: Number

eventPayload.address  
+ The address of the site.
+ Type: String

`eventType: assetStateTransition`

eventPayload.siteName  
+ The site name displayed in the app
+ Type: String

eventPayload.assetName  
+ The asset name displayed in the app
+ Type: String

eventPayload.positionName  
+ The sensor position name displayed in the app
+ Type: String

eventPayload.assetPositionURL  
+ The sensor URL displayed in the app
+ Type: String

eventPayload.sensor.physicalID  
+ The physical ID of the sensor from which the measurement is sent
+ Type: String

eventPayload.assetTransitionType  
+ The reason behind the asset state transition
+ Type: String
+ Possible values: `measurement` or `userInput`

eventPayload.assetState.newState  
+ The new state of the asset
+ Type: String

eventPayload.assetState.previousState  
+ The previous state of the asset
+ Type: String

eventPayload.closureCode.failureMode  
+ The failure mode selected by the user when acknowledging this failure
+ Type: String
+ Possible values: `NO_ISSUE` \$1 `BLOCKAGE` \$1 `CAVITATION` \$1 `CORROSION` \$1 `DEPOSIT` \$1 `IMBALANCE` \$1 `LUBRICATION` \$1 `MISALIGNMENT` \$1 `OTHER` \$1 `RESONANCE` \$1 `ROTATING_LOOSENESS` \$1 `STRUCTURAL_LOOSENESS` \$1 `TRANSMITTED_FAULT` \$1 `UNDETERMINED` 

eventPayload.closureCode.failureCause  
+ The cause of the failure as selected by the user in the app dropdown when acknowledging a failure.
+ Type: String
+ Possible values: `ADMINISTRATION` \$1 `DESIGN` \$1 `FABRICATION` \$1 `MAINTENANCE` \$1 `OPERATION` \$1 `OTHER` \$1 `QUALITY` \$1 `UNDETERMINED` \$1 `WEAR` 

eventPayload.closureCode.actionTaken  
+ The action taken when closing this anomaly, as selected by the user in the app dropdown.
+ Type: String
+ Possible values: `ADJUST` \$1 `CLEAN` \$1 `LUBRICATE` \$1 `MODIFY` \$1 `NO_ACTION` \$1 `OTHER` \$1 `OVERHAUL` \$1 `REPLACE` 

eventPayload.closureCode.resolvedModels  
+ The set of models which called out the issue.
+ Type: List of Strings
+ Possible values: `vibrationISO` \$1 `vibrationML` \$1 `temperatureML` 

eventPayload.assetPositionId  
+ The identifier of the asset position whose state changed.
+ Type: String

models.temperatureML.persistentClassificationOutput  
+ The persistent classification output from the machine learning based temperature model
+ Type: Number
+ Valid Values: `UNKNOWN | HEALTHY | WARNING | ALARM`

models.temperatureML.pointwiseClassificationOutput  
+ The point–wise classification output from the machine learning based temperature model
+ Type: String
+ Valid Values: `UNKNOWN | INITIALIZING | HEALTHY | WARNING | ALARM`

models.vibrationISO.isoClass  
+ The ISO 20816 class (a standard for measurement and evaluation of machine vibration) used by the ISO based vibration model
+ Type: String
+ Valid Values: `CLASS1 | CLASS2 | CLASS3 | CLASS4`

models.vibrationISO.mutedThreshold  
+ The threshold to mute the notification from the ISO based vibration model
+ Type: String
+ Valid Values: `WARNING | ALARM`

models.vibrationISO.persistentClassificationOutput  
+ The persistent classification output from the ISO based vibration model
+ Type: String
+ Valid Values: `UNKNOWN | HEALTHY | WARNING | ALARM`

models.vibrationISO.pointwiseClassificationOutput  
+ The point–wise classification output from the the ISO based vibration model
+ Type: String
+ Valid Values: `UNKNOWN | HEALTHY | WARNING | ALARM | MUTED_WARNING | MUTED_ALARM`

models.vibrationML.persistentClassificationOutput  
+ The persistent classification output from the machine learning based vibration model
+ Type: String
+ Valid Values: `UNKNOWN | HEALTHY | WARNING | ALARM`

models.vibrationML.pointwiseClassificationOutput  
+ The point–wise classification output from the machine learning based vibration model
+ Type: String
+ Valid Values: `UNKNOWN | INITIALIZING | HEALTHY | WARNING | ALARM`

assetState.newState  
+ The machine status after processing the measurement
+ Type: String
+ Valid Values: `UNKNOWN | HEALTHY | NEEDS_MAINTENANCE | WARNING | ALARM`

assetState.previousState  
+ The machine status before processing the measurement
+ Type: String
+ Valid Values: `UNKNOWN | HEALTHY | NEEDS_MAINTENANCE | WARNING | ALARM`

eventPayload.companyName  
+ The name of the company using the asset.
+ Type: String

eventPayload.geoLocation.latitude  
+ The latitude of the site's physical location.
+ Type: Number

eventPayload.geoLocation.longitude  
+ The longitude of the site's physical location.
+ Type: Number

eventPayload.address  
+ The address of the site.
+ Type: String

eventPayload.serialNumber  
+ The serial number of the asset.
+ Type: String

eventPayload.make  
+ The make of the asset.
+ Type: String

eventPayload.model  
+ The model of the asset.
+ Type: String

# Migration from Kinesis v1 to v2


 If you are currently using the v1 data schema, you may already be sending data to Amazon S3, or further processing the data stream payload with Lambda. 

**Topics**
+ [

## Updating the data schema to v2
](#updating-to-v2)
+ [

## Updating data processing with Lambda
](#updating-with-lam)

## Updating the data schema to v2


 If you have already configured a data stream with the v1 schema, you can update your data export process by doing the following: 

1. Open your Amazon Monitron console.

1. Navigate to your project.

1.  Stop the [current live data export](monitron-kinesis-export-v2.md#stop-kinesis-export-v2). 

1.  Start the live data export to create a new data stream.

1. Select the newly created data stream.

1. Choose **start live data export**. At this point, the new schema will send your payload through the data stream.

1. (Optional) Go to the Kinesis console and delete your old data stream.

1. Configure a new delivery method for your newly created data stream with the v2 schema.

 Your new stream now delivers payloads conforming to the v2 schema to your new bucket. We recommend using two distinct buckets to have a consistent format in case you want to process all the data in these buckets. For example, using other services such as Athena and AWS Glue. 

**Note**  
If you were delivering your data to Amazon S3, learn how to [store exported data in Amazon S3](kinesis-store-S3-v2.md#kinesis-store-S3-title-v2) for details on how to deliver your data to Amazon S3 with the v2 schema.

**Note**  
If you were using a Lambda function to process your payloads, learn how to [ process data with Lambda](https://docs.aws.amazon.com/Monitron/latest/user-guide/data-export-lambda.html). You can also refer to the [updating with Lambda](#updating-with-lam) section for more information.

## Updating data processing with Lambda


 Updating the data processing with Lambda requires you to consider that the v2 data stream is now event-based. Your initial v1 Lambda code may have been similar to the following: 

```
import base64

def main_handler(event):
    # Kinesis "data" blob is base64 encoded so decode here:
    for record in event['Records']:
        payload = base64.b64decode(record["kinesis"]["data"])
     
        measurement = payload["measurement"]
        projectDisplayName = payload["projectDisplayName"]
     
        # Process the content of the measurement
        # ...
```

 Since the v1 data schema is on a deprecation path, the previous Lambda code won't work with all the new data streams. 

 The following Python sample code will process events from Kinesis stream with the data schema v2. This code uses the new `eventType` parameter to orient the processing to the appropriate handler: 

```
import base64

handlers = {
    "measurement": measurementEventHandler,
    "gatewayConnected": gatewayConnectedEventHandler,
    "gatewayDisconnected": gatewayDisconnectedEventHandler,
    "sensorConnected": sensorConnectedEventHandler,
    "sensorDisconnected": sensorDisconnectedEventHandler,
}

def main_handler(event):
    # Kinesis "data" blob is base64 encoded so decode here:
    for record in event['Records']:
        payload = base64.b64decode(record["kinesis"]["data"])
          
        eventType = payload["eventType"]
        if eventType not in handler.keys():
            log.info("No event handler found for the event type: {event['eventType']}")
            return 
     
        # Invoke the appropriate handler based on the event type.
        eventPayload = payload["eventPayload"]
        eventHandler = handlers[eventType] 
        eventHandler(eventPayload)

def measurementEventHandler(measurementEventPayload):
    # Handle measurement event
    projectName = measurementEventPayload["projectName"]
    
    # ...

def gatewayConnectedEventHandler(gatewayConnectedEventPayload):
    # Handle gateway connected event

# Other event handler functions
```