Skip to main content

metric_filters

Creates, updates, deletes or gets a metric_filter resource or lists metric_filters in a region

Overview

Namemetric_filters
TypeResource
DescriptionThe AWS::Logs::MetricFilter resource specifies a metric filter that describes how CWL extracts information from logs and transforms it into Amazon CloudWatch metrics. If you have multiple metric filters that are associated with a log group, all the filters are applied to the log streams in that group.
The maximum number of metric filters that can be associated with a log group is 100.
Idaws.logs.metric_filters

Fields

NameDatatypeDescription
metric_transformationsarrayThe metric transformations.
filter_patternstringA filter pattern for extracting metric data out of ingested log events. For more information, see [Filter and Pattern Syntax](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html).
log_group_namestringThe name of an existing log group that you want to associate with this metric filter.
filter_namestringThe name of the metric filter.
regionstringAWS region.

Methods

NameAccessible byRequired Params
create_resourceINSERTFilterPattern, LogGroupName, MetricTransformations, region
delete_resourceDELETEdata__Identifier, region
update_resourceUPDATEdata__Identifier, data__PatchDocument, region
list_resourcesSELECTregion
get_resourceSELECTdata__Identifier, region

SELECT examples

Gets all metric_filters in a region.

SELECT
region,
metric_transformations,
filter_pattern,
log_group_name,
filter_name
FROM aws.logs.metric_filters
WHERE region = 'us-east-1';

Gets all properties from an individual metric_filter.

SELECT
region,
metric_transformations,
filter_pattern,
log_group_name,
filter_name
FROM aws.logs.metric_filters
WHERE region = 'us-east-1' AND data__Identifier = '<LogGroupName>|<FilterName>';

INSERT example

Use the following StackQL query and manifest file to create a new metric_filter resource, using stack-deploy.

/*+ create */
INSERT INTO aws.logs.metric_filters (
MetricTransformations,
FilterPattern,
LogGroupName,
region
)
SELECT
'{{ MetricTransformations }}',
'{{ FilterPattern }}',
'{{ LogGroupName }}',
'{{ region }}';

DELETE example

/*+ delete */
DELETE FROM aws.logs.metric_filters
WHERE data__Identifier = '<LogGroupName|FilterName>'
AND region = 'us-east-1';

Permissions

To operate on the metric_filters resource, the following permissions are required:

Read

logs:DescribeMetricFilters

Create

logs:PutMetricFilter,
logs:DescribeMetricFilters

Update

logs:PutMetricFilter,
logs:DescribeMetricFilters

List

logs:DescribeMetricFilters

Delete

logs:DeleteMetricFilter