Add option to control collecting global variables to mysql input (#6790)

This commit is contained in:
Ben Hymans 2019-12-11 13:42:54 -06:00 committed by Daniel Nelson
parent 98585a1853
commit 4def7cc5e1
2 changed files with 18 additions and 7 deletions

View File

@ -69,6 +69,9 @@ This plugin gathers the statistic data from MySQL server
## gather metrics from SHOW BINARY LOGS command output
# gather_binary_logs = false
## gather metrics from SHOW GLOBAL VARIABLES command output
# gather_global_variables = true
## gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE
# gather_table_io_waits = false

View File

@ -36,6 +36,7 @@ type Mysql struct {
GatherTableSchema bool `toml:"gather_table_schema"`
GatherFileEventsStats bool `toml:"gather_file_events_stats"`
GatherPerfEventsStatements bool `toml:"gather_perf_events_statements"`
GatherGlobalVars bool `toml:"gather_global_variables"`
IntervalSlow string `toml:"interval_slow"`
MetricVersion int `toml:"metric_version"`
@ -94,6 +95,9 @@ const sampleConfig = `
## gather metrics from SHOW BINARY LOGS command output
# gather_binary_logs = false
## gather metrics from PERFORMANCE_SCHEMA.GLOBAL_VARIABLES
# gather_global_variables = true
## gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE
# gather_table_io_waits = false
@ -134,6 +138,7 @@ const (
defaultPerfEventsStatementsDigestTextLimit = 120
defaultPerfEventsStatementsLimit = 250
defaultPerfEventsStatementsTimeLimit = 86400
defaultGatherGlobalVars = true
)
func (m *Mysql) SampleConfig() string {
@ -431,6 +436,7 @@ func (m *Mysql) gatherServer(serv string, acc telegraf.Accumulator) error {
return err
}
if m.GatherGlobalVars {
// Global Variables may be gathered less often
if len(m.IntervalSlow) > 0 {
if uint32(time.Since(m.lastT).Seconds()) >= m.scanIntervalSlow {
@ -441,6 +447,7 @@ func (m *Mysql) gatherServer(serv string, acc telegraf.Accumulator) error {
m.lastT = time.Now()
}
}
}
if m.GatherBinaryLogs {
err = m.gatherBinaryLogs(db, serv, acc)
@ -1767,6 +1774,7 @@ func init() {
PerfEventsStatementsDigestTextLimit: defaultPerfEventsStatementsDigestTextLimit,
PerfEventsStatementsLimit: defaultPerfEventsStatementsLimit,
PerfEventsStatementsTimeLimit: defaultPerfEventsStatementsTimeLimit,
GatherGlobalVars: defaultGatherGlobalVars,
}
})
}