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 The maximum number of metric filters that can be associated with a log group is 100. |
| Id | awscc.logs.metric_filters |
Fields
- get (all properties)
- list (identifiers only)
| 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. |
log_group_name | string | The name of an existing log group that you want to associate with this metric filter. |
apply_on_transformed_logs | boolean | 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 istrue, the metric filter is applied on the transformed version of the log events instead of the original ingested log events. |
filter_name | string | The name of the metric filter. |
region | string | AWS region. |
| Name | Datatype | Description |
|---|---|---|
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. |
For more information, see AWS::Logs::MetricFilter.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | metric_filters | INSERT | FilterPattern, LogGroupName, MetricTransformations, region |
delete_resource | metric_filters | DELETE | Identifier, region |
update_resource | metric_filters | UPDATE | Identifier, PatchDocument, region |
list_resources | metric_filters_list_only | SELECT | region |
get_resource | metric_filters | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
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 }}';
Lists all metric_filters in a region.
SELECT
region,
log_group_name,
filter_name
FROM awscc.logs.metric_filters_list_only
WHERE
region = '{{ region }}';
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 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
;
/*+ create */
INSERT INTO awscc.logs.metric_filters (
MetricTransformations,
FilterPattern,
LogGroupName,
ApplyOnTransformedLogs,
FilterName,
region
)
SELECT
'{{ metric_transformations }}',
'{{ filter_pattern }}',
'{{ log_group_name }}',
'{{ apply_on_transformed_logs }}',
'{{ filter_name }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: metric_filter
props:
- name: metric_transformations
value:
- default_value: null
metric_name: '{{ metric_name }}'
metric_value: '{{ metric_value }}'
metric_namespace: '{{ metric_namespace }}'
dimensions:
- value: '{{ value }}'
key: '{{ key }}'
unit: '{{ unit }}'
- name: filter_pattern
value: '{{ filter_pattern }}'
- name: log_group_name
value: '{{ log_group_name }}'
- name: apply_on_transformed_logs
value: '{{ apply_on_transformed_logs }}'
- name: filter_name
value: '{{ filter_name }}'
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:
| Parameter | Description |
|---|---|
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:
- Read
- Create
- Update
- List
- Delete
logs:DescribeMetricFilters
logs:PutMetricFilter,
logs:DescribeMetricFilters
logs:PutMetricFilter,
logs:DescribeMetricFilters
logs:DescribeMetricFilters
logs:DeleteMetricFilter