在kube-prometheus之后,我已将Prometheus安装到我的Kubernetes v1.17 KOPS集群中,确保设置了--authentication-token-webhook=true
和--authorization-mode=Webhook
prerequisets并配置了kube-prometheus/kube-prometheus-kops.libsonnet指定。
然后我使用提供的https://github.com/helm/charts/tree/master/stable/postgresql使用values-production.yaml,并使用以下设置来安装Postgres:
metrics:
enabled: true
# resources: {}
service:
type: ClusterIP
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9187"
loadBalancerIP:
serviceMonitor:
enabled: true
namespace: monitoring
interval: 30s
scrapeTimeout: 10s
这两个服务都可以正常运行,但是Prometheus并未从Postgres中发现任何指标。
我的postgres Pod上metrics
容器上的日志没有错误,monitoring
名称空间中的任何Pod也没有错误。
要使Postgres指标导出器到达Prometheus,还需要执行哪些其他步骤?
答案 0 :(得分:1)
尝试为Prometheus更新ClusterRole。默认情况下,它无权从非监视名称空间检索Pod,服务和端点的列表。
在我的系统中,最初的ClusterRole是:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: prometheus-k8s
rules:
- apiGroups:
- ""
resources:
- nodes/metrics
verbs:
- get
- nonResourceURLs:
- /metrics
verbs:
- get
我将其更改为:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: prometheus-k8s
rules:
- apiGroups:
- ""
resources:
- nodes/metrics
- services
- endpoints
- pods
verbs:
- get
- list
- watch
- nonResourceURLs:
- /metrics
verbs:
- get
更改之后,Postgres指标将适用于Prometheus。