IoTEvents.Client.
create_alarm_model
(**kwargs)¶Creates an alarm model to monitor an AWS IoT Events input attribute. You can use the alarm to get notified when the value is outside a specified range. For more information, see Create an alarm model in the AWS IoT Events Developer Guide .
See also: AWS API Documentation
Request Syntax
response = client.create_alarm_model(
alarmModelName='string',
alarmModelDescription='string',
roleArn='string',
tags=[
{
'key': 'string',
'value': 'string'
},
],
key='string',
severity=123,
alarmRule={
'simpleRule': {
'inputProperty': 'string',
'comparisonOperator': 'GREATER'|'GREATER_OR_EQUAL'|'LESS'|'LESS_OR_EQUAL'|'EQUAL'|'NOT_EQUAL',
'threshold': 'string'
}
},
alarmNotification={
'notificationActions': [
{
'action': {
'lambdaAction': {
'functionArn': 'string',
'payload': {
'contentExpression': 'string',
'type': 'STRING'|'JSON'
}
}
},
'smsConfigurations': [
{
'senderId': 'string',
'additionalMessage': 'string',
'recipients': [
{
'ssoIdentity': {
'identityStoreId': 'string',
'userId': 'string'
}
},
]
},
],
'emailConfigurations': [
{
'from': 'string',
'content': {
'subject': 'string',
'additionalMessage': 'string'
},
'recipients': {
'to': [
{
'ssoIdentity': {
'identityStoreId': 'string',
'userId': 'string'
}
},
]
}
},
]
},
]
},
alarmEventActions={
'alarmActions': [
{
'sns': {
'targetArn': 'string',
'payload': {
'contentExpression': 'string',
'type': 'STRING'|'JSON'
}
},
'iotTopicPublish': {
'mqttTopic': 'string',
'payload': {
'contentExpression': 'string',
'type': 'STRING'|'JSON'
}
},
'lambda': {
'functionArn': 'string',
'payload': {
'contentExpression': 'string',
'type': 'STRING'|'JSON'
}
},
'iotEvents': {
'inputName': 'string',
'payload': {
'contentExpression': 'string',
'type': 'STRING'|'JSON'
}
},
'sqs': {
'queueUrl': 'string',
'useBase64': True|False,
'payload': {
'contentExpression': 'string',
'type': 'STRING'|'JSON'
}
},
'firehose': {
'deliveryStreamName': 'string',
'separator': 'string',
'payload': {
'contentExpression': 'string',
'type': 'STRING'|'JSON'
}
},
'dynamoDB': {
'hashKeyType': 'string',
'hashKeyField': 'string',
'hashKeyValue': 'string',
'rangeKeyType': 'string',
'rangeKeyField': 'string',
'rangeKeyValue': 'string',
'operation': 'string',
'payloadField': 'string',
'tableName': 'string',
'payload': {
'contentExpression': 'string',
'type': 'STRING'|'JSON'
}
},
'dynamoDBv2': {
'tableName': 'string',
'payload': {
'contentExpression': 'string',
'type': 'STRING'|'JSON'
}
},
'iotSiteWise': {
'entryId': 'string',
'assetId': 'string',
'propertyId': 'string',
'propertyAlias': 'string',
'propertyValue': {
'value': {
'stringValue': 'string',
'integerValue': 'string',
'doubleValue': 'string',
'booleanValue': 'string'
},
'timestamp': {
'timeInSeconds': 'string',
'offsetInNanos': 'string'
},
'quality': 'string'
}
}
},
]
},
alarmCapabilities={
'initializationConfiguration': {
'disabledOnInitialization': True|False
},
'acknowledgeFlow': {
'enabled': True|False
}
}
)
[REQUIRED]
A unique name that helps you identify the alarm model. You can't change this name after you create the alarm model.
[REQUIRED]
The ARN of the IAM role that allows the alarm to perform actions and access AWS resources. For more information, see Amazon Resource Names (ARNs) in the AWS General Reference .
A list of key-value pairs that contain metadata for the alarm model. The tags help you manage the alarm model. For more information, see Tagging your AWS IoT Events resources in the AWS IoT Events Developer Guide .
You can create up to 50 tags for one alarm model.
Metadata that can be used to manage the resource.
The tag's key.
The tag's value.
[REQUIRED]
Defines when your alarm is invoked.
A rule that compares an input property value to a threshold value with a comparison operator.
The value on the left side of the comparison operator. You can specify an AWS IoT Events input attribute as an input property.
The comparison operator.
The value on the right side of the comparison operator. You can enter a number or specify an AWS IoT Events input attribute.
Contains information about one or more notification actions.
Contains the notification settings of an alarm model. The settings apply to all alarms that were created based on this alarm model.
Contains the notification settings of an alarm model. The settings apply to all alarms that were created based on this alarm model.
Specifies an AWS Lambda function to manage alarm notifications. You can create one or use the AWS Lambda function provided by AWS IoT Events.
Calls a Lambda function, passing in information about the detector model instance and the event that triggered the action.
The ARN of the Lambda function that is executed.
You can configure the action payload when you send a message to a Lambda function.
The content of the payload. You can use a string expression that includes quoted strings ( '<string>'
), variables ( $variable.<variable-name>
), input values ( $input.<input-name>.<path-to-datum>
), string concatenations, and quoted strings that contain ${}
as the content. The recommended maximum size of a content expression is 1 KB.
The value of the payload type can be either STRING
or JSON
.
Contains the configuration information of SMS notifications.
Contains the configuration information of SMS notifications.
The sender ID.
The message that you want to send. The message can be up to 200 characters.
Specifies one or more recipients who receive the message.
Warning
You must add the users that receive SMS messages to your AWS SSO store.
The information that identifies the recipient.
The AWS Single Sign-On (AWS SSO) authentication information.
The ID of the AWS SSO identity store.
The user ID.
Contains the configuration information of email notifications.
Contains the configuration information of email notifications.
The email address that sends emails.
Warning
If you use the AWS IoT Events managed AWS Lambda function to manage your emails, you must verify the email address that sends emails in Amazon SES.
Contains the subject and message of an email.
The subject of the email.
The message that you want to send. The message can be up to 200 characters.
Contains the information of one or more recipients who receive the emails.
Warning
You must add the users that receive emails to your AWS SSO store.
Specifies one or more recipients who receive the email.
The information that identifies the recipient.
The AWS Single Sign-On (AWS SSO) authentication information.
The ID of the AWS SSO identity store.
The user ID.
Contains information about one or more alarm actions.
Specifies one or more supported actions to receive notifications when the alarm state changes.
Specifies one of the following actions to receive notifications when the alarm state changes.
Information required to publish the Amazon SNS message.
The ARN of the Amazon SNS target where the message is sent.
You can configure the action payload when you send a message as an Amazon SNS push notification.
The content of the payload. You can use a string expression that includes quoted strings ( '<string>'
), variables ( $variable.<variable-name>
), input values ( $input.<input-name>.<path-to-datum>
), string concatenations, and quoted strings that contain ${}
as the content. The recommended maximum size of a content expression is 1 KB.
The value of the payload type can be either STRING
or JSON
.
Information required to publish the MQTT message through the AWS IoT message broker.
The MQTT topic of the message. You can use a string expression that includes variables ( $variable.<variable-name>
) and input values ( $input.<input-name>.<path-to-datum>
) as the topic string.
You can configure the action payload when you publish a message to an AWS IoT Core topic.
The content of the payload. You can use a string expression that includes quoted strings ( '<string>'
), variables ( $variable.<variable-name>
), input values ( $input.<input-name>.<path-to-datum>
), string concatenations, and quoted strings that contain ${}
as the content. The recommended maximum size of a content expression is 1 KB.
The value of the payload type can be either STRING
or JSON
.
Calls a Lambda function, passing in information about the detector model instance and the event that triggered the action.
The ARN of the Lambda function that is executed.
You can configure the action payload when you send a message to a Lambda function.
The content of the payload. You can use a string expression that includes quoted strings ( '<string>'
), variables ( $variable.<variable-name>
), input values ( $input.<input-name>.<path-to-datum>
), string concatenations, and quoted strings that contain ${}
as the content. The recommended maximum size of a content expression is 1 KB.
The value of the payload type can be either STRING
or JSON
.
Sends an AWS IoT Events input, passing in information about the detector model instance and the event that triggered the action.
The name of the AWS IoT Events input where the data is sent.
You can configure the action payload when you send a message to an AWS IoT Events input.
The content of the payload. You can use a string expression that includes quoted strings ( '<string>'
), variables ( $variable.<variable-name>
), input values ( $input.<input-name>.<path-to-datum>
), string concatenations, and quoted strings that contain ${}
as the content. The recommended maximum size of a content expression is 1 KB.
The value of the payload type can be either STRING
or JSON
.
Sends information about the detector model instance and the event that triggered the action to an Amazon SQS queue.
The URL of the SQS queue where the data is written.
Set this to TRUE if you want the data to be base-64 encoded before it is written to the queue. Otherwise, set this to FALSE.
You can configure the action payload when you send a message to an Amazon SQS queue.
The content of the payload. You can use a string expression that includes quoted strings ( '<string>'
), variables ( $variable.<variable-name>
), input values ( $input.<input-name>.<path-to-datum>
), string concatenations, and quoted strings that contain ${}
as the content. The recommended maximum size of a content expression is 1 KB.
The value of the payload type can be either STRING
or JSON
.
Sends information about the detector model instance and the event that triggered the action to an Amazon Kinesis Data Firehose delivery stream.
The name of the Kinesis Data Firehose delivery stream where the data is written.
A character separator that is used to separate records written to the Kinesis Data Firehose delivery stream. Valid values are: 'n' (newline), 't' (tab), 'rn' (Windows newline), ',' (comma).
You can configure the action payload when you send a message to an Amazon Kinesis Data Firehose delivery stream.
The content of the payload. You can use a string expression that includes quoted strings ( '<string>'
), variables ( $variable.<variable-name>
), input values ( $input.<input-name>.<path-to-datum>
), string concatenations, and quoted strings that contain ${}
as the content. The recommended maximum size of a content expression is 1 KB.
The value of the payload type can be either STRING
or JSON
.
Defines an action to write to the Amazon DynamoDB table that you created. The standard action payload contains all the information about the detector model instance and the event that triggered the action. You can customize the payload. One column of the DynamoDB table receives all attribute-value pairs in the payload that you specify.
You must use expressions for all parameters in DynamoDBAction
. The expressions accept literals, operators, functions, references, and substitution templates.
Examples
hashKeyType
parameter can be 'STRING'
.hashKeyField
parameter can be $input.GreenhouseInput.name
.${}
, and the template must be in single quotes. A substitution template can also contain a combination of literals, operators, functions, references, and substitution templates. In the following example, the value for the hashKeyValue
parameter uses a substitution template. '${$input.GreenhouseInput.temperature * 6 / 5 + 32} in Fahrenheit'
+
. A string concatenation can also contain a combination of literals, operators, functions, references, and substitution templates. In the following example, the value for the tableName
parameter uses a string concatenation. 'GreenhouseTemperatureTable ' + $input.GreenhouseInput.date
For more information, see Expressions in the AWS IoT Events Developer Guide .
If the defined payload type is a string, DynamoDBAction
writes non-JSON data to the DynamoDB table as binary data. The DynamoDB console displays the data as Base64-encoded text. The value for the payloadField
parameter is <payload-field>_raw
.
The data type for the hash key (also called the partition key). You can specify the following values:
'STRING'
- The hash key is a string.'NUMBER'
- The hash key is a number.If you don't specify hashKeyType
, the default value is 'STRING'
.
The name of the hash key (also called the partition key). The hashKeyField
value must match the partition key of the target DynamoDB table.
The value of the hash key (also called the partition key).
The data type for the range key (also called the sort key), You can specify the following values:
'STRING'
- The range key is a string.'NUMBER'
- The range key is number.If you don't specify rangeKeyField
, the default value is 'STRING'
.
The name of the range key (also called the sort key). The rangeKeyField
value must match the sort key of the target DynamoDB table.
The value of the range key (also called the sort key).
The type of operation to perform. You can specify the following values:
'INSERT'
- Insert data as a new item into the DynamoDB table. This item uses the specified hash key as a partition key. If you specified a range key, the item uses the range key as a sort key.'UPDATE'
- Update an existing item of the DynamoDB table with new data. This item's partition key must match the specified hash key. If you specified a range key, the range key must match the item's sort key.'DELETE'
- Delete an existing item of the DynamoDB table. This item's partition key must match the specified hash key. If you specified a range key, the range key must match the item's sort key.If you don't specify this parameter, AWS IoT Events triggers the 'INSERT'
operation.
The name of the DynamoDB column that receives the action payload.
If you don't specify this parameter, the name of the DynamoDB column is payload
.
The name of the DynamoDB table. The tableName
value must match the table name of the target DynamoDB table.
Information needed to configure the payload.
By default, AWS IoT Events generates a standard payload in JSON for any action. This action payload contains all attribute-value pairs that have the information about the detector model instance and the event triggered the action. To configure the action payload, you can use contentExpression
.
The content of the payload. You can use a string expression that includes quoted strings ( '<string>'
), variables ( $variable.<variable-name>
), input values ( $input.<input-name>.<path-to-datum>
), string concatenations, and quoted strings that contain ${}
as the content. The recommended maximum size of a content expression is 1 KB.
The value of the payload type can be either STRING
or JSON
.
Defines an action to write to the Amazon DynamoDB table that you created. The default action payload contains all the information about the detector model instance and the event that triggered the action. You can customize the payload. A separate column of the DynamoDB table receives one attribute-value pair in the payload that you specify.
You must use expressions for all parameters in DynamoDBv2Action
. The expressions accept literals, operators, functions, references, and substitution templates.
Examples
tableName
parameter can be 'GreenhouseTemperatureTable'
.tableName
parameter can be $variable.ddbtableName
.${}
, and the template must be in single quotes. A substitution template can also contain a combination of literals, operators, functions, references, and substitution templates. In the following example, the value for the contentExpression
parameter in Payload
uses a substitution template. '{\"sensorID\": \"${$input.GreenhouseInput.sensor_id}\", \"temperature\": \"${$input.GreenhouseInput.temperature * 9 / 5 + 32}\"}'
+
. A string concatenation can also contain a combination of literals, operators, functions, references, and substitution templates. In the following example, the value for the tableName
parameter uses a string concatenation. 'GreenhouseTemperatureTable ' + $input.GreenhouseInput.date
For more information, see Expressions in the AWS IoT Events Developer Guide .
The value for the type
parameter in Payload
must be JSON
.
The name of the DynamoDB table.
Information needed to configure the payload.
By default, AWS IoT Events generates a standard payload in JSON for any action. This action payload contains all attribute-value pairs that have the information about the detector model instance and the event triggered the action. To configure the action payload, you can use contentExpression
.
The content of the payload. You can use a string expression that includes quoted strings ( '<string>'
), variables ( $variable.<variable-name>
), input values ( $input.<input-name>.<path-to-datum>
), string concatenations, and quoted strings that contain ${}
as the content. The recommended maximum size of a content expression is 1 KB.
The value of the payload type can be either STRING
or JSON
.
Sends information about the detector model instance and the event that triggered the action to a specified asset property in AWS IoT SiteWise.
You must use expressions for all parameters in IotSiteWiseAction
. The expressions accept literals, operators, functions, references, and substitutions templates.
Examples
propertyAlias
parameter can be '/company/windfarm/3/turbine/7/temperature'
.assetId
parameter can be $input.TurbineInput.assetId1
.${}
, and the template must be in single quotes. A substitution template can also contain a combination of literals, operators, functions, references, and substitution templates. In the following example, the value for the propertyAlias
parameter uses a substitution template. 'company/windfarm/${$input.TemperatureInput.sensorData.windfarmID}/turbine/ ${$input.TemperatureInput.sensorData.turbineID}/temperature'
You must specify either propertyAlias
or both assetId
and propertyId
to identify the target asset property in AWS IoT SiteWise.
For more information, see Expressions in the AWS IoT Events Developer Guide .
A unique identifier for this entry. You can use the entry ID to track which data entry causes an error in case of failure. The default is a new unique identifier.
The ID of the asset that has the specified property.
The ID of the asset property.
The alias of the asset property.
The value to send to the asset property. This value contains timestamp, quality, and value (TQV) information.
The value to send to an asset property.
The asset property value is a string. You must use an expression, and the evaluated result should be a string.
The asset property value is an integer. You must use an expression, and the evaluated result should be an integer.
The asset property value is a double. You must use an expression, and the evaluated result should be a double.
The asset property value is a Boolean value that must be 'TRUE'
or 'FALSE'
. You must use an expression, and the evaluated result should be a Boolean value.
The timestamp associated with the asset property value. The default is the current event time.
The timestamp, in seconds, in the Unix epoch format. The valid range is between 1-31556889864403199.
The nanosecond offset converted from timeInSeconds
. The valid range is between 0-999999999.
The quality of the asset property value. The value must be 'GOOD'
, 'BAD'
, or 'UNCERTAIN'
.
Contains the configuration information of alarm state changes.
Specifies the default alarm state. The configuration applies to all alarms that were created based on this alarm model.
The value must be TRUE
or FALSE
. If FALSE
, all alarm instances created based on the alarm model are activated. The default value is TRUE
.
Specifies whether to get notified for alarm state changes.
The value must be TRUE
or FALSE
. If TRUE
, you receive a notification when the alarm state changes. You must choose to acknowledge the notification before the alarm state can return to NORMAL
. If FALSE
, you won't receive notifications. The alarm automatically changes to the NORMAL
state when the input property value returns to the specified range.
dict
Response Syntax
{
'creationTime': datetime(2015, 1, 1),
'alarmModelArn': 'string',
'alarmModelVersion': 'string',
'lastUpdateTime': datetime(2015, 1, 1),
'status': 'ACTIVE'|'ACTIVATING'|'INACTIVE'|'FAILED'
}
Response Structure
(dict) --
creationTime (datetime) --
The time the alarm model was created, in the Unix epoch format.
alarmModelArn (string) --
The ARN of the alarm model. For more information, see Amazon Resource Names (ARNs) in the AWS General Reference .
alarmModelVersion (string) --
The version of the alarm model.
lastUpdateTime (datetime) --
The time the alarm model was last updated, in the Unix epoch format.
status (string) --
The status of the alarm model. The status can be one of the following values:
ACTIVE
- The alarm model is active and it's ready to evaluate data.ACTIVATING
- AWS IoT Events is activating your alarm model. Activating an alarm model can take up to a few minutes.INACTIVE
- The alarm model is inactive, so it isn't ready to evaluate data. Check your alarm model information and update the alarm model.FAILED
- You couldn't create or update the alarm model. Check your alarm model information and try again.Exceptions
IoTEvents.Client.exceptions.InvalidRequestException
IoTEvents.Client.exceptions.ResourceInUseException
IoTEvents.Client.exceptions.ResourceAlreadyExistsException
IoTEvents.Client.exceptions.LimitExceededException
IoTEvents.Client.exceptions.ThrottlingException
IoTEvents.Client.exceptions.InternalFailureException
IoTEvents.Client.exceptions.ServiceUnavailableException