:doc:`IoT <../../iot>` / Client / create_custom_metric

********************
create_custom_metric
********************



.. py:method:: IoT.Client.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 <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions>`__ action.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/iot-2015-05-28/CreateCustomMetric>`_  


  **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'
    )
    
  :type metricName: string
  :param metricName: **[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.

    

  
  :type displayName: string
  :param 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.

    

  
  :type metricType: string
  :param metricType: **[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.

      

    

  
  :type tags: list
  :param tags: 

    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.

        

      
    

  :type clientRequestToken: string
  :param clientRequestToken: **[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.

  
  
  :rtype: 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**
  
  *   :py:class:`IoT.Client.exceptions.InvalidRequestException`

  
  *   :py:class:`IoT.Client.exceptions.LimitExceededException`

  
  *   :py:class:`IoT.Client.exceptions.ResourceAlreadyExistsException`

  
  *   :py:class:`IoT.Client.exceptions.ThrottlingException`

  
  *   :py:class:`IoT.Client.exceptions.InternalFailureException`

  