custom_metrics
Creates, updates, deletes, gets or lists a custom_metrics resource.
Overview
| Name | custom_metrics |
| Type | Resource |
| Id | aws.iot.custom_metrics |
Fields
The following fields are returned by SELECT queries:
- describe_custom_metric
- list_custom_metrics
| Name | Datatype | Description |
|---|---|---|
creation_date | string (date-time) | The creation date of the custom metric in milliseconds since epoch. |
display_name | string | Field 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_date | string (date-time) | The time the custom metric was last modified in milliseconds since epoch. |
metric_arn | string | The Amazon Resource Number (ARN) of the custom metric. |
metric_name | string | The name of the custom metric. (pattern: <code>[a-zA-Z0-9:_-]+</code>) |
metric_type | string | The 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) |
| Name | Datatype | Description |
|---|---|---|
metric_name | string | The name of the custom metric. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
describe_custom_metric | select | metric_name, region | Gets information about a Device Defender detect custom metric. Requires permission to access the DescribeCustomMetric action. | |
list_custom_metrics | select | region | nextToken, maxResults | Lists your Device Defender detect custom metrics. Requires permission to access the ListCustomMetrics action. |
create_custom_metric | insert | metric_name, region, metricType, clientRequestToken | Use this API to define a Custom Metric published by your devices to Device Defender. Requires permission to access the CreateCustomMetric action. | |
update_custom_metric | update | metric_name, region, displayName | Updates a Device Defender detect custom metric. Requires permission to access the UpdateCustomMetric action. | |
delete_custom_metric | delete | metric_name, region | 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. |
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.
| Name | Datatype | Description |
|---|---|---|
metric_name | string | The name of the custom metric. |
region | string | AWS region (default: us-east-1) |
maxResults | integer | The maximum number of results to return at one time. The default is 25. |
nextToken | string | The token for the next set of results. |
SELECT examples
- describe_custom_metric
- list_custom_metrics
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
;
Lists your Device Defender detect custom metrics. Requires permission to access the ListCustomMetrics action.
SELECT
metric_name
FROM aws.iot.custom_metrics
WHERE region = '{{ region }}' -- required
AND nextToken = '{{ nextToken }}'
AND maxResults = '{{ maxResults }}'
;
INSERT examples
- create_custom_metric
- Manifest
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
;
# Description fields are for documentation purposes
- name: custom_metrics
props:
- name: metric_name
value: "{{ metric_name }}"
description: Required parameter for the custom_metrics resource.
- name: region
value: "{{ region }}"
description: Required parameter for the custom_metrics resource.
- name: displayName
value: "{{ displayName }}"
- name: metricType
value: "{{ metricType }}"
valid_values: ['string-list', 'ip-address-list', 'number-list', 'number']
- name: tags
value:
- Key: "{{ Key }}"
Value: "{{ Value }}"
- name: clientRequestToken
value: "{{ clientRequestToken }}"
UPDATE examples
- update_custom_metric
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
- delete_custom_metric
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
;