AWS::IoT::CustomMetric - AWS CloudFormation

AWS::IoT::CustomMetric

Use the AWS::IoT::CustomMetric resource to define a custom metric published by your devices to Device Defender. For API reference, see CreateCustomMetric and for general information, see Custom metrics.

Syntax

To declare this entity in your AWS CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::IoT::CustomMetric", "Properties" : { "DisplayName" : String, "MetricName" : String, "MetricType" : String, "Tags" : [ Tag, ... ] } }

YAML

Type: AWS::IoT::CustomMetric Properties: DisplayName: String MetricName: String MetricType: String Tags: - Tag

Properties

DisplayName

The friendly name in the console for the custom metric. This name doesn't have to be unique. Don't use this name as the metric identifier in the device metric report. You can update the friendly name after you define it.

Required: No

Type: String

Maximum: 128

Update requires: No interruption

MetricName

The name of the custom metric. This will be used in the metric report submitted from the device/thing. The name can't begin with aws:. You can’t change the name after you define it.

Required: No

Type: String

Pattern: [a-zA-Z0-9:_-]+

Minimum: 1

Maximum: 128

Update requires: Replacement

MetricType

The type of the custom metric. Types include string-list, ip-address-list, number-list, and number.

Important

The type number only takes a single metric value as an input, but when you submit the metrics value in the DeviceMetrics report, you must pass it as an array with a single value.

Required: Yes

Type: String

Allowed values: string-list | ip-address-list | number-list | number

Update requires: Replacement

Tags

Metadata that can be used to manage the custom metric.

Required: No

Type: Array of Tag

Maximum: 50

Update requires: No interruption

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the custom metric name.

Fn::GetAtt

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.

MetricArn

The Amazon Resource Number (ARN) of the custom metric; for example, arn:aws-partition:iot:region:accountId:custommetric/metricName .

Examples

JSON

{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "Amazon Web Services IoT CustomMetric Sample Template", "Resources": { "BatteryPercentageMetric": { "Type": "AWS::IoT::CustomMetric", "Properties": { "MetricName": "batteryPercentage", "DisplayName": "Remaining battery percentage", "MetricType": "number" } } } }

YAML

AWSTemplateFormatVersion: '2010-09-09' Description: Amazon Web Services IoT CustomMetric Sample Template Resources: BatteryPercentageMetric: Type: AWS::IoT::CustomMetric Properties: MetricName: batteryPercentage DisplayName: Remaining battery percentage MetricType: number