Skip to content

put_insight_rule async

put_insight_rule(
    *,
    config_overrides: Optional[AsyncCloudWatchClientConfig] = None,
    rule_name: Optional[InsightRuleName] = None,
    rule_state: Optional[InsightRuleState] = None,
    rule_definition: Optional[InsightRuleDefinition] = None,
    tags: Optional[TagList] = None,
    apply_on_transformed_logs: Optional[InsightRuleOnTransformedLogs] = None,
) -> PutInsightRuleOutput

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.

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.

Parameters:

  • rule_name (Optional[InsightRuleName], default: None ) –

    A unique name for the rule.

  • rule_state (Optional[InsightRuleState], default: None ) –

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

  • rule_definition (Optional[InsightRuleDefinition], default: None ) –

    The definition of the rule, as a JSON object. For details on the valid syntax, see Contributor Insights Rule Syntax.

  • tags (Optional[TagList], default: None ) –

    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.

  • apply_on_transformed_logs (Optional[InsightRuleOnTransformedLogs], default: None ) –

    Specify true to have this rule evaluate log events after they have been transformed by Log transformation. 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

    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.

Raises:

Source code in docs_src/capo_cloudwatch/_services/async_cloud_watch.py
async def put_insight_rule(
    self,
    *,
    config_overrides: Optional[AsyncCloudWatchClientConfig] = None,
    rule_name: Optional[
        "capo_cloudwatch.types.insight_rule_name.InsightRuleName"
    ] = None,
    rule_state: Optional[
        "capo_cloudwatch.types.insight_rule_state.InsightRuleState"
    ] = None,
    rule_definition: Optional[
        "capo_cloudwatch.types.insight_rule_definition.InsightRuleDefinition"
    ] = None,
    tags: Optional["capo_cloudwatch.types.tag_list.TagList"] = None,
    apply_on_transformed_logs: Optional[
        "capo_cloudwatch.types.insight_rule_on_transformed_logs.InsightRuleOnTransformedLogs"
    ] = None,
) -> "capo_cloudwatch.types.put_insight_rule_output.PutInsightRuleOutput":
    """<p>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 <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContributorInsights.html">Using Contributor Insights to Analyze High-Cardinality Data</a>.</p> <p>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.</p>

    Args:
        rule_name: <p>A unique name for the rule.</p>
        rule_state: <p>The state of the rule. Valid values are ENABLED and DISABLED.</p>
        rule_definition: <p>The definition of the rule, as a JSON object. For details on the valid syntax, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ContributorInsights-RuleSyntax.html">Contributor Insights Rule Syntax</a>.</p>
        tags: <p>A list of key-value pairs to associate with the Contributor Insights rule. You can associate as many as 50 tags with a rule.</p> <p>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.</p> <p>To be able to associate tags with a rule, you must have the <code>cloudwatch:TagResource</code> permission in addition to the <code>cloudwatch:PutInsightRule</code> permission.</p> <p>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 <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_TagResource.html">TagResource</a>.</p>
        apply_on_transformed_logs: <p>Specify <code>true</code> to have this rule evaluate log events after they have been transformed by <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatch-Logs-Transformation.html">Log transformation</a>. If you specify <code>true</code>, 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.</p> <p>The default is <code>false</code> </p> <note> <p>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 <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Transformation-Errors-Metrics.html">Transformation metrics and errors</a>.</p> </note>

    Raises:
        capo_cloudwatch.errors.invalid_parameter_value_exception.InvalidParameterValueException: <p>The value of an input parameter is bad or out-of-range.</p>
        capo_cloudwatch.errors.limit_exceeded_exception.LimitExceededException: <p>The operation exceeded one or more limits.</p>
        capo_cloudwatch.errors.missing_required_parameter_exception.MissingRequiredParameterException: <p>An input parameter that is required is missing.</p>
        capo_cloudwatch.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudwatch.types.put_insight_rule_input.PutInsightRuleInput]",
    ) -> AsyncOperationResponse[
        "capo_cloudwatch.types.put_insight_rule_output.PutInsightRuleOutput"
    ]:
        import capo_cloudwatch._operations.granite_service_version20100801.put_insight_rule

        (
            output,
            http_response,
        ) = await capo_cloudwatch._operations.granite_service_version20100801.put_insight_rule.async_put_insight_rule(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("PutInsightRule")
    )
    input_: capo_cloudwatch.types.put_insight_rule_input.PutInsightRuleInput = {}
    if rule_name is not None:
        input_["rule_name"] = rule_name
    if rule_state is not None:
        input_["rule_state"] = rule_state
    if rule_definition is not None:
        input_["rule_definition"] = rule_definition
    if tags is not None:
        input_["tags"] = tags
    if apply_on_transformed_logs is not None:
        input_["apply_on_transformed_logs"] = apply_on_transformed_logs

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output