github nbari/pg_exporter 0.22.4

53 minutes ago

Fixed

  • The statements collector decided whether to filter on toplevel with a catalog
    probe that it cached for the life of the process, and that looked at the
    pg_stat_statements view while the scrape reads the function. That could:

    • fail every scrape with column s.toplevel does not exist (503) after the extension
      was dropped and created again at 1.8, until the exporter was restarted;
    • keep reading without the filter after ALTER EXTENSION pg_stat_statements UPDATE
      from a version older than 1.9, until the exporter was restarted;
    • drop the filter when a relation called pg_stat_statements came earlier in
      search_path, or when the role could not read pg_attribute.

    Without the filter, under pg_stat_statements.track = all a statement that only runs
    inside a function was exported, and one that runs both ways had its two entries
    overwrite each other. The filter is now part of the scrape query: a NATURAL JOIN on
    toplevel keeps only top-level rows wherever the function returns that column, and
    every row on 1.8, which has none. There is no probe left to go stale or to disagree
    with the call it describes, and the scrape needs no catalog access beyond what 0.22.3
    needed.

  • The database collector failed whenever a scrape overlapped a DROP DATABASE.
    pg_database_size raises an error for a database that was dropped after the statement
    had listed it, and that error failed the collector for the scrape. When that happens
    the databases are now read one by one, so only the one that vanished is left out. Where
    PostgreSQL answers NULL for it instead (14, and a superuser up to 17), the catalog is
    asked whether it still exists. The normal case is still a single statement.

  • The same collector asked for each size by database name, which PostgreSQL looks up
    a second time. A database dropped and created again under its name in between was
    reported with the old connection limit and the new size. Sizes are now asked for by
    the OID of the row that was listed, so both values describe one database (short of
    recreating it with an explicitly chosen old OID in the middle of a scrape).

  • pg_database_size_bytes reported 0 for a database whose size PostgreSQL answered as
    NULL. An unknown size is no longer published as 0 bytes; the series is absent for
    that scrape.

  • pg_stat_user_tables_autovacuum_threshold_ratio and
    pg_stat_user_tables_autoanalyze_threshold_ratio did not follow the server's own
    trigger point, in two ways:

    • They reported 0 for every table without live rows, which after a mass delete is
      exactly the table that is due. Both are now computed for such tables. This also
      makes the 0.22.3 note true for them: with a zero trigger point the ratio is the
      tuple count.
    • The scaled part used the live-tuple counter. Autovacuum uses reltuples, the row
      estimate from the last VACUUM or ANALYZE, and so do the ratios now. The two
      differ most right after a bulk delete or load: a 100-row table that was analyzed and
      then emptied, with threshold 10 and scale factor 1, is at 100/110 = 0.91 of its
      trigger point, not past it.

    Values of both ratios change for tables whose row count moved since their last
    vacuum or analyze, and an alert on them can now fire for emptied tables that it used
    to miss.

  • On PostgreSQL 18 and later the vacuum ratio honours autovacuum_vacuum_max_threshold
    (the table reloption or the server setting). It was ignored, which under-reported how
    due a table is once the cap is lower than threshold + scale_factor * reltuples.

Security

  • A release no longer pushes the container image before every build has succeeded.
    The image job waited for the binaries only, so sha-<commit> could be public while
    the crate build was still running, and it was pushed before it had been run. It now
    waits for the crate too and runs the image before pushing it.
  • The release guard and just release take CI OK from the Test & Build workflow's own
    jobs, and go by the one that completed last across runs and re-run attempts. They used
    to accept the latest check named CI OK on the commit, whoever published it, and an
    earlier success could stand in for a later failure.
  • just release tells the workflow which commit it means, and the guard refuses any
    other. develop moving between the two could otherwise release a commit the operator
    had not looked at. The recipe also follows its own run by a request id, not "the
    newest run of this commit".
  • crates.io is asked before the image is pushed, and again right before the release is
    created: a version that already exists there with other bytes stops the run before
    any tag or release exists. After the upload the publish job compares the checksum
    crates.io reports with the .crate in the GitHub release. Any registry answer other
    than "found" or "not found" is an error, not "not published yet".
  • scripts/setup-local-test-db.sh and the other helper scripts no longer print a DSN
    in their messages; a password in the query string or a keyword was shown in clear
    text. They name the destination host instead, and the setup script validates its
    target before it prints anything about it.
  • The test suite checks where its database connection really goes, in the Rust tests,
    in scripts/setup-local-test-db.sh and for the containers tests start themselves. The
    old guard looked for localhost anywhere in the DSN and did not see PGHOSTADDR, so
    the suite, which drops databases and terminates backends, could be pointed at another
    server while the DSN looked local. The devcontainer opt-in now admits its postgres
    service only, where it used to switch the guard off.
  • Test fixtures derive their isolated-database and role connections without the
    dbname, user and password query parameters, which SQLx lets override the URL, and
    verify current_database() before use. With ?dbname= in PG_EXPORTER_DSN a test
    could change the caller's database and still pass.

