metric_filters
Creates, updates, deletes or gets a metric_filter
resource or lists metric_filters
in a region
Overview
Name | metric_filters |
Type | Resource |
Description | The 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. |
Id | aws.logs.metric_filters |
Fields
Name | Datatype | Description |
---|---|---|
metric_transformations | array | The metric transformations. |
filter_pattern | string | A 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_name | string | The name of an existing log group that you want to associate with this metric filter. |
filter_name | string | The name of the metric filter. |
region | string | AWS region. |
Methods
Name | Accessible by | Required Params |
---|---|---|
create_resource | INSERT | FilterPattern, LogGroupName, MetricTransformations, region |
delete_resource | DELETE | data__Identifier, region |
update_resource | UPDATE | data__Identifier, data__PatchDocument, region |
list_resources | SELECT | region |
get_resource | SELECT | data__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
.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO aws.logs.metric_filters (
MetricTransformations,
FilterPattern,
LogGroupName,
region
)
SELECT
'{{ MetricTransformations }}',
'{{ FilterPattern }}',
'{{ LogGroupName }}',
'{{ region }}';
/*+ create */
INSERT INTO aws.logs.metric_filters (
MetricTransformations,
FilterPattern,
LogGroupName,
FilterName,
region
)
SELECT
'{{ MetricTransformations }}',
'{{ FilterPattern }}',
'{{ LogGroupName }}',
'{{ FilterName }}',
'{{ region }}';
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: metric_filter
props:
- name: MetricTransformations
value:
- DefaultValue: null
MetricName: '{{ MetricName }}'
MetricValue: '{{ MetricValue }}'
MetricNamespace: '{{ MetricNamespace }}'
Dimensions:
- Value: '{{ Value }}'
Key: '{{ Key }}'
Unit: '{{ Unit }}'
- name: FilterPattern
value: '{{ FilterPattern }}'
- name: LogGroupName
value: '{{ LogGroupName }}'
- name: FilterName
value: '{{ FilterName }}'
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