0

我部署了一个集群: https ://bitnami.com/stack/prometheus-operator/helm 和 https://github.com/prometheus-community/postgres_exporter

如何正确地将自己的指标添加到 postgres_exporter 导出的指标的 prometheus-operator 列表中?

我是这样尝试的:

helm upgrade kube-prometheus bitnami/kube-prometheus \
    --set prometheus.additionalScrapeConfigs.enabled=true \
    --set prometheus.additionalScrapeConfigs.type=internal \
    --set prometheus.additionalScrapeConfigs.internal.jobList=
      - job_name: 'prometheus-postgres-exporter' 
        static_configs:
          - targets: ['prometheus-postgres-exporter.default:80']

但它不起作用('job_name:' 未添加到 Prometheus 配置中)。

4

1 回答 1

0

如果使用 Prometheus Operator,请使用ServiceMonitors 。

在 postgres-exporter helm 图表中的 values.yaml 下配置以下块。这允许 Prometheus Operator 自动读取和配置作业。

serviceMonitor:
  # When set true then use a ServiceMonitor to configure scraping
  enabled: true
  # Set the namespace the ServiceMonitor should be deployed
  namespace: <namespace where prometheus operator is deployed.>
  # Set how frequently Prometheus should scrape
  interval: 30s
  # Set path to cloudwatch-exporter telemtery-path
  telemetryPath: /metrics
  # Set labels for the ServiceMonitor, use this to define your scrape label for Prometheus Operator
  # labels:
  # Set timeout for scrape
  # timeout: 10s
  # Set of labels to transfer from the Kubernetes Service onto the target
  # targetLabels: []
  # MetricRelabelConfigs to apply to samples before ingestion
  # metricRelabelings: []
于 2021-08-31T15:25:15.830 回答