Skip to content

Commit

Permalink
tag user and pool mode in show POOLS result
Browse files Browse the repository at this point in the history
  • Loading branch information
nerzhul committed May 16, 2018
1 parent 469c0c2 commit 0c41e8d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugins/inputs/pgbouncer/pgbouncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type PgBouncer struct {
postgresql.Service
}

var ignoredColumns = map[string]bool{"user": true, "database": true}
var ignoredColumns = map[string]bool{"user": true, "database": true, "pool_mode": true}

var sampleConfig = `
## specify address via a url matching:
Expand Down Expand Up @@ -96,14 +96,17 @@ func (p *PgBouncer) Gather(acc telegraf.Accumulator) error {
return err
}

tags["user"] = (*columnMap["user"]).(string)
tags["pool_mode"] = (*columnMap["pool_mode"]).(string)

fields := make(map[string]interface{})
for col, val := range columnMap {
_, ignore := ignoredColumns[col]
if !ignore {
fields[col] = *val
}
}
acc.AddFields("pgbouncer", fields, tags)
acc.AddFields("pgbouncer_pools", fields, tags)
}

return poolRows.Err()
Expand Down

0 comments on commit 0c41e8d

Please sign in to comment.