如何配置Prometheus Postgres导出器和收集指标

时间:2019-04-29 13:16:11

标签: postgresql docker-swarm prometheus

我已经通过SwarmProm部署了Prometheus / Grafana等。然后,我继续将它创建的网络添加到我的PSQL Container的服务中。

  as-postgres:
    image: xxxx.dkr.ecr.us-east-2.amazonaws.com/aspg:latest
    ports:
        - "54321:5432"
    volumes:
      - db-data:/var/lib/postgresql/data
    networks:
      - as-db
      - lognet
      - ras-mon_net
    healthcheck:
      test: ["CMD", "/healthcheck.sh"]
      interval: 5s
      timeout: 1s
      retries: 30
    logging:
      driver: "fluentd"
      options:
        tag: ras.as-postgres
        fluentd-async-connect: "true"
        fluentd-sub-second-precision: "true"
    deploy:
      restart_policy:
        condition: any
        delay: 10s
        max_attempts: 20
        window: 120s

networks:
  as:
  as-db:
    driver: overlay
  lognet:
    external: true
  ras-mon_net:
    external: true

然后,我将出口程序与prometheus部署在同一堆栈中。

  psql_exporter:
    image: wrouesnel/postgres_exporter
    deploy:
      mode: replicated
      replicas: 1
    networks:
      - net
    environment:
      DATA_SOURCE_NAME: postgresql://username:password@as-postgres:5432/db_name

在Prometheus上没有错误启动,并且导出器似乎指示其连接。

root@docker-host:~# docker container logs f1d1e92d3af2
time="2019-04-29T10:29:23Z" level=info msg="Established new database connection to \"as-postgres:5432\"." source="postgres_exporter.go:767"
time="2019-04-29T10:29:23Z" level=info msg="Semantic Version Changed on \"as-postgres:5432\": 0.0.0 -> 11.2.0" source="postgres_exporter.go:1192"
time="2019-04-29T10:29:23Z" level=info msg="Starting Server: :9187" source="postgres_exporter.go:1360"

将此行添加到prometheus服务后,

环境:   -JOBS = postgres_exporter:9187

产生的结果

- job_name: postgres_exporter
  scrape_interval: 15s
  scrape_timeout: 10s
  metrics_path: /metrics
  scheme: http
  dns_sd_configs:
  - names:
    - tasks.postgres_exporter
    refresh_interval: 30s
    type: A
    port: 9187

我的:9090 / targets显示postgres导出器为0/0

我必须在某个地方失踪,而我只是没能过手。

0 个答案:

没有答案