putMetricFilter method

Future<void> putMetricFilter({
  1. required String filterName,
  2. required String filterPattern,
  3. required String logGroupName,
  4. required List<MetricTransformation> metricTransformations,
})

Creates or updates a metric filter and associates it with the specified log group. Metric filters allow you to configure rules to extract metric data from log events ingested through PutLogEvents.

The maximum number of metric filters that can be associated with a log group is 100.

May throw InvalidParameterException. May throw ResourceNotFoundException. May throw OperationAbortedException. May throw LimitExceededException. May throw ServiceUnavailableException.

Parameter filterName : A name for the metric filter.

Parameter filterPattern : A filter pattern for extracting metric data out of ingested log events.

Parameter logGroupName : The name of the log group.

Parameter metricTransformations : A collection of information that defines how metric data gets emitted.

Implementation

Future<void> putMetricFilter({
  required String filterName,
  required String filterPattern,
  required String logGroupName,
  required List<MetricTransformation> metricTransformations,
}) async {
  ArgumentError.checkNotNull(filterName, 'filterName');
  _s.validateStringLength(
    'filterName',
    filterName,
    1,
    512,
    isRequired: true,
  );
  ArgumentError.checkNotNull(filterPattern, 'filterPattern');
  _s.validateStringLength(
    'filterPattern',
    filterPattern,
    0,
    1024,
    isRequired: true,
  );
  ArgumentError.checkNotNull(logGroupName, 'logGroupName');
  _s.validateStringLength(
    'logGroupName',
    logGroupName,
    1,
    512,
    isRequired: true,
  );
  ArgumentError.checkNotNull(metricTransformations, 'metricTransformations');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'Logs_20140328.PutMetricFilter'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'filterName': filterName,
      'filterPattern': filterPattern,
      'logGroupName': logGroupName,
      'metricTransformations': metricTransformations,
    },
  );
}