prometheus-community / postgres_exporter

A PostgreSQL metric exporter for Prometheus
Apache License 2.0
2.83k stars 745 forks source link

Wal DIrectory Size metrics does not occurs #901

Closed umlumpa closed 1 year ago

umlumpa commented 1 year ago
pgWALQuery = 
    SELECT
        COUNT(*) AS segments,
        SUM(size) AS size
    FROM pg_ls_waldir()
    WHERE name ~ '^[0-9A-F]{24}$'`

i dont see metrics from Wal Directory Size but in wal.go this is collecting metrics can you helm how to get WalDirectory size metrics?

JosefMachytkaNetApp commented 1 year ago

Hi guys, I have the same problem - when I use official Docker image, WAL metrics are not there and if I try "--collector.wal" parameter it says unknown parameter. Also when I try help or help-long inside container running official image, it does NOT show any lines related to WAL metrics.

But if I build exporter locally, or in my own image based on Ubuntu, WAL metrics are there and help/help-long shows:

      --[no-]collector.stat_wal_receiver  
                                 Enable the stat_wal_receiver collector (default: disabled).
     ...
      --[no-]collector.wal       Enable the wal collector (default: enabled).

Maybe there is some problem with process building official Docker image?

megamail2000 commented 1 year ago

Hi all, I have the same issue in 0.13.2 - there are no WAL metrics in the output. Also this version provides no configuration setting to enable/disable the WAL subgroup. So, if it was disabled by default I couldn't find a way to fix it.

umlumpa commented 1 year ago

I found soluting for this you can get own metrics by quering the database for example queries.yaml

wal_directory_size_mb:
  query: |
    SELECT
      sum(size) / (1024 * 1024) AS size_mb
    FROM
      pg_ls_waldir()
  metrics:
    - size_mb:
        usage: "GAUGE"
        description: "Size of the WAL directory in gigabytes (mb)"

when start the postgres_exporter add options --extend.query-path=/opt/postgres_exporter/queries.yaml then check metrics for Size of the WAL directory in gigabytes (mb)

JosefMachytkaNetApp commented 1 year ago

I tried today docker image with master tag and this image HAS wal metrics - help-long shows it and --collector.wal works here. But image with latest tag, which is currently 2 months old does NOT contain Wal metrics.

umlumpa commented 1 year ago

I recommend binary or mount file query.yaml to docker it will work and aslo you can add lots of metrics by adding query