Changed

  • Update sysinfo to 0.40.4, which the system collector and the exporter's own
    process metrics are built on. It makes creating its system handle and reading the load
    average fallible, so the collectors now create the handle on first use and handle
    both failures instead of assuming success:

    • When the load average cannot be read, pg_system_load1, pg_system_load5 and
      pg_system_load15 keep their last values (0 if it never could be read) and a
      warning is logged. A platform without load averages is skipped silently.
    • On a platform sysinfo does not support, the affected metrics are not updated and
      each affected collector logs one warning.

    Metric names and labels are unchanged, and so are the values on Linux, with one
    possible exception: sysinfo 0.40 keeps no /proc/<pid>/stat descriptor open for
    the exporter's own process, so pg_exporter_process_open_fds may read one lower.
    On FreeBSD
    pg_system_memory_available_bytes rises
    : it now includes inactive and cache pages
    and buffer space, where it used to equal free memory.

  • Drop the unused ipnetwork and uuid features of SQLx. Nothing decoded those types,
    and the features kept SQLx's MySQL and SQLite drivers in the lockfile.

  • Update built to 0.9.0. It only runs at build time and still records the commit
    hash that --version and /health report.

  • Remove the nix development dependency; nothing used it.

Tests

  • CI now exports the two-platform image as an OCI archive, checks that its index holds
    both platforms and, for each, its own attestation with an SBOM and provenance, and
    runs the amd64 image out of that archive. It used to leave the two-platform build in
    the build cache and run a second, separate build.
  • The vacuum-progress test always cancels its throttled VACUUM and drops its database,
    also when a scrape fails; the issue 35 test checks each system sub-collector on its
    own; the standby reply-time test identifies the reply by its timestamp; and the
    LazySystem tests pass on a host without a sysinfo backend.
  • Make the issue 35 regression test deterministic. It checked that another task ran
    while the system collector was collecting, which is a race: on a busy host the
    offloaded reads can finish before the collector is first suspended, and a correct
    collector then never yields. Under full CPU load it failed about 1 run in 30, and now
    that CI OK gates a release, that blocks releases. The test now holds the runtime's
    only blocking thread, so an offloading collector must yield and an inline one cannot.

Documentation

  • Replication: pg_replication_slots_pg_wal_lsn_diff on a standby is measured against
    the last WAL received by streaming. A standby that never streamed reports 0, and one
    that switched from streaming to the archive keeps measuring against its last streamed
    position.
  • Statements: the metric names in the README carry the postgres_ prefix they are
    exported with; the PromQL examples returned nothing as written.
  • Statements: of the measures against secrets in query_short, only
    --statements.query-text-refresh=0 rules exposure out; the two server-side ones are
    prospective and partial, and nothing removes a label Prometheus already stored.
  • Releasing: Dependabot security updates target main whatever the configuration says,
    and have to be applied on sandbox.

Full changelog: 0.22.3...0.22.4

Container image

podman pull ghcr.io/nbari/pg_exporter:0.22.4

Digest: sha256:bc0f5348a33af17e8dd6bc17aabdb5bf1c9c2887dd5e98af98f03c8ab8fefaf6

Verify a download

sha256sum --check --ignore-missing SHA256SUMS
gh attestation verify <file> --repo nbari/pg_exporter --signer-workflow nbari/pg_exporter/.github/workflows/release.yml
gh attestation verify oci://ghcr.io/nbari/pg_exporter:0.22.4 --repo nbari/pg_exporter --signer-workflow nbari/pg_exporter/.github/workflows/release.yml

Built with Rust 1.100.1.

Don't miss a new pg_exporter release

NewReleases is sending notifications on new releases.