create_custom_metric

create_custom_metric(**kwargs)

Use this API to define a Custom Metric published by your devices to Device Defender.

Requires permission to access the CreateCustomMetric action.

See also: AWS API Documentation

Request Syntax

response = client.create_custom_metric(
    metricName='string',
    displayName='string',
    metricType='string-list'|'ip-address-list'|'number-list'|'number',
    tags=[
        {
            'Key': 'string',
            'Value': 'string'
        },
    ],
    clientRequestToken='string'
)
Parameters
  • metricName (string) --

    [REQUIRED]

    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.

  • displayName (string) -- 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.
  • metricType (string) --

    [REQUIRED]

    The type of the custom metric.

    Warning

    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.

  • tags (list) --

    Metadata that can be used to manage the custom metric.

    • (dict) --

      A set of key/value pairs that are used to manage the resource.

      • Key (string) -- [REQUIRED]

        The tag's key.

      • Value (string) --

        The tag's value.

  • clientRequestToken (string) --

    [REQUIRED]

    Each custom metric must have a unique client request token. If you try to create a new custom metric that already exists with a different token, an exception occurs. If you omit this value, Amazon Web Services SDKs will automatically generate a unique client request.

    This field is autopopulated if not provided.

Return type

dict

Returns

Response Syntax

{
    'metricName': 'string',
    'metricArn': 'string'
}

Response Structure

  • (dict) --

    • metricName (string) --

      The name of the custom metric to be used in the metric report.

    • metricArn (string) --

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

Exceptions

  • IoT.Client.exceptions.InvalidRequestException
  • IoT.Client.exceptions.LimitExceededException
  • IoT.Client.exceptions.ResourceAlreadyExistsException
  • IoT.Client.exceptions.ThrottlingException
  • IoT.Client.exceptions.InternalFailureException