简体   繁体   English

GCP - 使用 HPA 根据自定义日志记录指标缩放 GKE pod

[英]GCP - Scale GKE pods based on custom logging metric using HPA

I want to use the Custom log metrics on GKE HPA.我想在 GKE HPA 上使用自定义日志指标。 Metrics are able to view on metrics explorer but unable to use it on HPA. Metrics 可以在 Metrics Explorer 上查看,但无法在 HPA 上使用。 We have installed Custom metrics adapter and We are able to use other custom metrics like kube.netes.io|pod.network|received_bytes_count successfully for scaling.我们已经安装了自定义指标适配器,并且我们能够成功使用其他自定义指标(如kube.netes.io|pod.network|received_bytes_count )进行扩展。 Below image shows the Metrics explorer graph for custom metric that i want to use on HPA下图显示了我想在 HPA 上使用的自定义指标的指标浏览器图表

This metric was created from application logs该指标是根据应用程序日志创建的

在此处输入图像描述

Used following HPA yaml to use that metric在 HPA yaml 之后使用以使用该指标

apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
  name:   "similar-products-rts-hpa"
  namespace: relevancy
spec:
  behavior:
    scaleUp:
      stabilizationWindowSeconds: 120
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: similar-products
  minReplicas: 3
  maxReplicas: 6
  metrics:
    - type: Pods
      pods:
        metric:
          name: "logging.googleapis.com|user|Similar_Products(RTS)_Inbound_Request_Count"
        target:
          type: AverageValue
          averageValue: 25

Please find the error below请找出下面的错误

The HPA was unable to compute the replica count: unable to get metric logging.googleapis.com|user|Similar_Products(RTS)_Inbound_Request_Count: unable to fetch metrics from custom metrics API: googleapi: Error 400: The supplied filter does not specify a valid combination of metric and monitored resource descriptors. The query will not return any time series., badRequest

Unfortunately, upper case letters in metric names are not supported as HPA treats metrics as pseudo resources which means they are not case sensitive.不幸的是,不支持指标名称中的大写字母,因为 HPA 将指标视为伪资源,这意味着它们不区分大小写。 I also believe that parentheses are invalid characters as well for metric names.我还认为括号对于指标名称也是无效字符。

Any chance you can change your metric name to lowercase and remove the parentheses?您是否有机会将指标名称更改为小写并删除括号? Maybe something like similar_products_rts_inbound_request_count ?也许像similar_products_rts_inbound_request_count这样的东西?

EDIT: The other issue I just noticed is that the metric is a container metric and not a pod metric.编辑:我刚刚注意到的另一个问题是指标是容器指标而不是 pod 指标。 Prior tothis change , it was necessary to modify the custom metrics adapter deployment to support container metrics.此更改之前,有必要修改自定义指标适配器部署以支持容器指标。 You can either update your deployment with the current manifest ,or you can modify your current deployment by adding --fallback-for-container-metrics=true :您可以使用当前清单更新部署,也可以通过添加--fallback-for-container-metrics=true来修改当前部署:

spec:
      serviceAccountName: custom-metrics-stackdriver-adapter
      containers:
      - image: gcr.io/gke-release/custom-metrics-stackdriver-adapter:v0.12.0-gke.0
        imagePullPolicy: Always
        name: pod-custom-metrics-stackdriver-adapter
        command:
        - /adapter
        - --use-new-resource-model=true
        - --fallback-for-container-metrics=true
        resources:
          limits:
            cpu: 250m
            memory: 200Mi
          requests:
            cpu: 250m
            memory: 200Mi 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 GKE 中的日志记录自定义指标进行横向 pod 自动缩放 - Horizontal pod autoscaling using a logging custom metric in GKE Google Kube.netes Engine (GKE) 上的 Horizontal Pod Autoscaler (HPA) 通过 Stackdriver 外部指标使用 Ingress LoadBalancer 的后端延迟 - Horizontal Pod Autoscaler (HPA) on Google Kubernetes Engine (GKE) using Backend Latency from an Ingress LoadBalancer via Stackdriver External Metric Kube.netes HPA 使用自定义指标快速扩展 - Kubernetes HPA Scales Up Rapidly with Custom Metric 在 GCP Logging 中需要 GKE 部署失败日志 - Need GKE Deployment Failed Logs in GCP Logging 基于 pod 或部署的 GKE 账单明细 - Breakdown of GKE bill based on pods or deployments 当 pod 配置为在 AKS 虚拟节点上运行时,HPA 是否也缩放 pod - Does HPA also scale pods when the pods are configured to run on AKS Virtual Nodes GCP 日志记录控制台不显示某些 GKE 日志消息 - GCP logging console doesn't display some GKE log messages Kube.netes HPA - 扩大冷却时间 - Kubernetes HPA - Scale up cooldown 无法在使用“带有 Docker 的 Ubuntu”映像创建的 GKE 集群上部署 pod - Unable to deploy pods on GKE cluster created using 'Ubuntu with Docker' image 使用 Google Serverless VPC 访问具有云功能的 GKE pod - Access GKE pods with Cloud functions using Google Serverless VPC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM