custom_metrics
Creates, updates, deletes or gets a custom_metric resource or lists custom_metrics in a region
Overview
| Name | custom_metrics |
| Type | Resource |
| Description | A custom metric published by your devices to Device Defender. |
| Id | awscc.iot.custom_metrics |
Fields
- get (all properties)
- list (identifiers only)
| Name | Datatype | Description |
|---|---|---|
metric_name | string | The name of the custom metric. This will be used in the metric report submitted from the device/thing. Shouldn't begin with aws: . Cannot be updated once defined. |
display_name | string | Field represents a friendly name in the console for the custom metric; it doesn't have to be unique. Don't use this name as the metric identifier in the device metric report. Can be updated once defined. |
metric_type | string | The type of the custom metric. Types include string-list, ip-address-list, number-list, and number. |
metric_arn | string | The Amazon Resource Number (ARN) of the custom metric. |
tags | array | An array of key-value pairs to apply to this resource. |
region | string | AWS region. |
| Name | Datatype | Description |
|---|---|---|
metric_name | string | The name of the custom metric. This will be used in the metric report submitted from the device/thing. Shouldn't begin with aws: . Cannot be updated once defined. |
region | string | AWS region. |
For more information, see AWS::IoT::CustomMetric.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | custom_metrics | INSERT | MetricType, region |
delete_resource | custom_metrics | DELETE | Identifier, region |
update_resource | custom_metrics | UPDATE | Identifier, PatchDocument, region |
list_resources | custom_metrics_list_only | SELECT | region |
get_resource | custom_metrics | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
Gets all properties from an individual custom_metric.
SELECT
region,
metric_name,
display_name,
metric_type,
metric_arn,
tags
FROM awscc.iot.custom_metrics
WHERE
region = '{{ region }}' AND
Identifier = '{{ metric_name }}';
Lists all custom_metrics in a region.
SELECT
region,
metric_name
FROM awscc.iot.custom_metrics_list_only
WHERE
region = '{{ region }}';
INSERT example
Use the following StackQL query and manifest file to create a new custom_metric resource, using stack-deploy.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO awscc.iot.custom_metrics (
MetricType,
region
)
SELECT
'{{ metric_type }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
/*+ create */
INSERT INTO awscc.iot.custom_metrics (
MetricName,
DisplayName,
MetricType,
Tags,
region
)
SELECT
'{{ metric_name }}',
'{{ display_name }}',
'{{ metric_type }}',
'{{ tags }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: custom_metric
props:
- name: metric_name
value: '{{ metric_name }}'
- name: display_name
value: '{{ display_name }}'
- name: metric_type
value: '{{ metric_type }}'
- name: tags
value:
- key: '{{ key }}'
value: '{{ value }}'
UPDATE example
Use the following StackQL query and manifest file to update a custom_metric resource, using stack-deploy.
/*+ update */
UPDATE awscc.iot.custom_metrics
SET PatchDocument = string('{{ {
"DisplayName": display_name,
"Tags": tags
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ metric_name }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
DELETE example
/*+ delete */
DELETE FROM awscc.iot.custom_metrics
WHERE
Identifier = '{{ metric_name }}' AND
region = '{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
Additional Parameters
Mutable resources in the Cloud Control provider support additional optional parameters which can be supplied with INSERT, UPDATE, or DELETE operations. These include:
| Parameter | Description |
|---|---|
ClientToken | A unique identifier to ensure the idempotency of the resource request.This allows the provider to accurately distinguish between retries and new requests.A client token is valid for 36 hours once used. After that, a resource request with the same client token is treated as a new request. If you do not specify a client token, one is generated for inclusion in the request. |
RoleArn | The ARN of the IAM role used to perform this resource operation.The role specified must have the permissions required for this operation.If you do not specify a role, a temporary session is created using your AWS user credentials. |
TypeVersionId | For private resource types, the type version to use in this resource operation.If you do not specify a resource version, the default version is used. |
Permissions
To operate on the custom_metrics resource, the following permissions are required:
- Create
- Read
- Update
- Delete
- List
iot:CreateCustomMetric,
iot:TagResource
iot:DescribeCustomMetric,
iot:ListTagsForResource
iot:UpdateCustomMetric,
iot:ListTagsForResource,
iot:UntagResource,
iot:TagResource
iot:DescribeCustomMetric,
iot:DeleteCustomMetric
iot:ListCustomMetrics