Fix pgbouncer input when used with newer pgbouncer versions (#6820)

This commit is contained in:
Mark Fletcher
2020-02-12 20:53:11 -08:00
committed by GitHub
parent e3bc546a46
commit 6c839a33a4
2 changed files with 15 additions and 1 deletions

View File

@@ -2,6 +2,7 @@ package pgbouncer
import (
"bytes"
"strconv"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal"
@@ -70,12 +71,18 @@ func (p *PgBouncer) Gather(acc telegraf.Accumulator) error {
for col, val := range columnMap {
_, ignore := ignoredColumns[col]
if !ignore {
fields[col] = *val
// these values are returned by pgbouncer as strings, which we need to convert.
fields[col], _ = strconv.ParseUint((*val).(string), 10, 64)
}
}
acc.AddFields("pgbouncer", fields, tags)
}
err = rows.Err()
if err != nil {
return err
}
query = `SHOW POOLS`
poolRows, err := p.DB.Query(query)