:doc:`CloudWatch <../../cloudwatch>` / Client / put_insight_rule

****************
put_insight_rule
****************



.. py:method:: CloudWatch.Client.put_insight_rule(**kwargs)

  

  Creates a Contributor Insights rule. Rules evaluate log events in a CloudWatch Logs log group, enabling you to find contributor data for the log events in that log group. For more information, see `Using Contributor Insights to Analyze High-Cardinality Data <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContributorInsights.html>`__.

   

  If you create a rule, delete it, and then re-create it with the same name, historical data from the first time the rule was created might not be available.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/monitoring-2010-08-01/PutInsightRule>`_  


  **Request Syntax**
  ::

    response = client.put_insight_rule(
        RuleName='string',
        RuleState='string',
        RuleDefinition='string',
        Tags=[
            {
                'Key': 'string',
                'Value': 'string'
            },
        ],
        ApplyOnTransformedLogs=True|False
    )
    
  :type RuleName: string
  :param RuleName: **[REQUIRED]** 

    A unique name for the rule.

    

  
  :type RuleState: string
  :param RuleState: 

    The state of the rule. Valid values are ENABLED and DISABLED.

    

  
  :type RuleDefinition: string
  :param RuleDefinition: **[REQUIRED]** 

    The definition of the rule, as a JSON object. For details on the valid syntax, see `Contributor Insights Rule Syntax <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContributorInsights-RuleSyntax.html>`__.

    

  
  :type Tags: list
  :param Tags: 

    A list of key-value pairs to associate with the Contributor Insights rule. You can associate as many as 50 tags with a rule.

     

    Tags can help you organize and categorize your resources. You can also use them to scope user permissions, by granting a user permission to access or change only the resources that have certain tag values.

     

    To be able to associate tags with a rule, you must have the ``cloudwatch:TagResource`` permission in addition to the ``cloudwatch:PutInsightRule`` permission.

     

    If you are using this operation to update an existing Contributor Insights rule, any tags you specify in this parameter are ignored. To change the tags of an existing rule, use `TagResource <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_TagResource.html>`__.

    

  
    - *(dict) --* 

      A key-value pair associated with a CloudWatch resource.

      

    
      - **Key** *(string) --* **[REQUIRED]** 

        A string that you can use to assign a value. The combination of tag keys and values can help you organize and categorize your resources.

        

      
      - **Value** *(string) --* **[REQUIRED]** 

        The value for the specified tag key.

        

      
    

  :type ApplyOnTransformedLogs: boolean
  :param ApplyOnTransformedLogs: 

    Specify ``true`` to have this rule evaluate log events after they have been transformed by `Log transformation <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatch-Logs-Transformation.html>`__. If you specify ``true``, then the log events in log groups that have transformers will be evaluated by Contributor Insights after being transformed. Log groups that don't have transformers will still have their original log events evaluated by Contributor Insights.

     

    The default is ``false``

     

    .. note::

      

      If a log group has a transformer, and transformation fails for some log events, those log events won't be evaluated by Contributor Insights. For information about investigating log transformation failures, see `Transformation metrics and errors <https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Transformation-Errors-Metrics.html>`__.

      

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {}
      
    **Response Structure**

    

    - *(dict) --* 
  
  **Exceptions**
  
  *   :py:class:`CloudWatch.Client.exceptions.InvalidParameterValueException`

  
  *   :py:class:`CloudWatch.Client.exceptions.MissingRequiredParameterException`

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

  