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

Create PostgreSQL metrics dynamically for older version compatibility #192

Closed
wants to merge 9 commits into from

Conversation

bmxpert1
Copy link
Contributor

The current postgresql plugin only works with postgres versions 9.2+ due to lack of some columns in versions older than that. This PR fixes that by dynamically creating metrics based on the columns returned from the pg_stat_database table.

@bmxpert1
Copy link
Contributor Author

For reference these are the columns returned from pg_stat_database, by postgres version:

pg version      9.2+   9.1   8.3-9.0   8.1-8.2   7.4-8.0
---             ---    ---   -------   -------   -------
datid            x      x       x         x         
datname          x      x       x         x  
numbackends      x      x       x         x         x
xact_commit      x      x       x         x         x
xact_rollback    x      x       x         x         x
blks_read        x      x       x         x         x
blks_hit         x      x       x         x         x
tup_returned     x      x       x
tup_fetched      x      x       x
tup_inserted     x      x       x
tup_updated      x      x       x
tup_deleted      x      x       x
conflicts        x      x
temp_files       x      
temp_bytes       x      
deadlocks        x      
blk_read_time    x      
blk_write_time   x      
stats_reset      x      x

Actually looking at this now I don't think this plugin will be able to fully support anything <= 8.0 because of the lack of datname column. Could work around that but I'm guessing this is more of a non issue.

@sparrc
Copy link
Contributor

sparrc commented Sep 14, 2015

@bmxpert1 Great! thank you for the contribution, could you put a link to this PR in the CHANGELOG and also put the above version compatability graph in a README file in the postgresql directory?

thanks!

@bmxpert1
Copy link
Contributor Author

No problem, I'm loving telegraf.

Thank you!

@sparrc sparrc closed this in aac9ba6 Sep 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants