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.
Analyze a detector model in Amazon IoT Events (Amazon CLI)
Analyzing your Amazon 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 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 Amazon CLI to analyze a detector model.
To analyze a detector model using Amazon CLI
-
Run the following command to start an analysis.
aws iotevents start-detector-model-analysis --cli-input-json file://
file-name
.jsonNote
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 Amazon CLI to analyze an existing detector model, choose one of the following to retrieve the detector model definition:
-
If you want to use the Amazon IoT Events console, do the following:
-
In navigation pane, choose Detector models.
-
Under Detector models, choose the target detector model.
-
Choose Export detector model from Action to download the detector model. The detector model is saved in JSON.
-
Open the detector model JSON file.
-
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
-
-
Save the file.
-
-
If you want to use the Amazon CLI, do the following:
-
Run the following command in a terminal.
aws iotevents describe-detector-model --detector-model-name
detector-model-name
-
Replace
detector-model-name
with the name of your detector model. -
Copy the
detectorModelDefinition
object to a text editor. -
Add curly brackets (
{}
) outside of thedetectorModelDefinition
. -
Save the file in JSON.
-
Example response
{ "analysisId": "c1133390-14e3-4204-9a66-31efd92a4fed" }
-
-
Copy the analysis ID from the output.
-
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
– Amazon IoT Events is analyzing your detector model. This process can take up to one minute to complete. -
COMPLETE
– Amazon IoT Events finished analyzing your detector model. -
FAILED
– Amazon IoT Events couldn't analyze your detector model. Try again later.
-
-
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 Amazon IoT Events starts analyzing your detector model, you have up to 24 hours to retrieve the analysis results.