MySQL input: log and continue on field parse error (#2855)

This commit is contained in:
Matteo Cerutti 2017-05-26 20:09:43 +01:00 committed by Daniel Nelson
parent 5065a6e7f5
commit c8b7739237
1 changed files with 18 additions and 15 deletions

View File

@ -858,42 +858,45 @@ func (m *Mysql) gatherGlobalStatuses(db *sql.DB, serv string, acc telegraf.Accum
case "Queries": case "Queries":
i, err := strconv.ParseInt(string(val.([]byte)), 10, 64) i, err := strconv.ParseInt(string(val.([]byte)), 10, 64)
if err != nil { if err != nil {
return err acc.AddError(fmt.Errorf("E! Error mysql: parsing %s int value (%s)", name, err))
} else {
fields["queries"] = i
} }
fields["queries"] = i
case "Questions": case "Questions":
i, err := strconv.ParseInt(string(val.([]byte)), 10, 64) i, err := strconv.ParseInt(string(val.([]byte)), 10, 64)
if err != nil { if err != nil {
return err acc.AddError(fmt.Errorf("E! Error mysql: parsing %s int value (%s)", name, err))
} else {
fields["questions"] = i
} }
fields["questions"] = i
case "Slow_queries": case "Slow_queries":
i, err := strconv.ParseInt(string(val.([]byte)), 10, 64) i, err := strconv.ParseInt(string(val.([]byte)), 10, 64)
if err != nil { if err != nil {
return err acc.AddError(fmt.Errorf("E! Error mysql: parsing %s int value (%s)", name, err))
} else {
fields["slow_queries"] = i
} }
fields["slow_queries"] = i
case "Connections": case "Connections":
i, err := strconv.ParseInt(string(val.([]byte)), 10, 64) i, err := strconv.ParseInt(string(val.([]byte)), 10, 64)
if err != nil { if err != nil {
return err acc.AddError(fmt.Errorf("E! Error mysql: parsing %s int value (%s)", name, err))
} else {
fields["connections"] = i
} }
fields["connections"] = i
case "Syncs": case "Syncs":
i, err := strconv.ParseInt(string(val.([]byte)), 10, 64) i, err := strconv.ParseInt(string(val.([]byte)), 10, 64)
if err != nil { if err != nil {
return err acc.AddError(fmt.Errorf("E! Error mysql: parsing %s int value (%s)", name, err))
} else {
fields["syncs"] = i
} }
fields["syncs"] = i
case "Uptime": case "Uptime":
i, err := strconv.ParseInt(string(val.([]byte)), 10, 64) i, err := strconv.ParseInt(string(val.([]byte)), 10, 64)
if err != nil { if err != nil {
return err acc.AddError(fmt.Errorf("E! Error mysql: parsing %s int value (%s)", name, err))
} else {
fields["uptime"] = i
} }
fields["uptime"] = i
} }
} }
// Send any remaining fields // Send any remaining fields