Add option to control collecting global variables to mysql input (#6790)
This commit is contained in:
parent
98585a1853
commit
4def7cc5e1
|
@ -69,6 +69,9 @@ This plugin gathers the statistic data from MySQL server
|
||||||
## gather metrics from SHOW BINARY LOGS command output
|
## gather metrics from SHOW BINARY LOGS command output
|
||||||
# gather_binary_logs = false
|
# 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 metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE
|
||||||
# gather_table_io_waits = false
|
# gather_table_io_waits = false
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ type Mysql struct {
|
||||||
GatherTableSchema bool `toml:"gather_table_schema"`
|
GatherTableSchema bool `toml:"gather_table_schema"`
|
||||||
GatherFileEventsStats bool `toml:"gather_file_events_stats"`
|
GatherFileEventsStats bool `toml:"gather_file_events_stats"`
|
||||||
GatherPerfEventsStatements bool `toml:"gather_perf_events_statements"`
|
GatherPerfEventsStatements bool `toml:"gather_perf_events_statements"`
|
||||||
|
GatherGlobalVars bool `toml:"gather_global_variables"`
|
||||||
IntervalSlow string `toml:"interval_slow"`
|
IntervalSlow string `toml:"interval_slow"`
|
||||||
MetricVersion int `toml:"metric_version"`
|
MetricVersion int `toml:"metric_version"`
|
||||||
|
|
||||||
|
@ -94,6 +95,9 @@ const sampleConfig = `
|
||||||
## gather metrics from SHOW BINARY LOGS command output
|
## gather metrics from SHOW BINARY LOGS command output
|
||||||
# gather_binary_logs = false
|
# 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 metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE
|
||||||
# gather_table_io_waits = false
|
# gather_table_io_waits = false
|
||||||
|
|
||||||
|
@ -134,6 +138,7 @@ const (
|
||||||
defaultPerfEventsStatementsDigestTextLimit = 120
|
defaultPerfEventsStatementsDigestTextLimit = 120
|
||||||
defaultPerfEventsStatementsLimit = 250
|
defaultPerfEventsStatementsLimit = 250
|
||||||
defaultPerfEventsStatementsTimeLimit = 86400
|
defaultPerfEventsStatementsTimeLimit = 86400
|
||||||
|
defaultGatherGlobalVars = true
|
||||||
)
|
)
|
||||||
|
|
||||||
func (m *Mysql) SampleConfig() string {
|
func (m *Mysql) SampleConfig() string {
|
||||||
|
@ -431,14 +436,16 @@ func (m *Mysql) gatherServer(serv string, acc telegraf.Accumulator) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global Variables may be gathered less often
|
if m.GatherGlobalVars {
|
||||||
if len(m.IntervalSlow) > 0 {
|
// Global Variables may be gathered less often
|
||||||
if uint32(time.Since(m.lastT).Seconds()) >= m.scanIntervalSlow {
|
if len(m.IntervalSlow) > 0 {
|
||||||
err = m.gatherGlobalVariables(db, serv, acc)
|
if uint32(time.Since(m.lastT).Seconds()) >= m.scanIntervalSlow {
|
||||||
if err != nil {
|
err = m.gatherGlobalVariables(db, serv, acc)
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
m.lastT = time.Now()
|
||||||
}
|
}
|
||||||
m.lastT = time.Now()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1767,6 +1774,7 @@ func init() {
|
||||||
PerfEventsStatementsDigestTextLimit: defaultPerfEventsStatementsDigestTextLimit,
|
PerfEventsStatementsDigestTextLimit: defaultPerfEventsStatementsDigestTextLimit,
|
||||||
PerfEventsStatementsLimit: defaultPerfEventsStatementsLimit,
|
PerfEventsStatementsLimit: defaultPerfEventsStatementsLimit,
|
||||||
PerfEventsStatementsTimeLimit: defaultPerfEventsStatementsTimeLimit,
|
PerfEventsStatementsTimeLimit: defaultPerfEventsStatementsTimeLimit,
|
||||||
|
GatherGlobalVars: defaultGatherGlobalVars,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue