

End of support notice: On May 20, 2026, AWS will end support for AWS IoT Events. After May 20, 2026, you will no longer be able to access the AWS IoT Events console or AWS IoT Events resources. For more information, see [AWS IoT Events end of support](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-end-of-support.html).

# Troubleshooting AWS IoT Events
Troubleshooting

 This troubleshooting guide provides solutions for common issues you may encounter when using AWS IoT Events. Browse the topics to identify and resolve problems with detecting events, accessing data, permissions, service integrations, device configurations, and more. With troubleshooting advice for the AWS IoT Events console, API, CLI, errors, latency, and integrations, this guide aims to quickly resolve your issues so you can build reliable and scalable event-driven applications.

**Topics**
+ [

# Common AWS IoT Events issues and solutions
](iotevents-error-messages.md)
+ [

# Troubleshooting a detector model by running analyses in AWS IoT Events
](iotevents-analyze-api.md)

# Common AWS IoT Events issues and solutions


See the following section to troubleshoot errors and find possible solutions to resolve issues with AWS IoT Events.

**Topics**
+ [

## Detector model creation errors
](#create-detector-model)
+ [

## Updates from a deleted detector model
](#update-detector-model)
+ [

## Action trigger failure (when meeting a condition)
](#no-action)
+ [

## Action trigger failure (when breeching a threshold)
](#trigger-action)
+ [

## Incorrect state usage
](#wrong-state)
+ [

## Connection message
](#connection-aborted-error)
+ [

## InvalidRequestException message
](#invalid-request)
+ [

## Amazon CloudWatch Logs `action.setTimer` errors
](#cw-logs-timer)
+ [

## Amazon CloudWatch payload errors
](#cw-logs-payload)
+ [

## Incompatible data types
](#troubleshoot-expressions-incompatible-data-types)
+ [

## Failed to send message to AWS IoT Events
](#failed-to-send-to-iot-events)

## Detector model creation errors


I get errors when I attempt to create a detector model.

### Solution


 When you create a detector model, you must consider the following limitations. 
+ Only one action is allowed in each `action` field.
+ The `condition` is required for `transitionEvents`. It's optional for `OnEnter`, `OnInput`, and `OnExit` events. 
+ If the `condition` field is empty, the evaluated result of the condition expression is equivalent to `true`. 
+ The evaluated result of the condition expression should be a Boolean value. If the result isn't a Boolean value, it's equivalent to `false` and doesn't trigger the `actions` or transition to the `nextState` specified in the event. 

For more information, see [AWS IoT Events detector model restrictions and limitations](iotevents-restrictions-detector-model.md). 

## Updates from a deleted detector model


I updated or deleted a detector model a few minutes ago but I'm still getting state updates from the old detector model through MQTT messages or SNS alerts.

### Solution


If you update, delete, or recreate a detector model (see [UpdateDetectorModel](https://docs.aws.amazon.com/iotevents/latest/apireference/API_UpdateDetectorModel.html)), there is a delay before all detector instances are deleted and the new model is used. During this time, inputs might continue to be processed by the instances of the previous version of the detector model. You might continue to receive alerts defined by the previous detector model. Wait for at least seven minutes before you recheck the update or report an error. 

## Action trigger failure (when meeting a condition)


The detector fails to trigger an action or transition to a new state when the condition is met.

### Solution


Verify that the evaluated result of the detector's conditional expression is a Boolean value. If the result isn't a Boolean value, it's equivalent to `false` and doesn't trigger the `action` or transition to the `nextState` specified in the event. For more information, see [Conditional expression syntax](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-conditional-expressions.html). 

## Action trigger failure (when breeching a threshold)


The detector doesn't trigger an action or an event transition when the variable in a conditional expression reaches a specified value.

### Solution


If you update `setVariable` for `onInput`, `onEnter`, or `onExit`, the new value isn't used when evaluating any `condition` during the current processing cycle. Instead, the original value is used until the current cycle is complete. You can change this behavior by setting the `evaluationMethod` parameter in the detector model definition. When `evaluationMethod` is set to `SERIAL`, variables are updated and event conditions evaluated in the order that the events are defined. When `evaluationMethod` is set to `BATCH` (the default), variables are updated and events performed only after all event conditions are evaluated. 

## Incorrect state usage


The detector enters the wrong states when I attempt to send messages to inputs by using `BatchPutMessage`.

### Solution


 If you use [BatchPutMessage](https://docs.aws.amazon.com/iotevents/latest/apireference/API_iotevents-data_BatchPutMessage.html) to send multiple messages to inputs, the order in which the messages or inputs are processed isn't guaranteed. To guarantee ordering, send messages one at time and wait each time for `BatchPutMessage` to acknowledge success. 

## Connection message


I get a `('Connection aborted.', error(54, 'Connection reset by peer'))` error when I attempt to call or invoke an API.

### Solution


Verify that OpenSSL uses TLS 1.1 or a later version to establish the connection. This should be the default under most Linux distributions or Windows version 7 and later. Users of macOS might need to upgrade OpenSSL.

## InvalidRequestException message


I get InvalidRequestException when I attempt to call `CreateDetectorModel` and `UpdateDetectorModel` APIs.

### Solution


Check the following to help resolve the issue. For more information, see [CreateDetectorModel](https://docs.aws.amazon.com/iotevents/latest/apireference/API_CreateDetectorModel.html) and [UpdateDetectorModel](https://docs.aws.amazon.com/iotevents/latest/apireference/API_UpdateDetectorModel.html).
+ Make sure that you don't use both `seconds` and `durationExpression` as the parameters of `SetTimerAction` at the same time.
+ Make sure that your string expression for `durationExpression` is valid. The string expression can contain numbers, variables (`$variable.<variable-name>`), or input values (`$input.<input-name>.<path-to-datum>`).

## Amazon CloudWatch Logs `action.setTimer` errors


You can set up Amazon CloudWatch Logs to monitor AWS IoT Events detector model instances. The following are common errors generated by AWS IoT Events, when you use `action.setTimer`. 
+ **Error:** Your duration expression for the timer named `<timer-name>` could not be evaluated to a number.

### Solution


   Make sure that your string expression for `durationExpression` can be converted to a number. Other data types, such as Boolean, aren't allowed.
+ **Error:** The evaluated result of your duration expression for the timer named `<timer-name>` is greater than 31622440. To ensure accuracy, make sure that your duration expression refers to a value between 60‐31622400.

### Solution


   Make sure that the duration of your timer is less than or equal to 31622400 seconds. The evaluated result of the duration is rounded down to the nearest whole number.
+ **Error:** The evaluated result of your duration expression for the timer named `<timer-name>` is less than 60. To ensure accuracy, make sure that your duration expression refers to a value between 60‐31622400.

### Solution


   Make sure that the duration of your timer is greater than or equal to 60 seconds. The evaluated result of the duration is rounded down to the nearest whole number.
+ **Error:** Your duration expression for the timer named `<timer-name>` could not be evaluated. Check the variable names, input names, and paths to the data to make sure that you refer to the existing variables and inputs. 

### Solution


   Make sure that your string expression refers to the existing variables and inputs. The string expression can contain numbers, variables (`$variable.variable-name`), and input values (`$input.input-name.path-to-datum`).
+ **Error:** Failed to set the timer named `<timer-name>`. Check your duration expression, and try again.

### Solution


   See the [SetTimerAction](https://docs.aws.amazon.com/iotevents/latest/apireference/API_SetTimerAction.html) action to ensure that you specified the correct parameters, and then set the timer again. 

For more information, see [ Enable Amazon CloudWatch logging when developing AWS IoT Events detector models](https://docs.aws.amazon.com/iotevents/latest/developerguide/best-practices.html#best-practices-cw-logs). 

## Amazon CloudWatch payload errors


You can set up Amazon CloudWatch Logs to monitor AWS IoT Events detector model instances. The following are common errors and warnings generated by AWS IoT Events, when you configure the action payload. 
+ **Error:** We couldn't evaluate your expression for the action. Make sure that the variable names, input names, and paths to the data refer to the existing variables and input values. Also, verify that the size of the payload is less than 1 KB, the maximum allowed size of a payload.

### Solution


   Make sure that you enter the correct variable names, input names, and paths to the data. You might also receive this error message if the action payload is larger than 1 KB.
+ **Error:** We couldn't parse your content expression for the payload of `<action-type>`. Enter a content expression with the correct syntax.

### Solution


   The content expression can contain strings (`'string'`), variables (`$variable.variable-name`), input values (`$input.input-name.path-to-datum`), string concatenations, and strings that contain `${}`.
+ **Error:** Your payload expression \$1*expression*\$1 isn't valid. The defined payload type is JSON, so you must specify an expression that AWS IoT Events would evaluate to a string.

### Solution


   If the specified payload type is JSON, AWS IoT Events first checks if the service can evaluate your expression to a string. The evaluated result can't be a Boolean or number. If the validation fails, you might receive this error.
+ **Warning:** The action was executed, but we couldn't evaluate your content expression for the action payload to valid JSON. The defined payload type is JSON.

### Solution


   Make sure that AWS IoT Events can evaluate your content expression for the action payload to valid JSON, if you define the payload type as `JSON`. AWS IoT Events runs the action even if AWS IoT Events can't evaluate the content expression to valid JSON.

For more information, see [ Enable Amazon CloudWatch logging when developing AWS IoT Events detector models](https://docs.aws.amazon.com/iotevents/latest/developerguide/best-practices.html#best-practices-cw-logs).

## Incompatible data types


Message: Incompatible data types [`<inferred-types>`] found for `<reference>` in the following expression: `<expression>`

### Solution


 You might receive this error for one of the following reasons:
+ The evaluated results of your references are not compatible with other operands in your expressions.
+ The type of the argument passed to a function is not supported.

When you use references in expressions, check the following:<a name="expression-reference-type-compatibility"></a>
+ When you use a reference as an operand with one or more operators, make sure that all data types that you reference are compatible.

  For example, in the following expression, integer `2` is an operand of both the `==` and `&&` operators. To ensure that the operands are compatible, `$variable.testVariable + 1` and `$variable.testVariable` must reference an integer or decimal.

  In addition, integer `1` is an operand of the `+` operator. Therefore, `$variable.testVariable` must reference an integer or decimal.

  ```
  ‘$variable.testVariable + 1 == 2 && $variable.testVariable’
  ```
+ When you use a reference as an argument passed to a function, make sure that the function supports the data types that you reference.

  For example, the following `timeout("time-name")` function requires a string with double quotes as the argument. If you use a reference for the *timer-name* value, you must reference a string with double quotes.

  ```
  timeout("timer-name")
  ```
**Note**  
For the `convert(type, expression)` function, if you use a reference for the *type* value, the evaluated result of your reference must be `String`, `Decimal`, or `Boolean`.

For more information, see [AWS IoT Events reference for inputs and variables in expressions](iotevents-expressions.md#expression-reference). 

## Failed to send message to AWS IoT Events


Message: Failed to send message to Iot Events

### Solution


You might experience this error for the following reasons:
+ The input message payload does not contain the `Input attribute Key`.
+ The `Input attribute Key` is not in the same JSON path as specified in the input definition.
+ The input message does not match with the schema, as defined in the AWS IoT Events input.

**Note**  
The data ingestion from other services will also experience failure.

**Example**  
For example in AWS IoT Core, the AWS IoT rule will fail with the following message `Verify the Input Attribute key.`

To resolve this, ensure that the input payload message schema conforms to the AWS IoT Events Input definition and the `Input attribute Key` location matches. For more information, see [Create an input for models in AWS IoT Events](create-input-overview.md) to learn how to define AWS IoT Events Inputs.

# Troubleshooting a detector model by running analyses in AWS IoT Events
Troubleshooting a detector modelTroubleshoot a detector model by running analyses[https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-analyze-api.html](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-analyze-api.html)

AWS IoT Events can now analyze your detector model and generate analysis results that you can use to troubleshoot your detector model.

AWS IoT Events can analyze your detector model and generate analysis results without sending input data to your detector model. AWS IoT Events performs a series of analyses described in this section to check your detector model. This advanced troubleshooting solution also summarizes diagnostic information, including the severity level and location, so that you can quickly find and fix potential issues in your detector model. For more information about diagnostic error types and messages for your detector model, see [Detector model analysis and diagnostic information for AWS IoT Events](analyze-diagnostic-information.md).

You can use the AWS IoT Events console, [API](https://docs.aws.amazon.com/iotevents/latest/apireference/), [AWS Command Line Interface (AWS CLI)](https://docs.aws.amazon.com/cli/latest/reference/iotevents/index.html), or [AWS SDK](https://docs.aws.amazon.com/iot/latest/developerguide/iot-sdks.html) to view diagnostic error messages from the analysis of your detector model.

**Note**  
You must fix all errors before you can publish your detector model.
We recommend that you review warnings and take necessary actions before you use your detector model in production environments. Otherwise, the detector model might not work as expected.
You can have up to 10 analyses in the `RUNNING` status at the same time.

To learn how to analyze your detector model, see [Analyze a detector model for AWS IoT Events (Console)](analyze-api-console.md) or [Analyze a detector model in AWS IoT Events (AWS CLI)](analyze-api-api.md). 

**Topics**
+ [

# Detector model analysis and diagnostic information for AWS IoT Events
](analyze-diagnostic-information.md)
+ [

# Analyze a detector model for AWS IoT Events (Console)
](analyze-api-console.md)
+ [

# Analyze a detector model in AWS IoT Events (AWS CLI)
](analyze-api-api.md)

# Detector model analysis and diagnostic information for AWS IoT Events
Diagnostic information

Detector model analyses gather the following diagnostic information:
+ **Level** – The severity level of the analysis result. Based on the severity level, analysis results fall into three general categories:
  + **Information** (`INFO`) – An information result tells you about a significant field in your detector model. This type of result usually doesn't require immediate action.
  + **Warning** (`WARNING`) – A warning result draws special attention to fields that might cause issues for your detector model. We recommend that you review warnings and take necessary actions before you use your detector model in production environments. Otherwise, the detector model might not work as expected.
  + **Error** (`ERROR`) – An error result notifies you about a problem found in your detector model. AWS IoT Events automatically performs this set of analyses when you try to publish the detector model. You must fix all errors before you can publish the detector model.
+ **Location** – Contains information that you can use to locate the field in your detector model that the analysis result references. A location typically includes the state name, transition event name, event name, and expression (for example, `in state TemperatureCheck in onEnter in event Init in action setVariable`).
+ **Type** – The type of the analysis result. Analysis types fall into the following categories:
  + `supported-actions` – AWS IoT Events can invoke actions when a specified event or transition event is detected. You can define built-in actions to use a timer or set a variable, or send data to other AWS services. You must specify actions that work with other AWS services in an AWS Region where the AWS services are available. 
  + `service-limits` – Service quotas, also known as limits, are the maximum or minimum number of service resources or operations for your AWS account. Unless otherwise noted, each quota is Region-specific. Depending on your business needs, you can update your detector model to avoid encountering limits or request a quota increase. You can request increases for some quotas, and other quotas can't be increased. For more information, see [Quotas](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-quotas.html).
+ **`structure`** – The detector model must have all required components such as states and follow a structure that AWS IoT Events supports. A detector model must have at least one state and a condition that evaluates the incoming input data to detect significant events. When an event is detected, the detector model transitions to the next state and can invoke actions. These events are known as transition events. A transition event must direct the next state to enter.
+ **`expression-syntax`** – AWS IoT Events provides several ways to specify values when you create and update detector models. You can use literals, operators, functions, references, and substitution templates in the expressions. You can use expressions to specify literal values, or AWS IoT Events can evaluate the expressions before you specify particular values. Your expression must follow the required syntax. For more information, see [Expressions to filter, transform, and process event data](iotevents-expressions.md).

  Detector Model expressions in AWS IoT Events can reference specific data or a resource.
  + **`data-type`** – AWS IoT Events supports integer, decimal, string, and Boolean data types. If AWS IoT Events can automatically convert the data of one data type to another during expression evaluation, these data types are compatible.
**Note**  
Integer and decimal are the only compatible data types supported by AWS IoT Events.
AWS IoT Events can't evaluate arithmetic expressions because AWS IoT Events can't convert an integer to a string.
  + **`referenced-data`** – You must define the data referenced in your detector model before you can use the data. For example, if you want to send data to a DynamoDB table, you must define a variable that references the table name before you can use the variable in an expression (`$variable.TableName`).
  + **`referenced-resource`** – Resources that the detector model uses must be available. You must define resources before you can use them. For example, you want to create a detector model to monitor the temperature of a greenhouse. You must define an input (`$input.TemperatureInput`) to route incoming temperature data to your detector model before you can use the `$input.TemperatureInput.sensorData.temperature` to reference the temperature.

See the following section to troubleshoot errors and find possible solutions from the analysis of your detector model.

## Troubleshoot detector model errors in AWS IoT Events
Troubleshoot error messages

The types of errors described above provide diagnostic information about a detector model and correspond to messages that you might retrieve. Use these messages and suggested solutions to troubleshoot errors with your detector model.

**Topics**
+ [

### `Location`
](#analyze-location)
+ [

### `supported-actions`
](#analyze-supported-actions)
+ [

### `service-limits`
](#analyze-service-limits)
+ [

### `structure`
](#analyze-structure)
+ [

### `expression-syntax`
](#analyze-expression-syntax)
+ [

### `data-type`
](#analyze-data-type)
+ [

### `referenced-data`
](#analyze-referenced-data)
+ [

### `referenced-resource`
](#analyze-referenced-resource)

### `Location`


An analysis result with information about `Location`, corresponds to the following error message: 
+ **Message** – Contains additional information about the analysis result. This can be an information, warning, or error message.

#### Solution


   You might receive this error message if you specified an action that AWS IoT Events currently doesn't support. For a list of supported actions, see [Supported actions to receive data and trigger actions in AWS IoT Events](iotevents-supported-actions.md).

### `supported-actions`


An analysis result with information about `supported‐actions`, corresponds to the following error messages: 
+ **Message:** Invalid action type present in action definition: *action-definition*.

#### Solution


   You might receive this error message if you specified an action that AWS IoT Events currently doesn't support. For a list of supported actions, see [Supported actions to receive data and trigger actions in AWS IoT Events](iotevents-supported-actions.md).
+ **Message:** DetectorModel definition has an *aws-service* action, but the *aws-service* service is not supported in the region *region-name*.

#### Solution


   You might receive this error message if the action that you specified is supported by AWS IoT Events, but the action isn't available in your current Region. This might occur when you try to send data to an AWS service that isn't available in the Region. You must also choose the same Region for both AWS IoT Events and the AWS services that you're using.

### `service-limits`


An analysis result with information about `service‐limits`, corresponds to the following error messages: 
+ **Message:** Content Expression allowed in payload exceeded the limit *content-expression-size* bytes in event *event-name* in state *state-name*.

#### Solution


   You might receive this error message if the content expression for your action payload is greater than 1024 bytes. The size of the content expression for a payload can be up to 1024 bytes.
+ **Message:** Number of states allowed in detector model definition exceeded the limit *states-per-detector-model*.

#### Solution


   You might receive this error message if your detector model has more than 20 states. A detector model can have up to 20 states.
+ **Message:** The duration for timer *timer-name* should be at least *minimum-timer-duration* seconds long.

#### Solution


   You might receive this error message if the duration of your timer is less than 60 seconds. We recommend that the duration of a timer is between 60 and 31622400 seconds. If you specify an expression for the duration of your timer, the evaluated result of the duration expression is rounded down to the nearest whole number.
+ **Message:** Number of actions allowed per event exceeded the limit *actions-per-event* in detector model definition

#### Solution


   You might receive this error message if the event has more than 10 actions. You can have up to 10 actions for each event in your detector model.
+ **Message:** Number of transition events allowed per state exceeded the limit *transition-events-per-state* in detector model definition.

#### Solution


   You might receive this error message if the state has more than 20 transition events. You can have up to 20 transition events for each state in your detector model.
+ **Message:** Number of events allowed per state exceeded the limit *events-per-state* in detector model definition

#### Solution


   You might receive this error message if the state has more than 20 events. You can have up to 20 events for each state in your detector model.
+ **Message:** The maximum number of detector models that can be associated with a single input may have reached the limit. Input *input-name* is used in *detector-models-per-input* detector model routes.

#### Solution


   You might receive this warning message if you tried to route an input to more than 10 detector models. You can have up to 10 different detector models associated with a single detector model.

### `structure`


An analysis result with information about `structure`, corresponds to the following error messages: 
+ **Message:** Actions may only have one type defined, but found an action with *number-of-types* types. Please split into separate Actions.

#### Solution


   You might receive this error message if you specified two or more actions in a single field by using API operations to create or update your detector model. You can define an array of `Action` objects. Make sure that you define each action as a separate object.
+ **Message:** The TransitionEvent *transition-event-name* transitions to a non-existent state *state-name*.

#### Solution


   You might receive this error message if AWS IoT Events couldn't find the next state that your transition event referenced. Make sure that the next state is defined and that you entered the correct state name.
+ **Message:** The DetectorModelDefinition had a shared state name: found state *state-name* with *number-of-states* repetitions.

#### Solution


   You might receive this error message if you use the same name for one or more states. Make sure that you give a unique name to each state in your detector model. The state name must have 1-128 characters. Valid characters: a-z, A-Z, 0-9, \$1 (underscore), and - (hyphen).
+ **Message:** The Definition's initialStateName *initial-state-name* did not correspond to a defined State.

#### Solution


   You might receive this error message if the initial state name is incorrect. The detector model remains in the initial (start) state until an input arrives. Once an input arrives, the detector model immediately transitions to the next state. Make sure that the initial state name is the name of a defined state and that you enter the correct name.
+ **Message:** Detector Model Definition must use at least one Input in a condition.

#### Solution


   You might receive this error if you didn't specify an input in a condition. You must use at least one input in at least one condition. Otherwise, AWS IoT Events doesn't evaluate incoming data.
+ **Message:** Only one of seconds and durationExpression can be set in SetTimer.

#### Solution


   You might receive this error message if you used both `seconds` and `durationExpression` for your timer. Make sure that you use either `seconds` or `durationExpression` as the parameters of `SetTimerAction`. For more information, see [SetTimerAction](https://docs.aws.amazon.com/iotevents/latest/apireference/API_SetTimerAction.html) in the *AWS IoT Events API Reference*.
+  **Message:** An action in your detector model is unreachable. Check the condition that initiates the action. 

#### Solution


   If an action in your detector model is unreachable, the event's condition evaluates to false. Check the condition of the event that contains the action, to ensure that it evaluates to true. When the event's condition evaluates to true, the action should become reachable.
+ **Message:** An input attribute is being read, but this may be caused by a timer expiration.

#### Solution


   An input attribute’s value can be read when either of the following occurs: 
  + A new input value has been received.
  + When a timer in the detector has expired.

  

  To ensure that an input attribute is being evaluated only when the new value for that input is received, include a call to the `triggerType(“Message”)` function in your condition as follows:

  The original condition being evaluated in the detector model: 

  ```
  if ($input.HeartBeat.status == “OFFLINE”)
  ```

  would become similar to the following: 

  ```
  if ( triggerType("MESSAGE") &&  $input.HeartBeat.status == “OFFLINE”)
  ```

  where a call to the `triggerType(“Message”)` function comes before the initial input provided in the condition. By using this technique, the `triggerType("Message")` function will evaluate to true and satisfy the condition of receiving a new input value. For more information about the usage of the `triggerType` function, search for `triggerType` in the [Expressions](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-expressions.html) section in the *AWS IoT Events Developer Guide* 
+ **Message:** A state in your detector model is unreachable. Check the condition that will cause a transition to the desired state.

#### Solution


   If a state in your detector model is unreachable, a condition that causes an incoming transition to that state evaluates to false. Check that the conditions of the incoming transitions to that unreachable state in your detector model evaluates to true, so the desired state can become reachable.
+ **Message:** An expiring timer can cause an unexpected amount of messages to be sent.

#### Solution


   To prevent your detector model from entering into an infinite state of sending an unexpected amount of messages because a timer has expired, consider using a call to the `triggerType("Message")` function, in the conditions of your detector model as follows: 

  The original condition being evaluated in the detector model: 

  ```
  if (timeout("awake"))
  ```

  would be transformed into a condition that looks similar to the following: 

  ```
   if (triggerType("MESSAGE") && timeout("awake")) 
  ```

  where a call to the `triggerType(“Message”)` function comes before the initial input provided in the condition.

  This change prevents initiating timer actions in your detector, preventing an infinite loop of messages being sent. For more information about how to use timer actions in your detector, see the [Using built-in actions](https://docs.aws.amazon.com/iotevents/latest/developerguide/built-in-actions.html) page of the *AWS IoT Events Developer Guide*

### `expression-syntax`


An analysis result with information about `expression‐syntax`, corresponds to the following error messages: 
+ **Message:** Your payload expression \$1*expression*\$1 isn't valid. The defined payload type is JSON, so you must specify an expression that AWS IoT Events would evaluate to a string.

#### Solution


   If the specified payload type is JSON, AWS IoT Events first checks if the service can evaluate your expression to a string. The evaluated result can't be a Boolean or number. If the validation doesn't succeed, you might receive this error.
+ **Message:** `SetVariableAction.value` must be an expression. Failed to parse value '*variable-value*'

#### Solution


   You can use `SetVariableAction` to define a variable with a `name` and `value`. The `value` can be a string, number, or Boolean value. You can also specify an expression for the `value`. For more information, see [SetVariableAction](https://docs.aws.amazon.com/iotevents/latest/apireference/API_SetVariableAction.html), in the *AWS IoT Events API Reference*.
+ **Message:** We couldn't parse your expression of the attributes (*attribute-name*) for the DynamoDB action. Enter expression with the correct syntax.

#### Solution


   You must use expressions for all parameters in `DynamoDBAction`. substitution templates. For more information, see [DynamoDBAction](https://docs.aws.amazon.com/iotevents/latest/apireference/API_DynamoDBAction.html) in the *AWS IoT Events API Reference*.
+ **Message:** We couldn't parse your expression of the tableName for the DynamoDBv2 action. Enter expression with the correct syntax.

#### Solution


   The `tableName` in `DynamoDBv2Action` must be a string. You must use an expression for the `tableName`. The expressions accept literals, operators, functions, references, and substitution templates. For more information, see [DynamoDBv2Action](https://docs.aws.amazon.com/iotevents/latest/apireference/API_DynamoDBv2Action.html) in the *AWS IoT Events API Reference*.
+ **Message:** We couldn't evaluate your expression to valid JSON. The DynamoDBv2 action only supports the JSON payload type.

#### Solution


   The payload type for `DynamoDBv2` must be JSON. Make sure that AWS IoT Events can evaluate your content expression for the payload to valid JSON. For more information, see [DynamoDBv2Action](https://docs.aws.amazon.com/iotevents/latest/apireference/API_DynamoDBv2Action.html), in the *AWS IoT Events API Reference*. 
+ **Message:** We couldn't parse your content expression for the payload of *action-type*. Enter a content expression with the correct syntax.

#### Solution


   The content expression can contain strings ('*string*'), variables (\$1variable.*variable-name*), input values (\$1input.*input-name*.*path-to-datum*), string concatenations, and strings that contain `${}`. 
+ **Message:** Customized Payloads must be non-empty.

#### Solution


   You might receive this error message, if you chose **Custom payload** for your action and didn't enter a content expression in the AWS IoT Events console. If you choose **Custom payload**, you must enter a content expression under **Custom payload**. For more information, see [Payload](https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html) in the *AWS IoT Events API Reference*.
+ **Message:** Failed to parse duration expression '*duration-expression*' for timer '*timer-name*'.

#### Solution


   The evaluated result of your duration expression for the timer must be a value between 60–31622400. The evaluated result of the duration is rounded down to the nearest whole number.
+ **Message:** Failed to parse expression '*expression*' for *action-name*

#### Solution


   You might receive this message if the expression for the specified action has incorrect syntax. Make sure that you enter an expression with the correct syntax. For more information, see [Syntax to filter device data and define actions in AWS IoT Events](iotevents-expressions.md#expression-syntax).
+ **Message:** Your *fieldName* for `IotSitewiseAction` couldn't be parsed. You must use correct syntax in your expression.

#### Solution


   You might receive this error if AWS IoT Events couldn't parse your *fieldName* for `IotSitewiseAction`. Make sure the *fieldName* uses an expression that AWS IoT Events can parse. For more information, see [IotSiteWiseAction](https://docs.aws.amazon.com/iotevents/latest/apireference/API_IotSiteWiseAction.html) in the *AWS IoT Events API Reference*.

### `data-type`


An analysis result with information about `data‐type`, corresponds to the following error messages: 
+ **Message:** Duration expression *duration-expression* for timer *timer-name* is not valid, it must return a number.

#### Solution


   You might receive this error message if AWS IoT Events couldn't evaluate the duration expression for your timer to a number. Make sure that your `durationExpression` can be converted to a number. Other data types, such as Boolean, aren't supported. 
+ **Message:** Expression *condition-expression* is not a valid condition expression.

#### Solution


   You might receive this error message if AWS IoT Events couldn't evaluate your `condition-expression` to a Boolean value. The Boolean value must be either `TRUE` or `FALSE`. Make sure that your condition expression can be converted to a Boolean value. If the result isn't a Boolean value, it's equivalent to `FALSE` and doesn't invoke the actions or transition to the `nextState` specified in the event.
+ **Message:** Incompatible data types [*inferred-types*] found for *reference* in the following expression: *expression*

#### Solution


   **Solution**: All expressions for the same input attribute or variable in the detector model must reference the same data type. 

  Use the following information to resolve the issue:<a name="expression-reference-type-compatibility"></a>
  + When you use a reference as an operand with one or more operators, make sure that all data types that you reference are compatible.

    For example, in the following expression, integer `2` is an operand of both the `==` and `&&` operators. To ensure that the operands are compatible, `$variable.testVariable + 1` and `$variable.testVariable` must reference an integer or decimal.

    In addition, integer `1` is an operand of the `+` operator. Therefore, `$variable.testVariable` must reference an integer or decimal.

    ```
    ‘$variable.testVariable + 1 == 2 && $variable.testVariable’
    ```
  + When you use a reference as an argument passed to a function, make sure that the function supports the data types that you reference.

    For example, the following `timeout("time-name")` function requires a string with double quotes as the argument. If you use a reference for the *timer-name* value, you must reference a string with double quotes.

    ```
    timeout("timer-name")
    ```
**Note**  
For the `convert(type, expression)` function, if you use a reference for the *type* value, the evaluated result of your reference must be `String`, `Decimal`, or `Boolean`.

  For more information, see [AWS IoT Events reference for inputs and variables in expressions](iotevents-expressions.md#expression-reference).
+ **Message:** Incompatible data types [*inferred-types*] used with *reference*. This may lead to a runtime error.

#### Solution


   You might receive this warning message if two expressions for the same input attribute or variable reference two data types. Make sure that your expressions for the same input attribute or variable reference the same data type in the detector model.
+ **Message:** The data types [*inferred‐types*] that you entered for the operator [*operator*] aren't compatible for the following expression: '*expression*'

#### Solution


   You might receive this error message if your expression combines data types that are not compatible with a specified operator. For example, in the following expression, the operator `+` is compatible with Integer, Decimal, and String data types, but not operands of Boolean data type.

  ```
  true + false
  ```

  You must make sure that the data types you use with an operator are compatible.
+ **Message:** The data types [*inferred‐types*] found for *input‐attribute* aren't compatible and can lead to a runtime error.

#### Solution


   You might receive this error message if two expressions for the same input attribute reference two data types for either the `OnEnterLifecycle` of a state, or for both the `OnInputLifecycle` and `OnExitLifecycle` of a state. Make sure your expressions in `OnEnterLifecycle` (or, both `OnInputLifecycle` and `OnExitLifecycle`) reference the same data type for each state of your detector model.
+ **Message:** The payload expression [*expression*] isn't valid. Specify an expression that would evaluate to a string at runtime because the payload type is JSON format.

#### Solution


   You might receive this error if your specified payload type is JSON, but AWS IoT Events can't evaluate its expression to a String. Make sure the evaluated result is a String, not a Boolean or a number. 
+ **Message:** Your interpolated expression \$1*interpolated-expression*\$1 must evaluate to either an integer or a Boolean value at runtime. Otherwise, your payload expression \$1*payload-expression*\$1 won't be parseable at runtime as valid JSON.

#### Solution


   You might receive this error message if AWS IoT Events couldn't evaluate your interpolated expression to an integer or a Boolean value. Make sure your interpolated expression can be converted to an integer or a Boolean value, because other data types, such as tring, aren't supported.
+ **Message:** The expression type in the `IotSitewiseAction` field *expression* is defined as type *defined‐type* and inferred as type *inferred‐type*. The defined type and the inferred type must be the same.

#### Solution


   You might receive this error message if your expression in the `propertyValue` of `IotSitewiseAction` has a data type defined differently than the data type inferred by AWS IoT Events. Make sure you use the same data type for all instances of this expression in your detector model.
+ **Message:** The data types [*inferred-types*] used for `setTimer` action don't evaluate to `Integer` for the following expression: *expression*

#### Solution


   You might receive this error message if the inferred data type for your duration expression isn't Integer or Decimal. Make sure your `durationExpression` can be converted to a number. Other data types, such as Boolean and String, aren't supported.
+ **Message:** The data types [*inferred-types*] used with operands of the comparison operator [*operator*] are not compatible in the following expression: *expression*

#### Solution


   The inferred data types for the operands of the *operator* in the conditional expression (*expression*) of your detector model don't match. The operands must be used with the matching data types in all other parts of your detector model.

**Tip**  
You can use `convert` to change the data type of an expression in your detector model. For more information, see [Functions to use in AWS IoT Events expressions](iotevents-expressions.md#expression-function).

### `referenced-data`


An analysis result with information about `referenced‐data`, corresponds to the following error messages: 
+ **Message:** Detected broken Timer: timer *timer-name* is used in an expression but is never set.

#### Solution


   You might receive this error message if you use a timer that isn't set. You must set a timer before you use it in an expression. Also, make sure that you enter the correct timer name.
+ **Message:** Detected broken Variable: variable *variable-name* is used in an expression but is never set.

#### Solution


   You might receive this error message if you use a variable that isn't set. You must set a variable before you use it in an expression. Also, make sure that you enter the correct variable name.
+ **Message:** Detected broken Variable: a variable is used in an expression before being set to a value.

#### Solution


   Each variable must be assigned to a value before it can be evaluated in an expression. Set the value of the variable before every use so its value can be retrieved. Also, make sure that you enter the correct variable name.

### `referenced-resource`


An analysis result with information about `referenced‐resource`, corresponds to the following error messages: 
+ **Message:** Detector Model Definition contains reference to Input that does not exist.

#### Solution


   You might receive this error message if you use expressions to reference an input that doesn't exist. Make sure that your expression references an existing input and enter the correct input name. If you don't have an input, create one first.
+ **Message:** Detector Model Definition contains invalid InputName: *input-name*

#### Solution


   You might receive this error message if your detector model contains an invalid input name. Make sure that you enter the correct input name. The input name must have 1-128 characters. Valid characters: a-z, A-Z, 0-9, \$1 (underscore), and - (hyphen).

# Analyze a detector model for AWS IoT Events (Console)
Analyze a detector model (Console)

AWS IoT Events allows you to monitor and react to IoT data by detecting events and triggering actions with the AWS IoT Events API. The following steps use the AWS IoT Events console to analyze a detector model.

**Note**  
After AWS IoT Events starts analyzing your detector model, you have up to 24 hours to retrieve the analysis results.

A detector model analysis can help you optimize your models, identify potential issues, and ensure they're functioning as intended. For example, on a windfarm, the detector model analysis could reveal if the model correctly identifies potential gear failures based on abnormal vibration patterns. Or, if the model accurately triggers maintenance alerts when wind speeds exceed safe operating thresholds. By refining a model based on the analysis, you can improve predictive maintenance, reduce downtime, and enhance overall energy production efficiency.

**To analyze a detector model**

1. Sign in to the [AWS IoT Events console](https://console.aws.amazon.com/iotevents/).

1. In the navigation pane, choose **Detector models**.

1. Under **Detector models**, choose the target detector model.

1. On your detector model page, choose **Edit**.

1. In the upper-right corner, choose **Run analysis**.  
![\[Screenshot of how to analyze detector models in the AWS IoT Events console.\]](http://docs.aws.amazon.com/iotevents/latest/developerguide/images/analyzeAPI1.png)

   The following is an example analysis result in the AWS IoT Events console.  
![\[Screenshot of how to analyze detector models in the AWS IoT Events console.\]](http://docs.aws.amazon.com/iotevents/latest/developerguide/images/analyzeAPI2.png)

# Analyze a detector model in AWS IoT Events (AWS CLI)
Analyze a detector model (AWS CLI)

Analyzing your AWS IoT Events detector models programmatically provides valuable insights into their structure, behavior, and performance. This API-based approach allows for automated analysis, integration with your existing workflows, and the ability to perform bulk operations across multiple detector models. By leveraging the [StartDetectorModelAnalysis](https://docs.aws.amazon.com/iotevents/latest/apireference/API_StartDetectorModelAnalysis.html) API, you can initiate in-depth examinations of your models, helping you identify potential issues, optimize logic flows, and ensure that your IoT event processing aligns with your business requirements.

The following steps use the AWS CLI to analyze a detector model.

**To analyze a detector model using AWS CLI**

1. Run the following command to start an analysis.

   ```
   aws iotevents start-detector-model-analysis --cli-input-json file://file-name.json
   ```
**Note**  
Replace *file-name* with the name of the file that contains the detector model definition.  
**Example Detector model definition**  

   ```
   {
       "detectorModelDefinition": {
           "states": [
               {
                   "stateName": "TemperatureCheck",
                   "onInput": {
                       "events": [
                           {
                               "eventName": "Temperature Received",
                               "condition": "isNull($input.TemperatureInput.sensorData.temperature)==false",
                               "actions": [
                                   {
                                       "iotTopicPublish": {
                                           "mqttTopic": "IoTEvents/Output"
                                       }
                                   }
                               ]
                           }
                       ],
                       "transitionEvents": []
                   },
                   "onEnter": {
                       "events": [
                           {
                               "eventName": "Init",
                               "condition": "true",
                               "actions": [
                                   {
                                       "setVariable": {
                                           "variableName": "temperatureChecked",
                                           "value": "0"
                                       }
                                   }
                               ]
                           }
                       ]
                   },
                   "onExit": {
                       "events": []
                   }
               }
           ],
           "initialStateName": "TemperatureCheck"
       }
   }
   ```

   If you use the AWS CLI to analyze an existing detector model, choose one of the following to retrieve the detector model definition:
   + If you want to use the AWS IoT Events console, do the following:

     1. In navigation pane, choose **Detector models**.

     1. Under **Detector models**, choose the target detector model.

     1. Choose **Export detector model** from **Action** to download the detector model. The detector model is saved in JSON.

     1. Open the detector model JSON file.

     1. You only need the `detectorModelDefinition` object. Remove the following:
        + The first curly bracket (`{`) at the top of the page
        + The `detectorModel` line
        + The `detectorModelConfiguration` object
        + The last curly bracket (`}`) at the bottom of the page

     1. Save the file.
   + If you want to use the AWS CLI, do the following:

     1. Run the following command in a terminal.

        ```
        aws iotevents describe-detector-model --detector-model-name detector-model-name
        ```

     1. Replace *detector-model-name* with the name of your detector model.

     1. Copy the `detectorModelDefinition` object to a text editor.

     1. Add curly brackets (`{}`) outside of the `detectorModelDefinition`.

     1. Save the file in JSON.  
**Example response**  

   ```
   {
       "analysisId": "c1133390-14e3-4204-9a66-31efd92a4fed"
   }
   ```

1. Copy the analysis ID from the output.

1. Run the following command to retrieve the status of the analysis.

   ```
   aws iotevents describe-detector-model-analysis --analysis-id "analysis-id"
   ```
**Note**  
Replace *analysis-id* with the analysis ID that you copied.  
**Example response**  

   ```
   {
       "status": "COMPLETE"
   }
   ```

   The status can be one of the following values:
   + `RUNNING` – AWS IoT Events is analyzing your detector model. This process can take up to one minute to complete.
   + `COMPLETE` – AWS IoT Events finished analyzing your detector model.
   + `FAILED` – AWS IoT Events couldn't analyze your detector model. Try again later.

1. Run the following command to retrieve one or more analysis results of the detector model.
**Note**  
Replace *analysis-id* with the analysis ID that you copied.

   ```
   aws iotevents get-detector-model-analysis-results --analysis-id "analysis-id"
   ```  
**Example response**  

   ```
   {
       "analysisResults": [
           {
               "type": "data-type",
               "level": "INFO",
               "message": "Inferred data types [Integer] for $variable.temperatureChecked",
               "locations": []
           },
           {
               "type": "referenced-resource",
               "level": "ERROR",
               "message": "Detector Model Definition contains reference to Input 'TemperatureInput' that does not exist.",
               "locations": [
                   {
                       "path": "states[0].onInput.events[0]"
                   }
               ]
           }
       ]
   }
   ```

**Note**  
After AWS IoT Events starts analyzing your detector model, you have up to 24 hours to retrieve the analysis results.