Open JohnnyMarnell opened 5 years ago
Here's how I use it, by the way:
pgmetrics -wfjson | node pgmetrics.js | nc $GRAPHITE_HOST $GRAPHITE_PORT
And this is a snippet example of the translated graphite line protocol metrics being translated from pgmetrics json via this script, and fed to graphite server via netcat:
pgmetrics.start_time 1556036264 1556041852
pgmetrics.checkpoint_time 1556036564 1556041852
pgmetrics.databases.postgres.datdba 10 1556041852
pgmetrics.databases.postgres.dattablespace 1663 1556041852
pgmetrics.databases.postgres.datconnlimit -1 1556041852
pgmetrics.databases.postgres.tup_returned 19048457 1556041852
pgmetrics.databases.postgres.tup_fetched 186900 1556041852
pgmetrics.databases.postgres.tup_inserted 1392 1556041852
pgmetrics.databases.postgres.tup_updated 200 1556041852
pgmetrics.databases.postgres.tup_deleted 2 1556041852
pgmetrics.wal_archiving.archived_count 0 1556041852
pgmetrics.wal_archiving.last_archived_time 0 1556041852
pgmetrics.wal_archiving.failed_count 0 1556041852
pgmetrics.tables.__DATABASE_NAME__.public.root.__TABLE_NAME__.heap_blks_hit 0 1556041852
pgmetrics.tables.__DATABASE_NAME__.public.root.__TABLE_NAME__.idx_blks_read 0 1556041852
pgmetrics.tables.__DATABASE_NAME__.public.root.__TABLE_NAME__.idx_blks_hit 0 1556041852
pgmetrics.tables.__DATABASE_NAME__.public.root.__TABLE_NAME__.toast_blks_read 0 1556041852
pgmetrics.tables.__DATABASE_NAME__.public.root.__TABLE_NAME__.toast_blks_hit 0 1556041852
pgmetrics.tables.__DATABASE_NAME__.public.root.__TABLE_NAME__.tidx_blks_read 0 1556041852
Yes, a PR for native graphite support is welcome!
I suggest starting off by copying cmd/pgmetrics/csv.go
to cmd/pgmetrics/graphite.go
, and esstentially port your JS code to a top-level function:
func model2graphite(m *pgmetrics.Model, w io.Writer) (err error) {
// ...
}
similar to the existing model2csv
function. Then modify main.go
, add an option for graphite
wherever you find a csv
.
Hey there, love the details with these metrics!
I wrote a NodeJS script to flatten / convert json output into a graphite line protocol ready format here: https://gist.github.com/JohnnyMarnell/0ab7e95e2994b7960fe7a32667a529df
If I were to start porting it to Go (n00b), would you consider a pull request?
Something like
pgmetrics -f graphite
?