putInsightRule method
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.
May throw InvalidParameterValueException.
May throw LimitExceededException.
May throw MissingRequiredParameterException.
Parameter ruleDefinition :
The definition of the rule, as a JSON object. For details on the valid
syntax, see Contributor
Insights Rule Syntax.
Parameter ruleName :
A unique name for the rule.
Parameter applyOnTransformedLogs :
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
Parameter ruleState :
The state of the rule. Valid values are ENABLED and DISABLED.
Parameter 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.
Implementation
Future<void> putInsightRule({
required String ruleDefinition,
required String ruleName,
bool? applyOnTransformedLogs,
String? ruleState,
List<Tag>? tags,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'GraniteServiceVersion20100801.PutInsightRule'
};
await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'RuleDefinition': ruleDefinition,
'RuleName': ruleName,
if (applyOnTransformedLogs != null)
'ApplyOnTransformedLogs': applyOnTransformedLogs,
if (ruleState != null) 'RuleState': ruleState,
if (tags != null) 'Tags': tags,
},
);
}