[postgres] Made BGW_METRICS version dependent #1272
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We are using Postgres 9.1.9 and I see a lot of errors in collector,log like this:
2014-12-22 18:33:47 UTC | WARNING | dd.collector | checks.postgres(postgres.py:277) | Not all metrics may be available: ('ERROR', '42703', 'column "checkpoint_write_time" does not exist')
The problem is that postgres 9.2 columns of a pg_stat_bgwriter view are hardcoded in postgres.py
The columns checkpoint_write_time, checkpoint_sync_time, buffers_backend_fsync are missing in version 9.1
After a BGW_METRICS query failed, all the following queries fail, too.
The proposed fix makes the BGW_METRICS Postgres version aware. This may not be the most elegant solution, but I tried to make as fewer changes as possible, and do everything in the spirit of the existing code.
After I applied this fix, I have BGW_METRICS working, and the queries following BGW_METRICS are working too.