{
  "tagging" : {
    "taggable" : false
  },
  "typeName" : "AWS::Logs::MetricFilter",
  "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.\n The maximum number of metric filters that can be associated with a log group is 100.",
  "createOnlyProperties" : [ "/properties/FilterName", "/properties/LogGroupName" ],
  "primaryIdentifier" : [ "/properties/LogGroupName", "/properties/FilterName" ],
  "required" : [ "FilterPattern", "LogGroupName", "MetricTransformations" ],
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-logs.git",
  "handlers" : {
    "read" : {
      "permissions" : [ "logs:DescribeMetricFilters" ]
    },
    "create" : {
      "permissions" : [ "logs:PutMetricFilter", "logs:DescribeMetricFilters" ]
    },
    "update" : {
      "permissions" : [ "logs:PutMetricFilter", "logs:DescribeMetricFilters" ]
    },
    "list" : {
      "permissions" : [ "logs:DescribeMetricFilters" ]
    },
    "delete" : {
      "permissions" : [ "logs:DeleteMetricFilter" ]
    }
  },
  "resourceLink" : {
    "mappings" : {
      "MetricName" : "/MetricName",
      "LogGroupName" : "/LogGroupName"
    },
    "templateUri" : "/cloudwatch/home?region=${awsRegion}#logsV2:log-groups/log-group/${LogGroupName}/edit-metric-filter/${MetricName}"
  },
  "additionalProperties" : false,
  "definitions" : {
    "MetricTransformation" : {
      "description" : "``MetricTransformation`` is a property of the ``AWS::Logs::MetricFilter`` resource that describes how to transform log streams into a CloudWatch metric.",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "DefaultValue" : {
          "description" : "(Optional) The value to emit when a filter pattern does not match a log event. This value can be null.",
          "type" : "number"
        },
        "MetricName" : {
          "minLength" : 1,
          "pattern" : "^((?![:*$])[\\x00-\\x7F]){1,255}",
          "description" : "The name of the CloudWatch metric.",
          "type" : "string",
          "maxLength" : 255
        },
        "MetricValue" : {
          "minLength" : 1,
          "pattern" : ".{1,100}",
          "description" : "The value that is published to the CloudWatch metric. For example, if you're counting the occurrences of a particular term like ``Error``, specify 1 for the metric value. If you're counting the number of bytes transferred, reference the value that is in the log event by using $. followed by the name of the field that you specified in the filter pattern, such as ``$.size``.",
          "type" : "string",
          "maxLength" : 100
        },
        "MetricNamespace" : {
          "minLength" : 1,
          "pattern" : "^[0-9a-zA-Z\\.\\-_\\/#]{1,256}",
          "description" : "A custom namespace to contain your metric in CloudWatch. Use namespaces to group together metrics that are similar. For more information, see [Namespaces](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Namespace).",
          "$comment" : "Namespaces can be up to 256 characters long; valid characters include 0-9A-Za-z.-_/#",
          "type" : "string",
          "maxLength" : 256
        },
        "Dimensions" : {
          "minItems" : 1,
          "maxItems" : 3,
          "uniqueItems" : true,
          "description" : "The fields to use as dimensions for the metric. One metric filter can include as many as three dimensions.\n  Metrics extracted from log events are charged as custom metrics. To prevent unexpected high charges, do not specify high-cardinality fields such as ``IPAddress`` or ``requestID`` as dimensions. Each different value found for a dimension is treated as a separate metric and accrues charges as a separate custom metric. \n CloudWatch Logs disables a metric filter if it generates 1000 different name/value pairs for your specified dimensions within a certain amount of time. This helps to prevent accidental high charges.\n You can also set up a billing alarm to alert you if your charges are higher than expected. For more information, see [Creating a Billing Alarm to Monitor Your Estimated Charges](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html).",
          "insertionOrder" : false,
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/Dimension"
          }
        },
        "Unit" : {
          "description" : "The unit to assign to the metric. If you omit this, the unit is set as ``None``.",
          "type" : "string",
          "enum" : [ "Seconds", "Microseconds", "Milliseconds", "Bytes", "Kilobytes", "Megabytes", "Gigabytes", "Terabytes", "Bits", "Kilobits", "Megabits", "Gigabits", "Terabits", "Percent", "Count", "Bytes/Second", "Kilobytes/Second", "Megabytes/Second", "Gigabytes/Second", "Terabytes/Second", "Bits/Second", "Kilobits/Second", "Megabits/Second", "Gigabits/Second", "Terabits/Second", "Count/Second", "None" ]
        }
      },
      "required" : [ "MetricName", "MetricNamespace", "MetricValue" ]
    },
    "Dimension" : {
      "description" : "Specifies the CW metric dimensions to publish with this metric.\n  Because dimensions are part of the unique identifier for a metric, whenever a unique dimension name/value pair is extracted from your logs, you are creating a new variation of that metric.\n For more information about publishing dimensions with metrics created by metric filters, see [Publishing dimensions with metrics from values in JSON or space-delimited log events](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/FilterAndPatternSyntax.html#logs-metric-filters-dimensions).\n  Metrics extracted from log events are charged as custom metrics. To prevent unexpected high charges, do not specify high-cardinality fields such as ``IPAddress`` or ``requestID`` as dimensions. Each different value found for a dimension is treated as a separate metric and accrues charges as a separate custom metric. \n To help prevent accidental high charges, Amazon disables a metric filter if it generates 1000 different name/value pairs for the dimensions that you have specified within a certain amount of time.\n You can also set up a billing alarm to alert you if your charges are higher than expected. For more information, see [Creating a Billing Alarm to Monitor Your Estimated Charges](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html).",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "Value" : {
          "minLength" : 1,
          "description" : "The log event field that will contain the value for this dimension. This dimension will only be published for a metric if the value is found in the log event. For example, ``$.eventType`` for JSON log events, or ``$server`` for space-delimited log events.",
          "type" : "string",
          "maxLength" : 255
        },
        "Key" : {
          "minLength" : 1,
          "description" : "The name for the CW metric dimension that the metric filter creates.\n Dimension names must contain only ASCII characters, must include at least one non-whitespace character, and cannot start with a colon (:).",
          "type" : "string",
          "maxLength" : 255
        }
      },
      "required" : [ "Key", "Value" ]
    }
  },
  "replacementStrategy" : "delete_then_create",
  "properties" : {
    "FieldSelectionCriteria" : {
      "minLength" : 0,
      "description" : "The filter expression that specifies which log events are processed by this metric filter based on system fields. Returns the ``fieldSelectionCriteria`` value if it was specified when the metric filter was created.",
      "type" : "string",
      "maxLength" : 2000
    },
    "MetricTransformations" : {
      "minItems" : 1,
      "maxItems" : 1,
      "description" : "The metric transformations.",
      "insertionOrder" : false,
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/MetricTransformation"
      }
    },
    "FilterPattern" : {
      "description" : "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).",
      "type" : "string",
      "maxLength" : 1024
    },
    "EmitSystemFieldDimensions" : {
      "description" : "The list of system fields that are emitted as additional dimensions in the generated metrics. Returns the ``emitSystemFieldDimensions`` value if it was specified when the metric filter was created.",
      "insertionOrder" : false,
      "type" : "array",
      "items" : {
        "type" : "string"
      }
    },
    "LogGroupName" : {
      "minLength" : 1,
      "pattern" : "^[.\\-_/#A-Za-z0-9]{1,512}",
      "description" : "The name of an existing log group that you want to associate with this metric filter.",
      "type" : "string",
      "maxLength" : 512
    },
    "ApplyOnTransformedLogs" : {
      "description" : "This parameter is valid only for log groups that have an active log transformer. For more information about log transformers, see [PutTransformer](https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutTransformer.html).\n 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.",
      "type" : "boolean"
    },
    "FilterName" : {
      "minLength" : 1,
      "pattern" : "^[^:*]{1,512}",
      "description" : "The name of the metric filter.",
      "type" : "string",
      "maxLength" : 512
    }
  }
}