我们在kubernetes集群上部署了metricbeat。没有任何问题,所有指标都被推入了 flex 搜索索引。但是,观察metribeat日志中的以下错误,并且不确定是什么引起了该错误。

2020-07-01T14:05:25.421Z     INFO    module/wrapper.go:259   Error fetching data for metricset kubernetes.apiserver: error getting metrics: unexpected status code 403 from server
我们已经研究并尝试了建议的集群角色,但未见任何成功。以下是我们正在使用的集群角色。
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: metricbeat
  labels:
    k8s-app: metricbeat
rules:
  - apiGroups:
      - "extensions"
      - "apps"
      - "v1"
      - ""
    resources:
      - namespaces
      - pods
      - events
      - deployments
      - nodes
      - replicasets
      - statefulsets
      - nodes/metrics
      - nodes/stats
    verbs:
      - get
      - list
      - watch
让我知道是否有人碰过并修复了该问题。提前致谢。

最佳答案

看来Metricbeat无法连接到K8S API服务器,HTTP 403是一个安全错误。
根据the official documentation,您可以确保将它们添加到ClusterRole规则中:

rules:
- nonResourceURLs:
  - /metrics
  verbs:
  - get

07-24 09:39
查看更多