首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >基于使用HPA的自定义日志指标的GCP - Scale GKE pods

基于使用HPA的自定义日志指标的GCP - Scale GKE pods
EN

Stack Overflow用户
提问于 2021-10-05 19:56:33
回答 1查看 153关注 0票数 0

我想在GKE HPA上使用自定义日志指标。指标可以在指标资源管理器上查看,但无法在HPA上使用。我们已经安装了自定义指标适配器,并且我们能够成功地使用其他自定义指标,如kubernetes.io|pod|network|received_bytes_count进行扩展。下图显示了我要在HPA上使用的自定义指标的指标资源管理器图表

此指标是从应用程序日志创建的

在HPA yaml后面使用以使用该指标

代码语言:javascript
复制
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

请查找下面的错误

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-06 08:21:34

不幸的是,upper case letters in metric names are not supported as HPA将指标视为伪资源,这意味着它们不区分大小写。我还认为,对于指标名称,括号也是无效字符。

您是否可以将指标名称更改为小写并删除括号?也许是像similar_products_rts_inbound_request_count这样的东西

编辑:我刚刚注意到的另一个问题是,指标是一个容器指标,而不是一个pod指标。在this change之前,有必要修改自定义指标适配器部署以支持容器指标。您可以使用当前manifest更新部署,也可以通过添加--fallback-for-container-metrics=true来修改当前部署

代码语言:javascript
复制
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 
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69456545

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档