Skip to main content

custom_metrics

Creates, updates, deletes, gets or lists a custom_metrics resource.

Overview

Namecustom_metrics
TypeResource
Idaws.iot.custom_metrics

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
creation_datestring (date-time)The creation date of the custom metric in milliseconds since epoch.
display_namestringField represents a friendly name in the console for the custom metric; doesn't have to be unique. Don't use this name as the metric identifier in the device metric report. Can be updated. (pattern: <code>[\p{Graph}\x20]*</code>)
last_modified_datestring (date-time)The time the custom metric was last modified in milliseconds since epoch.
metric_arnstringThe Amazon Resource Number (ARN) of the custom metric.
metric_namestringThe name of the custom metric. (pattern: <code>[a-zA-Z0-9:_-]+</code>)
metric_typestringThe type of the custom metric. The type number only takes a single metric value as an input, but while submitting the metrics value in the DeviceMetrics report, it must be passed as an array with a single value. (string-list, ip-address-list, number-list, number)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_custom_metricselectmetric_name, regionGets information about a Device Defender detect custom metric. Requires permission to access the DescribeCustomMetric action.
list_custom_metricsselectregionnextToken, maxResultsLists your Device Defender detect custom metrics. Requires permission to access the ListCustomMetrics action.
create_custom_metricinsertmetric_name, region, metricType, clientRequestTokenUse this API to define a Custom Metric published by your devices to Device Defender. Requires permission to access the CreateCustomMetric action.
update_custom_metricupdatemetric_name, region, displayNameUpdates a Device Defender detect custom metric. Requires permission to access the UpdateCustomMetric action.
delete_custom_metricdeletemetric_name, regionDeletes a Device Defender detect custom metric. Requires permission to access the DeleteCustomMetric action. Before you can delete a custom metric, you must first remove the custom metric from all security profiles it's a part of. The security profile associated with the custom metric can be found using the ListSecurityProfiles API with metricName set to your custom metric name.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
metric_namestringThe name of the custom metric.
regionstringAWS region (default: us-east-1)
maxResultsintegerThe maximum number of results to return at one time. The default is 25.
nextTokenstringThe token for the next set of results.

SELECT examples

Gets information about a Device Defender detect custom metric. Requires permission to access the DescribeCustomMetric action.

SELECT
creation_date,
display_name,
last_modified_date,
metric_arn,
metric_name,
metric_type
FROM aws.iot.custom_metrics
WHERE metric_name = '{{ metric_name }}' -- required
AND region = '{{ region }}' -- required
;

INSERT examples

Use this API to define a Custom Metric published by your devices to Device Defender. Requires permission to access the CreateCustomMetric action.

INSERT INTO aws.iot.custom_metrics (
displayName,
metricType,
tags,
clientRequestToken,
metric_name,
region
)
SELECT
'{{ displayName }}',
'{{ metricType }}' /* required */,
'{{ tags }}',
'{{ clientRequestToken }}' /* required */,
'{{ metric_name }}',
'{{ region }}'
RETURNING
metric_arn,
metric_name
;

UPDATE examples

Updates a Device Defender detect custom metric. Requires permission to access the UpdateCustomMetric action.

UPDATE aws.iot.custom_metrics
SET
displayName = '{{ displayName }}'
WHERE
metric_name = '{{ metric_name }}' --required
AND region = '{{ region }}' --required
AND displayName = '{{ displayName }}' --required
RETURNING
creation_date,
display_name,
last_modified_date,
metric_arn,
metric_name,
metric_type;

DELETE examples

Deletes a Device Defender detect custom metric. Requires permission to access the DeleteCustomMetric action. Before you can delete a custom metric, you must first remove the custom metric from all security profiles it's a part of. The security profile associated with the custom metric can be found using the ListSecurityProfiles API with metricName set to your custom metric name.

DELETE FROM aws.iot.custom_metrics
WHERE metric_name = '{{ metric_name }}' --required
AND region = '{{ region }}' --required
;