Skip to main content

metric_filters

Creates, updates, deletes, gets or lists a metric_filters resource.

Overview

Namemetric_filters
TypeResource
Idaws.logs.metric_filters

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
apply_on_transformed_logsbooleanThis parameter is valid only for log groups that have an active log transformer. For more information about log transformers, see PutTransformer. If this value is true, the metric filter is applied on the transformed version of the log events instead of the original ingested log events.
creation_timeinteger (int64)The creation time of the metric filter, expressed as the number of milliseconds after Jan 1, 1970 00:00:00 UTC.
emit_system_field_dimensionsarrayThe list of system fields that are emitted as additional dimensions in the generated metrics. Returns the emitSystemFieldDimensions value if it was specified when the metric filter was created.
field_selection_criteriastringThe filter expression that specifies which log events are processed by this metric filter based on system fields. Returns the fieldSelectionCriteria value if it was specified when the metric filter was created.
filter_namestringThe name of the metric filter. (pattern: <code>[^:]</code>)
filter_patternstringA symbolic description of how CloudWatch Logs should interpret the data in each log event. For example, a log event can contain timestamps, IP addresses, strings, and so on. You use the filter pattern to specify what to look for in the log event message.
log_group_namestringThe name of the log group. (pattern: <code>[.-_/#A-Za-z0-9]+</code>)
metric_transformationsarrayThe metric transformations.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_metric_filtersselectregionLists the specified metric filters. You can list all of the metric filters or filter the results by log name, prefix, metric name, or metric namespace. The results are ASCII-sorted by filter name.
put_metric_filterreplaceregion, logGroupName, filterName, filterPattern, metricTransformationsCreates or updates a metric filter and associates it with the specified log group. With metric filters, you can 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. Using regular expressions in filter patterns is supported. For these filters, there is a quota of two regular expression patterns within a single filter pattern. There is also a quota of five regular expression patterns per log group. For more information about using regular expressions in filter patterns, see Filter pattern syntax for metric filters, subscription filters, filter log events, and Live Tail. When you create a metric filter, you can also optionally assign a unit and dimensions to the metric that is created. Metrics extracted from log events are charged as custom metrics. To prevent unexpected high charges, do not specify high-cardinality fields such as IPAddress or requestID as dimensions. Each different value found for a dimension is treated as a separate metric and accrues charges as a separate custom metric. CloudWatch Logs might disable a metric filter if it generates 1,000 different name/value pairs for your specified dimensions within one hour. You can also set up a billing alarm to alert you if your charges are higher than expected. For more information, see Creating a Billing Alarm to Monitor Your Estimated Amazon Web Services Charges.
delete_metric_filterdeleteregionDeletes the specified metric filter.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
regionstringAWS region (default: us-east-1)

SELECT examples

Lists the specified metric filters. You can list all of the metric filters or filter the results by log name, prefix, metric name, or metric namespace. The results are ASCII-sorted by filter name.

SELECT
apply_on_transformed_logs,
creation_time,
emit_system_field_dimensions,
field_selection_criteria,
filter_name,
filter_pattern,
log_group_name,
metric_transformations
FROM aws.logs.metric_filters
WHERE region = '{{ region }}' -- required
;

REPLACE examples

Creates or updates a metric filter and associates it with the specified log group. With metric filters, you can 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. Using regular expressions in filter patterns is supported. For these filters, there is a quota of two regular expression patterns within a single filter pattern. There is also a quota of five regular expression patterns per log group. For more information about using regular expressions in filter patterns, see Filter pattern syntax for metric filters, subscription filters, filter log events, and Live Tail. When you create a metric filter, you can also optionally assign a unit and dimensions to the metric that is created. Metrics extracted from log events are charged as custom metrics. To prevent unexpected high charges, do not specify high-cardinality fields such as IPAddress or requestID as dimensions. Each different value found for a dimension is treated as a separate metric and accrues charges as a separate custom metric. CloudWatch Logs might disable a metric filter if it generates 1,000 different name/value pairs for your specified dimensions within one hour. You can also set up a billing alarm to alert you if your charges are higher than expected. For more information, see Creating a Billing Alarm to Monitor Your Estimated Amazon Web Services Charges.

REPLACE aws.logs.metric_filters
SET
logGroupName = '{{ logGroupName }}',
filterName = '{{ filterName }}',
filterPattern = '{{ filterPattern }}',
metricTransformations = '{{ metricTransformations }}',
applyOnTransformedLogs = {{ applyOnTransformedLogs }},
fieldSelectionCriteria = '{{ fieldSelectionCriteria }}',
emitSystemFieldDimensions = '{{ emitSystemFieldDimensions }}'
WHERE
region = '{{ region }}' --required
AND logGroupName = '{{ logGroupName }}' --required
AND filterName = '{{ filterName }}' --required
AND filterPattern = '{{ filterPattern }}' --required
AND metricTransformations = '{{ metricTransformations }}' --required;

DELETE examples

Deletes the specified metric filter.

DELETE FROM aws.logs.metric_filters
WHERE region = '{{ region }}' --required
;