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
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.
Idawscc.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.
log_group_namestringThe name of an existing log group that you want to associate with this metric filter.
apply_on_transformed_logsboolean
This 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.
filter_namestringThe name of the metric filter.
regionstringAWS region.

For more information, see AWS::Logs::MetricFilter.

Methods

NameResourceAccessible byRequired Params
create_resourcemetric_filtersINSERTFilterPattern, LogGroupName, MetricTransformations, region
delete_resourcemetric_filtersDELETEIdentifier, region
update_resourcemetric_filtersUPDATEIdentifier, PatchDocument, region
list_resourcesmetric_filters_list_onlySELECTregion
get_resourcemetric_filtersSELECTIdentifier, region

SELECT examples

Gets all properties from an individual metric_filter.

SELECT
region,
metric_transformations,
filter_pattern,
log_group_name,
apply_on_transformed_logs,
filter_name
FROM awscc.logs.metric_filters
WHERE
region = '{{ region }}' AND
Identifier = '{{ log_group_name }}|{{ filter_name }}';

INSERT example

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

/*+ create */
INSERT INTO awscc.logs.metric_filters (
MetricTransformations,
FilterPattern,
LogGroupName,
region
)
SELECT
'{{ metric_transformations }}',
'{{ filter_pattern }}',
'{{ log_group_name }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

UPDATE example

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

/*+ update */
UPDATE awscc.logs.metric_filters
SET PatchDocument = string('{{ {
"MetricTransformations": metric_transformations,
"FilterPattern": filter_pattern,
"ApplyOnTransformedLogs": apply_on_transformed_logs
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ log_group_name }}|{{ filter_name }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

DELETE example

/*+ delete */
DELETE FROM awscc.logs.metric_filters
WHERE
Identifier = '{{ log_group_name }}|{{ filter_name }}' AND
region = '{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;

Additional Parameters

Mutable resources in the Cloud Control provider support additional optional parameters which can be supplied with INSERT, UPDATE, or DELETE operations. These include:

ParameterDescription
ClientToken
A unique identifier to ensure the idempotency of the resource request.This allows the provider to accurately distinguish between retries and new requests.
A client token is valid for 36 hours once used.
After that, a resource request with the same client token is treated as a new request.
If you do not specify a client token, one is generated for inclusion in the request.
RoleArn
The ARN of the IAM role used to perform this resource operation.The role specified must have the permissions required for this operation.
If you do not specify a role, a temporary session is created using your AWS user credentials.
TypeVersionId
For private resource types, the type version to use in this resource operation.If you do not specify a resource version, the default version is used.

Permissions

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

logs:DescribeMetricFilters