【问题标题】:How do you get prometheus metrics from postgresql?您如何从 postgresql 获取 prometheus 指标?
【发布时间】:2020-01-22 18:15:42
【问题描述】:

我已在 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 安装了 Postgres,使用提供的 values-production.yaml 和以下设置:

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,还需要哪些额外步骤?

【问题讨论】:

    标签: postgresql kubernetes prometheus prometheus-operator


    【解决方案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。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-05
      • 1970-01-01
      相关资源
      最近更新 更多