{
  "description": "AutoscalingMetric defines autoscaling metrics for a set of pods, scoped to\npods within the resource's namespace.",
  "properties": {
    "apiVersion": {
      "description": "APIVersion defines the versioned schema of this representation of an object.\nServers should convert recognized schemas to the latest internal value, and\nmay reject unrecognized values.\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
      "type": [
        "string",
        "null"
      ]
    },
    "kind": {
      "description": "Kind is a string value representing the REST resource this object represents.\nServers may infer this from the endpoint the client submits requests to.\nCannot be updated.\nIn CamelCase.\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
      "type": [
        "string",
        "null"
      ]
    },
    "metadata": {
      "type": [
        "object",
        "null"
      ]
    },
    "spec": {
      "additionalProperties": false,
      "description": "Specification of desired pod and metric selection for target discovery\nby Prometheus.",
      "properties": {
        "endpoints": {
          "description": "The endpoints to scrape on the selected pods (min 1, max 10).\nThis field is deprecated, use metrics.pod instead.",
          "items": {
            "additionalProperties": false,
            "description": "ScrapeEndpoint specifies a Prometheus metrics endpoint to scrape.",
            "properties": {
              "metrics": {
                "description": "List of metrics to scrape (min 1, max 20).",
                "items": {
                  "additionalProperties": false,
                  "description": "Metric specifies a metric to scrape and an optional new name.",
                  "properties": {
                    "exportName": {
                      "description": "ExportName specifies an optional new name for the metric to be used when\nexported. If not set, the original metric 'Name' is used. This is useful for\nrenaming metrics to align with different naming conventions or to avoid\nconflicts.",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "filter": {
                      "additionalProperties": false,
                      "description": "Filter specifies the criteria to filter the metric.",
                      "properties": {
                        "matchLabels": {
                          "additionalProperties": {
                            "maxLength": 128,
                            "pattern": "^[a-zA-Z][a-zA-Z0-9_:-]*$",
                            "type": "string"
                          },
                          "description": "MatchLabels specifies a set of key-value pairs to filter the metric.\nOnly the metric series matching all the specified labels will be selected.",
                          "maxProperties": 10,
                          "type": "object"
                        }
                      },
                      "required": [
                        "matchLabels"
                      ],
                      "type": [
                        "object",
                        "null"
                      ]
                    },
                    "name": {
                      "description": "Name of the metric to scrape.",
                      "minLength": 1,
                      "type": "string"
                    }
                  },
                  "required": [
                    "name"
                  ],
                  "type": "object"
                },
                "maxItems": 20,
                "minItems": 1,
                "type": "array"
              },
              "params": {
                "additionalProperties": {
                  "items": {
                    "type": "string"
                  },
                  "type": "array"
                },
                "description": "HTTP GET params to use when scraping.",
                "type": [
                  "object",
                  "null"
                ]
              },
              "path": {
                "default": "/metrics",
                "description": "HTTP path to scrape metrics from. Defaults to \"/metrics\".",
                "maxLength": 256,
                "type": [
                  "string",
                  "null"
                ],
                "x-kubernetes-validations": [
                  {
                    "message": "Path must be empty or start with '/'.",
                    "rule": "self == '' || self.startsWith('/')"
                  }
                ]
              },
              "port": {
                "description": "Name or number of the port to scrape.",
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "integer"
                  }
                ],
                "x-kubernetes-int-or-string": true,
                "x-kubernetes-validations": [
                  {
                    "message": "Port must be a valid string (1-15 characters) or a valid port number (1-65535).",
                    "rule": "(type(self) == string \u0026\u0026 self.size() \u003e 0 \u0026\u0026 self.size() \u003c 16) || (type(self) == int \u0026\u0026 self \u003e 0 \u0026\u0026 self \u003c= 65535)"
                  }
                ]
              },
              "scheme": {
                "default": "http",
                "description": "Protocol scheme to use to scrape.",
                "enum": [
                  "http",
                  "https"
                ],
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "metrics",
              "port"
            ],
            "type": "object"
          },
          "maxItems": 10,
          "minItems": 1,
          "type": [
            "array",
            "null"
          ]
        },
        "metrics": {
          "description": "Defines a list of autoscaling metrics.",
          "items": {
            "additionalProperties": false,
            "description": "MetricSpec specifies an autoscaling metric.",
            "properties": {
              "pod": {
                "additionalProperties": false,
                "description": "An autoscaling metric computed from a Prometheus metric scraped from a set of pods.",
                "properties": {
                  "containers": {
                    "description": "Defines metrics to be scraped from endpoints within the selected pods.\nEach item typically corresponds to a metrics endpoint in a container.",
                    "items": {
                      "additionalProperties": false,
                      "description": "ContainerMetrics defines the configuration for scraping metrics from a container endpoint.",
                      "properties": {
                        "endpoint": {
                          "additionalProperties": false,
                          "description": "The Prometheus endpoint to scrape within the container.",
                          "properties": {
                            "params": {
                              "additionalProperties": {
                                "items": {
                                  "type": "string"
                                },
                                "type": "array"
                              },
                              "description": "HTTP GET params to use when scraping.",
                              "type": [
                                "object",
                                "null"
                              ]
                            },
                            "path": {
                              "default": "/metrics",
                              "description": "HTTP path to scrape metrics from. Defaults to \"/metrics\".",
                              "maxLength": 256,
                              "type": [
                                "string",
                                "null"
                              ],
                              "x-kubernetes-validations": [
                                {
                                  "message": "Path must be empty or start with '/'.",
                                  "rule": "self == '' || self.startsWith('/')"
                                }
                              ]
                            },
                            "port": {
                              "description": "Name or number of the port to scrape. The Pod spec must explicitly declare\nthe port for the metric endpoint, otherwise the metric is ignored and not\ncollected.",
                              "oneOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "integer"
                                }
                              ],
                              "x-kubernetes-int-or-string": true
                            },
                            "scheme": {
                              "default": "HTTP",
                              "description": "Protocol scheme to use to scrape. Defaults to \"HTTP\".",
                              "enum": [
                                "HTTP",
                                "HTTPS"
                              ],
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "port"
                          ],
                          "type": "object"
                        },
                        "metrics": {
                          "description": "The specific metrics to collect from this endpoint.",
                          "items": {
                            "additionalProperties": false,
                            "description": "ContainerMetric defines a single metric to be collected from a container.",
                            "properties": {
                              "gauge": {
                                "additionalProperties": false,
                                "description": "An autoscaling metric that is obtained from a gauge metric.",
                                "properties": {
                                  "filter": {
                                    "additionalProperties": false,
                                    "description": "An optional filter.",
                                    "properties": {
                                      "matchLabels": {
                                        "additionalProperties": {
                                          "maxLength": 128,
                                          "pattern": "^[a-zA-Z][a-zA-Z0-9_:-]*$",
                                          "type": "string"
                                        },
                                        "description": "MatchLabels specifies a set of key-value pairs to filter the metric.\nOnly the metric series matching all the specified labels will be selected.",
                                        "maxProperties": 10,
                                        "type": "object"
                                      }
                                    },
                                    "required": [
                                      "matchLabels"
                                    ],
                                    "type": [
                                      "object",
                                      "null"
                                    ]
                                  },
                                  "loadBalancing": {
                                    "additionalProperties": false,
                                    "description": "Configuration for metrics used in load balancing",
                                    "properties": {
                                      "enabled": {
                                        "description": "Whether this metric will be used as a custom metric for utilization-based load balancing.",
                                        "type": [
                                          "boolean",
                                          "null"
                                        ]
                                      }
                                    },
                                    "type": [
                                      "object",
                                      "null"
                                    ]
                                  },
                                  "name": {
                                    "description": "The name of the autoscaling metric. Must be unique within an AutoscalingMetric resource.",
                                    "maxLength": 63,
                                    "minLength": 1,
                                    "pattern": "^[a-z]([a-z0-9-_]*[a-z0-9])?$",
                                    "type": "string"
                                  },
                                  "prometheusMetricName": {
                                    "description": "The name of the Prometheus metric to scrape. If not specified, defaults to the \"name\" field.",
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  }
                                },
                                "required": [
                                  "name"
                                ],
                                "type": [
                                  "object",
                                  "null"
                                ],
                                "x-kubernetes-validations": [
                                  {
                                    "message": "Metric name is too long for load balancing; it must be at most 45 characters when load balancing is enabled.",
                                    "rule": "!has(self.loadBalancing) || !has(self.loadBalancing.enabled) || !self.loadBalancing.enabled || size(self.name + 'gke.named_metrics.') \u003c= 63"
                                  }
                                ]
                              }
                            },
                            "type": "object",
                            "x-kubernetes-validations": [
                              {
                                "message": "exactly one of the fields in [gauge] must be set",
                                "rule": "[has(self.gauge)].filter(x,x==true).size() == 1"
                              }
                            ]
                          },
                          "maxItems": 100,
                          "minItems": 1,
                          "type": "array"
                        }
                      },
                      "required": [
                        "endpoint",
                        "metrics"
                      ],
                      "type": "object"
                    },
                    "maxItems": 100,
                    "type": "array"
                  },
                  "selector": {
                    "additionalProperties": false,
                    "description": "Label selector that specifies which pods are selected for this\nautoscaling metric configuration. Only matchLabels are supported.",
                    "properties": {
                      "matchExpressions": {
                        "description": "matchExpressions is a list of label selector requirements. The requirements are ANDed.",
                        "items": {
                          "additionalProperties": false,
                          "description": "A label selector requirement is a selector that contains values, a key, and an operator that\nrelates the key and values.",
                          "properties": {
                            "key": {
                              "description": "key is the label key that the selector applies to.",
                              "type": "string"
                            },
                            "operator": {
                              "description": "operator represents a key's relationship to a set of values.\nValid operators are In, NotIn, Exists and DoesNotExist.",
                              "type": "string"
                            },
                            "values": {
                              "description": "values is an array of string values. If the operator is In or NotIn,\nthe values array must be non-empty. If the operator is Exists or DoesNotExist,\nthe values array must be empty. This array is replaced during a strategic\nmerge patch.",
                              "items": {
                                "type": "string"
                              },
                              "type": [
                                "array",
                                "null"
                              ],
                              "x-kubernetes-list-type": "atomic"
                            }
                          },
                          "required": [
                            "key",
                            "operator"
                          ],
                          "type": "object"
                        },
                        "type": [
                          "array",
                          "null"
                        ],
                        "x-kubernetes-list-type": "atomic"
                      },
                      "matchLabels": {
                        "additionalProperties": {
                          "type": "string"
                        },
                        "description": "matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels\nmap is equivalent to an element of matchExpressions, whose key field is \"key\", the\noperator is \"In\", and the values array contains only \"value\". The requirements are ANDed.",
                        "type": [
                          "object",
                          "null"
                        ]
                      }
                    },
                    "type": "object",
                    "x-kubernetes-map-type": "atomic",
                    "x-kubernetes-validations": [
                      {
                        "message": "Selector must use matchLabels and it must not be empty.",
                        "rule": "has(self.matchLabels) \u0026\u0026 self.matchLabels.size() \u003e 0"
                      },
                      {
                        "message": "Selector must not use matchExpressions.",
                        "rule": "!has(self.matchExpressions) || self.matchExpressions.size() == 0"
                      }
                    ]
                  }
                },
                "required": [
                  "containers",
                  "selector"
                ],
                "type": [
                  "object",
                  "null"
                ]
              },
              "prometheus": {
                "additionalProperties": false,
                "description": "An autoscaling metric that is obtained from a Prometheus server via a PromQL query.",
                "properties": {
                  "backend": {
                    "additionalProperties": false,
                    "description": "Configuration for the Prometheus backend. Defaults to the Google Managed Prometheus in the GCP project where the cluster runs.",
                    "properties": {
                      "projectId": {
                        "description": "The GCP Project ID of the Google Managed Prometheus endpoint to use. Defaults to the cluster project.",
                        "type": [
                          "string",
                          "null"
                        ]
                      }
                    },
                    "type": [
                      "object",
                      "null"
                    ]
                  },
                  "metricLabels": {
                    "additionalProperties": false,
                    "description": "MetricLabels specifies the names of the labels expected to be present in the query result.\nThese labels are used to match against expected values and to extract pod information (e.g., name, namespace).",
                    "properties": {
                      "clusterName": {
                        "description": "Cluster name. Defaults to \"cluster\".",
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "location": {
                        "description": "Location of the cluster. Defaults to \"location\".",
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "namespace": {
                        "description": "Namespace of the pod. Defaults to \"namespace\".",
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "podName": {
                        "description": "Name of the pod. Defaults to \"pod\".",
                        "type": [
                          "string",
                          "null"
                        ]
                      },
                      "projectId": {
                        "description": "GCP project ID. Defaults to \"project_id\".",
                        "type": [
                          "string",
                          "null"
                        ]
                      }
                    },
                    "type": [
                      "object",
                      "null"
                    ]
                  },
                  "name": {
                    "description": "The name of the autoscaling metric. Must be unique within an AutoscalingMetric resource.",
                    "maxLength": 63,
                    "minLength": 1,
                    "pattern": "^[a-z]([a-z0-9-_]*[a-z0-9])?$",
                    "type": "string"
                  },
                  "query": {
                    "description": "The PromQL query to execute to compute the final autoscaling metric.",
                    "type": "string"
                  },
                  "type": {
                    "description": "The type of the metric. (External, Pods).\nThis defines the granularity of the metric.\nIf set to 'Pods', the metric is expected to be a per-pod metric.\nIf set to 'External', it's expected to be a global metric.\nThe type must match the metric type of the HorizontalPodAutoscaler (HPA) that references this AutoscalingMetric.",
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "name",
                  "query"
                ],
                "type": [
                  "object",
                  "null"
                ]
              }
            },
            "type": "object",
            "x-kubernetes-validations": [
              {
                "message": "exactly one of the fields in [pod prometheus] must be set",
                "rule": "[has(self.pod),has(self.prometheus)].filter(x,x==true).size() == 1"
              }
            ]
          },
          "maxItems": 10,
          "minItems": 1,
          "type": [
            "array",
            "null"
          ]
        },
        "selector": {
          "additionalProperties": false,
          "description": "Label selector that specifies which pods are selected for this\nautoscaling metric configuration. Please note that only matchLabels\nis currently supported.\nThis field is deprecated, use metrics.pod instead.",
          "properties": {
            "matchExpressions": {
              "description": "matchExpressions is a list of label selector requirements. The requirements are ANDed.",
              "items": {
                "additionalProperties": false,
                "description": "A label selector requirement is a selector that contains values, a key, and an operator that\nrelates the key and values.",
                "properties": {
                  "key": {
                    "description": "key is the label key that the selector applies to.",
                    "type": "string"
                  },
                  "operator": {
                    "description": "operator represents a key's relationship to a set of values.\nValid operators are In, NotIn, Exists and DoesNotExist.",
                    "type": "string"
                  },
                  "values": {
                    "description": "values is an array of string values. If the operator is In or NotIn,\nthe values array must be non-empty. If the operator is Exists or DoesNotExist,\nthe values array must be empty. This array is replaced during a strategic\nmerge patch.",
                    "items": {
                      "type": "string"
                    },
                    "type": [
                      "array",
                      "null"
                    ],
                    "x-kubernetes-list-type": "atomic"
                  }
                },
                "required": [
                  "key",
                  "operator"
                ],
                "type": "object"
              },
              "type": [
                "array",
                "null"
              ],
              "x-kubernetes-list-type": "atomic"
            },
            "matchLabels": {
              "additionalProperties": {
                "type": "string"
              },
              "description": "matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels\nmap is equivalent to an element of matchExpressions, whose key field is \"key\", the\noperator is \"In\", and the values array contains only \"value\". The requirements are ANDed.",
              "type": [
                "object",
                "null"
              ]
            }
          },
          "type": [
            "object",
            "null"
          ],
          "x-kubernetes-map-type": "atomic",
          "x-kubernetes-validations": [
            {
              "message": "Selector must use matchLabels and it must not be empty.",
              "rule": "has(self.matchLabels) \u0026\u0026 size(self.matchLabels) \u003e 0"
            },
            {
              "message": "Selector must not use matchExpressions.",
              "rule": "!has(self.matchExpressions) || self.matchExpressions.size() == 0"
            }
          ]
        }
      },
      "type": "object",
      "x-kubernetes-validations": [
        {
          "message": "Either 'metrics' must be set, or both 'selector' and 'endpoints' must be set.",
          "rule": "has(self.metrics) || (has(self.endpoints) \u0026\u0026 has(self.selector))"
        },
        {
          "message": "Fields 'selector' and 'endpoints' must both be set or unset.",
          "rule": "has(self.endpoints) == has(self.selector)"
        }
      ]
    },
    "status": {
      "additionalProperties": false,
      "description": "Current information about the object.",
      "properties": {
        "metricStatuses": {
          "description": "The list of statuses for each metric defined in the spec.",
          "items": {
            "additionalProperties": false,
            "description": "Describes the status of a single metric.",
            "properties": {
              "errors": {
                "description": "List of errors associated with the metric, e.g. invalid label keys.",
                "items": {
                  "type": "string"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "gclbName": {
                "description": "The name of the metric to be specified as a custom utilization metric in a GCPBackendPolicy resource.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "hpaName": {
                "description": "The name of the metric to be specified in a HorizontalPodAutoscaler resource.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "name": {
                "description": "The name of the metric as defined in the AutoscalingMetricSpec.",
                "type": "string"
              }
            },
            "required": [
              "name"
            ],
            "type": "object"
          },
          "type": [
            "array",
            "null"
          ]
        }
      },
      "type": [
        "object",
        "null"
      ]
    }
  },
  "required": [
    "spec"
  ],
  "type": "object"
}