From 8ead219308e37437600ae45db29dd80ceac88c2d Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Wed, 16 May 2018 14:21:48 +0200 Subject: [PATCH] First part of review fixes --- plugins/inputs/pgbouncer/README.md | 5 ++++- plugins/inputs/pgbouncer/pgbouncer.go | 17 ++++------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/plugins/inputs/pgbouncer/README.md b/plugins/inputs/pgbouncer/README.md index 9e95cd5d4026f..2a841c45aada0 100644 --- a/plugins/inputs/pgbouncer/README.md +++ b/plugins/inputs/pgbouncer/README.md @@ -9,7 +9,10 @@ Specify address via a url matching: `postgres://[pqgotest[:password]]@localhost[/dbname]?sslmode=[disable|verify-ca|verify-full]` -All connection parameters are optional. Without the dbname parameter, the driver will default to a database with the same name as the user. This dbname is just for instantiating a connection with the server and doesn't restrict the databases we are trying to grab metrics for. +All connection parameters are optional. + +Without the dbname parameter, the driver will default to a database with the same name as the user. +This dbname is just for instantiating a connection with the server and doesn't restrict the databases we are trying to grab metrics for. ### Configuration example ``` diff --git a/plugins/inputs/pgbouncer/pgbouncer.go b/plugins/inputs/pgbouncer/pgbouncer.go index 8d97639f636c2..e679cba5af0b2 100644 --- a/plugins/inputs/pgbouncer/pgbouncer.go +++ b/plugins/inputs/pgbouncer/pgbouncer.go @@ -27,11 +27,6 @@ var sampleConfig = ` ## ## All connection parameters are optional. ## - ## Without the dbname parameter, the driver will default to a database - ## with the same name as the user. This dbname is just for instantiating a - ## connection with the server and doesn't restrict the databases we are trying - ## to grab metrics for. - ## address = "host=localhost user=pgbouncer sslmode=disable" ` @@ -43,10 +38,6 @@ func (p *PgBouncer) Description() string { return "Read metrics from one or many pgbouncer servers" } -func (p *PgBouncer) IgnoredColumns() map[string]bool { - return ignoredColumns -} - func (p *PgBouncer) Gather(acc telegraf.Accumulator) error { var ( err error @@ -69,7 +60,7 @@ func (p *PgBouncer) Gather(acc telegraf.Accumulator) error { } for rows.Next() { - err = p.accRow(rows, acc, columns) + err = p.accRow("pgbouncer", rows, acc, columns) if err != nil { return err } @@ -90,7 +81,7 @@ func (p *PgBouncer) Gather(acc telegraf.Accumulator) error { } for poolRows.Next() { - err = p.accRow(poolRows, acc, columns) + err = p.accRow("pgbouncer_pools", poolRows, acc, columns) if err != nil { return err } @@ -103,7 +94,7 @@ type scanner interface { Scan(dest ...interface{}) error } -func (p *PgBouncer) accRow(row scanner, acc telegraf.Accumulator, columns []string) error { +func (p *PgBouncer) accRow(measurement string, row scanner, acc telegraf.Accumulator, columns []string) error { var columnVars []interface{} var dbname bytes.Buffer @@ -147,7 +138,7 @@ func (p *PgBouncer) accRow(row scanner, acc telegraf.Accumulator, columns []stri fields[col] = *val } } - acc.AddFields("pgbouncer", fields, tags) + acc.AddFields(measurement, fields, tags) return nil }