{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/amazon-cloudwatch/json-schema/amazon-cloudwatch-put-metric-filter-request-schema.json",
  "title": "PutMetricFilterRequest",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/amazon-cloudwatch-metric-filter-api-openapi.yml#/components/schemas/PutMetricFilterRequest",
  "type": "object",
  "properties": {
    "logGroupName": {
      "type": "string",
      "description": "The name of the log group."
    },
    "filterName": {
      "type": "string",
      "description": "A name for the metric filter."
    },
    "filterPattern": {
      "type": "string",
      "description": "A filter pattern for extracting metric data out of ingested log events."
    },
    "metricTransformations": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MetricTransformation"
      },
      "description": "A collection of information that defines how metric data gets emitted."
    },
    "applyOnTransformedLogs": {
      "type": "boolean",
      "description": "This parameter is valid only for log groups that have an active log transformer. For more information about log transformers, see PutTransformer. If the log group uses either a log-group level or account-level transformer, and you specify true, the metric filter will be applied on the transformed version of the log events instead of the original ingested log events."
    },
    "fieldSelectionCriteria": {
      "type": "string",
      "description": "A filter expression that specifies which log events should be processed by this metric filter based on system fields such as source account and source region. Uses selection criteria syntax with operators like =, !=, AND, OR, IN, NOT IN. Example: @aws.region = \"us-east-1\" or @aws.account IN [\"123456789012\", \"987654321098\"]. Maximum length: 2000 characters."
    },
    "emitSystemFieldDimensions": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "A list of system fields to emit as additional dimensions in the generated metrics. Valid values are @aws.account and @aws.region. These dimensions help identify the source of centralized log data and count toward the total dimension limit for metric filters."
    }
  },
  "required": [
    "logGroupName",
    "filterName",
    "filterPattern",
    "metricTransformations"
  ],
  "$defs": {
    "MetricTransformation": {
      "type": "object",
      "properties": {
        "metricName": {
          "type": "string",
          "description": "The name of the CloudWatch metric."
        },
        "metricNamespace": {
          "type": "string",
          "description": "A custom namespace to contain your metric in CloudWatch. Use namespaces to group together metrics that are similar. For more information, see Namespaces."
        },
        "metricValue": {
          "type": "string",
          "description": "The value to publish to the CloudWatch metric when a filter pattern matches a log event."
        },
        "defaultValue": {
          "type": "number",
          "description": "(Optional) The value to emit when a filter pattern does not match a log event. This value can be null."
        },
        "dimensions": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "The fields to use as dimensions for the metric. One metric filter can include as many as three dimensions. 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. 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 accidenta"
        },
        "unit": {
          "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"
          ],
          "description": "The unit to assign to the metric. If you omit this, the unit is set as None."
        }
      },
      "required": [
        "metricName",
        "metricNamespace",
        "metricValue"
      ]
    }
  }
}