Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgresql_metrics Vector source does not work with PostgreSQL 17 #22094

Open
unflxw opened this issue Dec 30, 2024 · 1 comment
Open

postgresql_metrics Vector source does not work with PostgreSQL 17 #22094

unflxw opened this issue Dec 30, 2024 · 1 comment
Labels
source: postgresql_metrics Anything `postgresql_metrics` source related type: bug A code related bug.

Comments

@unflxw
Copy link
Contributor

unflxw commented Dec 30, 2024

A note for the community

I have uploaded a reproduction case for convenience: https://github.com/unflxw/vector-postgres-repro

Thank you for looking into this :)

Problem

When pointing the postgresql_metrics vector source at a PostgreSQL 17 instance, the source does not emit any metrics other than up, and instead emits errors related to the checkpoints_timed column being missing:

ERROR source{component_kind="source" component_id=postgres component_type=postgresql_metrics}: 
vector::internal_events::postgresql_metrics: PostgreSQL query error. 
error=failed to get value by key: checkpoints_timed (reason: invalid column `checkpoints_timed`) error_type="request_failed" 
stage="receiving" 
endpoint=postgresql:///vector?host=postgres&port=5432 
internal_log_rate_limit=true

This issue occurs when using PostgreSQL versions 17.0, 17.1 or 17.2. They do not occur on the latest 16.x release.

The likely cause is that the checkpoints_timed column, along with other metrics in pg_stat_bgwriter, was renamed and moved to the pg_stat_checkpointer table in PostgreSQL 17: https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=96f052613f35d07d001c8dd2f284ca8d95f82d1b

Configuration

sources:
  postgres:
    type: postgresql_metrics
    endpoints:
      - postgresql://vector:vector@postgres:5432/vector

transforms:
  postgres_as_log:
    type: metric_to_log
    inputs:
      - postgres

sinks:
  console:
    type: console
    inputs:
      - postgres_as_log
    encoding:
      codec: logfmt

Version

vector 0.44.0 (x86_64-unknown-linux-musl 029a2ff 2024-12-28 05:06:50.742487563) (current timberio/vector:nightly-alpine)

Debug Output

https://gist.github.com/unflxw/a38e28b7bb7f798934093b2bae33dc60

Example Data

No response

Additional Context

I reproduced the issue on Alpine containers on Docker for convenience, though I do not believe the issue is exclusive to either Alpine or Docker.

References

No response

@unflxw unflxw added the type: bug A code related bug. label Dec 30, 2024
@jorgehermo9
Copy link
Contributor

I think we must maintain backwards compatibility with postgres <17 when updating that source.

Maybe a new version configuration in the source?

Or using the select version() statement to query the postgres version at runtime and using the proper metrics sentences based on the current postgres version. I think this would be better for users.

@jszwedko jszwedko added the source: postgresql_metrics Anything `postgresql_metrics` source related label Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
source: postgresql_metrics Anything `postgresql_metrics` source related type: bug A code related bug.
Projects
None yet
Development

No branches or pull requests

3 participants