1. Packages
  2. AWS Classic
  3. API Docs
  4. cloudwatch
  5. LogMetricFilter

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.28.1 published on Thursday, Mar 28, 2024 by Pulumi

aws.cloudwatch.LogMetricFilter

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.28.1 published on Thursday, Mar 28, 2024 by Pulumi

    Provides a CloudWatch Log Metric Filter resource.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const dada = new aws.cloudwatch.LogGroup("dada", {name: "MyApp/access.log"});
    const yada = new aws.cloudwatch.LogMetricFilter("yada", {
        name: "MyAppAccessCount",
        pattern: "",
        logGroupName: dada.name,
        metricTransformation: {
            name: "EventCount",
            namespace: "YourNamespace",
            value: "1",
        },
    });
    
    import pulumi
    import pulumi_aws as aws
    
    dada = aws.cloudwatch.LogGroup("dada", name="MyApp/access.log")
    yada = aws.cloudwatch.LogMetricFilter("yada",
        name="MyAppAccessCount",
        pattern="",
        log_group_name=dada.name,
        metric_transformation=aws.cloudwatch.LogMetricFilterMetricTransformationArgs(
            name="EventCount",
            namespace="YourNamespace",
            value="1",
        ))
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		dada, err := cloudwatch.NewLogGroup(ctx, "dada", &cloudwatch.LogGroupArgs{
    			Name: pulumi.String("MyApp/access.log"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = cloudwatch.NewLogMetricFilter(ctx, "yada", &cloudwatch.LogMetricFilterArgs{
    			Name:         pulumi.String("MyAppAccessCount"),
    			Pattern:      pulumi.String(""),
    			LogGroupName: dada.Name,
    			MetricTransformation: &cloudwatch.LogMetricFilterMetricTransformationArgs{
    				Name:      pulumi.String("EventCount"),
    				Namespace: pulumi.String("YourNamespace"),
    				Value:     pulumi.String("1"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var dada = new Aws.CloudWatch.LogGroup("dada", new()
        {
            Name = "MyApp/access.log",
        });
    
        var yada = new Aws.CloudWatch.LogMetricFilter("yada", new()
        {
            Name = "MyAppAccessCount",
            Pattern = "",
            LogGroupName = dada.Name,
            MetricTransformation = new Aws.CloudWatch.Inputs.LogMetricFilterMetricTransformationArgs
            {
                Name = "EventCount",
                Namespace = "YourNamespace",
                Value = "1",
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.cloudwatch.LogGroup;
    import com.pulumi.aws.cloudwatch.LogGroupArgs;
    import com.pulumi.aws.cloudwatch.LogMetricFilter;
    import com.pulumi.aws.cloudwatch.LogMetricFilterArgs;
    import com.pulumi.aws.cloudwatch.inputs.LogMetricFilterMetricTransformationArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var dada = new LogGroup("dada", LogGroupArgs.builder()        
                .name("MyApp/access.log")
                .build());
    
            var yada = new LogMetricFilter("yada", LogMetricFilterArgs.builder()        
                .name("MyAppAccessCount")
                .pattern("")
                .logGroupName(dada.name())
                .metricTransformation(LogMetricFilterMetricTransformationArgs.builder()
                    .name("EventCount")
                    .namespace("YourNamespace")
                    .value("1")
                    .build())
                .build());
    
        }
    }
    
    resources:
      yada:
        type: aws:cloudwatch:LogMetricFilter
        properties:
          name: MyAppAccessCount
          pattern:
          logGroupName: ${dada.name}
          metricTransformation:
            name: EventCount
            namespace: YourNamespace
            value: '1'
      dada:
        type: aws:cloudwatch:LogGroup
        properties:
          name: MyApp/access.log
    

    Create LogMetricFilter Resource

    new LogMetricFilter(name: string, args: LogMetricFilterArgs, opts?: CustomResourceOptions);
    @overload
    def LogMetricFilter(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        log_group_name: Optional[str] = None,
                        metric_transformation: Optional[LogMetricFilterMetricTransformationArgs] = None,
                        name: Optional[str] = None,
                        pattern: Optional[str] = None)
    @overload
    def LogMetricFilter(resource_name: str,
                        args: LogMetricFilterArgs,
                        opts: Optional[ResourceOptions] = None)
    func NewLogMetricFilter(ctx *Context, name string, args LogMetricFilterArgs, opts ...ResourceOption) (*LogMetricFilter, error)
    public LogMetricFilter(string name, LogMetricFilterArgs args, CustomResourceOptions? opts = null)
    public LogMetricFilter(String name, LogMetricFilterArgs args)
    public LogMetricFilter(String name, LogMetricFilterArgs args, CustomResourceOptions options)
    
    type: aws:cloudwatch:LogMetricFilter
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args LogMetricFilterArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args LogMetricFilterArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args LogMetricFilterArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args LogMetricFilterArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args LogMetricFilterArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    LogMetricFilter Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The LogMetricFilter resource accepts the following input properties:

    LogGroupName string
    The name of the log group to associate the metric filter with.
    MetricTransformation LogMetricFilterMetricTransformation
    A block defining collection of information needed to define how metric data gets emitted. See below.
    Pattern string
    A valid CloudWatch Logs filter pattern for extracting metric data out of ingested log events.
    Name string
    A name for the metric filter.
    LogGroupName string
    The name of the log group to associate the metric filter with.
    MetricTransformation LogMetricFilterMetricTransformationArgs
    A block defining collection of information needed to define how metric data gets emitted. See below.
    Pattern string
    A valid CloudWatch Logs filter pattern for extracting metric data out of ingested log events.
    Name string
    A name for the metric filter.
    logGroupName String
    The name of the log group to associate the metric filter with.
    metricTransformation LogMetricFilterMetricTransformation
    A block defining collection of information needed to define how metric data gets emitted. See below.
    pattern String
    A valid CloudWatch Logs filter pattern for extracting metric data out of ingested log events.
    name String
    A name for the metric filter.
    logGroupName string
    The name of the log group to associate the metric filter with.
    metricTransformation LogMetricFilterMetricTransformation
    A block defining collection of information needed to define how metric data gets emitted. See below.
    pattern string
    A valid CloudWatch Logs filter pattern for extracting metric data out of ingested log events.
    name string
    A name for the metric filter.
    log_group_name str
    The name of the log group to associate the metric filter with.
    metric_transformation LogMetricFilterMetricTransformationArgs
    A block defining collection of information needed to define how metric data gets emitted. See below.
    pattern str
    A valid CloudWatch Logs filter pattern for extracting metric data out of ingested log events.
    name str
    A name for the metric filter.
    logGroupName String
    The name of the log group to associate the metric filter with.
    metricTransformation Property Map
    A block defining collection of information needed to define how metric data gets emitted. See below.
    pattern String
    A valid CloudWatch Logs filter pattern for extracting metric data out of ingested log events.
    name String
    A name for the metric filter.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the LogMetricFilter resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing LogMetricFilter Resource

    Get an existing LogMetricFilter resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: LogMetricFilterState, opts?: CustomResourceOptions): LogMetricFilter
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            log_group_name: Optional[str] = None,
            metric_transformation: Optional[LogMetricFilterMetricTransformationArgs] = None,
            name: Optional[str] = None,
            pattern: Optional[str] = None) -> LogMetricFilter
    func GetLogMetricFilter(ctx *Context, name string, id IDInput, state *LogMetricFilterState, opts ...ResourceOption) (*LogMetricFilter, error)
    public static LogMetricFilter Get(string name, Input<string> id, LogMetricFilterState? state, CustomResourceOptions? opts = null)
    public static LogMetricFilter get(String name, Output<String> id, LogMetricFilterState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    LogGroupName string
    The name of the log group to associate the metric filter with.
    MetricTransformation LogMetricFilterMetricTransformation
    A block defining collection of information needed to define how metric data gets emitted. See below.
    Name string
    A name for the metric filter.
    Pattern string
    A valid CloudWatch Logs filter pattern for extracting metric data out of ingested log events.
    LogGroupName string
    The name of the log group to associate the metric filter with.
    MetricTransformation LogMetricFilterMetricTransformationArgs
    A block defining collection of information needed to define how metric data gets emitted. See below.
    Name string
    A name for the metric filter.
    Pattern string
    A valid CloudWatch Logs filter pattern for extracting metric data out of ingested log events.
    logGroupName String
    The name of the log group to associate the metric filter with.
    metricTransformation LogMetricFilterMetricTransformation
    A block defining collection of information needed to define how metric data gets emitted. See below.
    name String
    A name for the metric filter.
    pattern String
    A valid CloudWatch Logs filter pattern for extracting metric data out of ingested log events.
    logGroupName string
    The name of the log group to associate the metric filter with.
    metricTransformation LogMetricFilterMetricTransformation
    A block defining collection of information needed to define how metric data gets emitted. See below.
    name string
    A name for the metric filter.
    pattern string
    A valid CloudWatch Logs filter pattern for extracting metric data out of ingested log events.
    log_group_name str
    The name of the log group to associate the metric filter with.
    metric_transformation LogMetricFilterMetricTransformationArgs
    A block defining collection of information needed to define how metric data gets emitted. See below.
    name str
    A name for the metric filter.
    pattern str
    A valid CloudWatch Logs filter pattern for extracting metric data out of ingested log events.
    logGroupName String
    The name of the log group to associate the metric filter with.
    metricTransformation Property Map
    A block defining collection of information needed to define how metric data gets emitted. See below.
    name String
    A name for the metric filter.
    pattern String
    A valid CloudWatch Logs filter pattern for extracting metric data out of ingested log events.

    Supporting Types

    LogMetricFilterMetricTransformation, LogMetricFilterMetricTransformationArgs

    Name string
    The name of the CloudWatch metric to which the monitored log information should be published (e.g., ErrorCount)
    Namespace string
    The destination namespace of the CloudWatch metric.
    Value string
    What to publish to the metric. For example, if you're counting the occurrences of a particular term like "Error", the value will be "1" for each occurrence. If you're counting the bytes transferred the published value will be the value in the log event.
    DefaultValue string
    The value to emit when a filter pattern does not match a log event. Conflicts with dimensions.
    Dimensions Dictionary<string, string>
    Map of fields to use as dimensions for the metric. Up to 3 dimensions are allowed. Conflicts with default_value.
    Unit string
    The unit to assign to the metric. If you omit this, the unit is set as None.
    Name string
    The name of the CloudWatch metric to which the monitored log information should be published (e.g., ErrorCount)
    Namespace string
    The destination namespace of the CloudWatch metric.
    Value string
    What to publish to the metric. For example, if you're counting the occurrences of a particular term like "Error", the value will be "1" for each occurrence. If you're counting the bytes transferred the published value will be the value in the log event.
    DefaultValue string
    The value to emit when a filter pattern does not match a log event. Conflicts with dimensions.
    Dimensions map[string]string
    Map of fields to use as dimensions for the metric. Up to 3 dimensions are allowed. Conflicts with default_value.
    Unit string
    The unit to assign to the metric. If you omit this, the unit is set as None.
    name String
    The name of the CloudWatch metric to which the monitored log information should be published (e.g., ErrorCount)
    namespace String
    The destination namespace of the CloudWatch metric.
    value String
    What to publish to the metric. For example, if you're counting the occurrences of a particular term like "Error", the value will be "1" for each occurrence. If you're counting the bytes transferred the published value will be the value in the log event.
    defaultValue String
    The value to emit when a filter pattern does not match a log event. Conflicts with dimensions.
    dimensions Map<String,String>
    Map of fields to use as dimensions for the metric. Up to 3 dimensions are allowed. Conflicts with default_value.
    unit String
    The unit to assign to the metric. If you omit this, the unit is set as None.
    name string
    The name of the CloudWatch metric to which the monitored log information should be published (e.g., ErrorCount)
    namespace string
    The destination namespace of the CloudWatch metric.
    value string
    What to publish to the metric. For example, if you're counting the occurrences of a particular term like "Error", the value will be "1" for each occurrence. If you're counting the bytes transferred the published value will be the value in the log event.
    defaultValue string
    The value to emit when a filter pattern does not match a log event. Conflicts with dimensions.
    dimensions {[key: string]: string}
    Map of fields to use as dimensions for the metric. Up to 3 dimensions are allowed. Conflicts with default_value.
    unit string
    The unit to assign to the metric. If you omit this, the unit is set as None.
    name str
    The name of the CloudWatch metric to which the monitored log information should be published (e.g., ErrorCount)
    namespace str
    The destination namespace of the CloudWatch metric.
    value str
    What to publish to the metric. For example, if you're counting the occurrences of a particular term like "Error", the value will be "1" for each occurrence. If you're counting the bytes transferred the published value will be the value in the log event.
    default_value str
    The value to emit when a filter pattern does not match a log event. Conflicts with dimensions.
    dimensions Mapping[str, str]
    Map of fields to use as dimensions for the metric. Up to 3 dimensions are allowed. Conflicts with default_value.
    unit str
    The unit to assign to the metric. If you omit this, the unit is set as None.
    name String
    The name of the CloudWatch metric to which the monitored log information should be published (e.g., ErrorCount)
    namespace String
    The destination namespace of the CloudWatch metric.
    value String
    What to publish to the metric. For example, if you're counting the occurrences of a particular term like "Error", the value will be "1" for each occurrence. If you're counting the bytes transferred the published value will be the value in the log event.
    defaultValue String
    The value to emit when a filter pattern does not match a log event. Conflicts with dimensions.
    dimensions Map<String>
    Map of fields to use as dimensions for the metric. Up to 3 dimensions are allowed. Conflicts with default_value.
    unit String
    The unit to assign to the metric. If you omit this, the unit is set as None.

    Import

    Using pulumi import, import CloudWatch Log Metric Filter using the log_group_name:name. For example:

    $ pulumi import aws:cloudwatch/logMetricFilter:LogMetricFilter test /aws/lambda/function:test
    

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.28.1 published on Thursday, Mar 28, 2024 by Pulumi