@@ -36,6 +36,7 @@ type Mysql struct {
36
36
GatherTableSchema bool `toml:"gather_table_schema"`
37
37
GatherFileEventsStats bool `toml:"gather_file_events_stats"`
38
38
GatherPerfEventsStatements bool `toml:"gather_perf_events_statements"`
39
+ GatherGlobalVars bool `toml:"gather_global_variables"`
39
40
IntervalSlow string `toml:"interval_slow"`
40
41
MetricVersion int `toml:"metric_version"`
41
42
@@ -94,6 +95,9 @@ const sampleConfig = `
94
95
## gather metrics from SHOW BINARY LOGS command output
95
96
# gather_binary_logs = false
96
97
98
+ ## gather metrics from PERFORMANCE_SCHEMA.GLOBAL_VARIABLES
99
+ # gather_global_variables = true
100
+
97
101
## gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE
98
102
# gather_table_io_waits = false
99
103
@@ -134,6 +138,7 @@ const (
134
138
defaultPerfEventsStatementsDigestTextLimit = 120
135
139
defaultPerfEventsStatementsLimit = 250
136
140
defaultPerfEventsStatementsTimeLimit = 86400
141
+ defaultGatherGlobalVars = true
137
142
)
138
143
139
144
func (m * Mysql ) SampleConfig () string {
@@ -431,14 +436,16 @@ func (m *Mysql) gatherServer(serv string, acc telegraf.Accumulator) error {
431
436
return err
432
437
}
433
438
434
- // Global Variables may be gathered less often
435
- if len (m .IntervalSlow ) > 0 {
436
- if uint32 (time .Since (m .lastT ).Seconds ()) >= m .scanIntervalSlow {
437
- err = m .gatherGlobalVariables (db , serv , acc )
438
- if err != nil {
439
- return err
439
+ if m .GatherGlobalVars {
440
+ // Global Variables may be gathered less often
441
+ if len (m .IntervalSlow ) > 0 {
442
+ if uint32 (time .Since (m .lastT ).Seconds ()) >= m .scanIntervalSlow {
443
+ err = m .gatherGlobalVariables (db , serv , acc )
444
+ if err != nil {
445
+ return err
446
+ }
447
+ m .lastT = time .Now ()
440
448
}
441
- m .lastT = time .Now ()
442
449
}
443
450
}
444
451
@@ -1767,6 +1774,7 @@ func init() {
1767
1774
PerfEventsStatementsDigestTextLimit : defaultPerfEventsStatementsDigestTextLimit ,
1768
1775
PerfEventsStatementsLimit : defaultPerfEventsStatementsLimit ,
1769
1776
PerfEventsStatementsTimeLimit : defaultPerfEventsStatementsTimeLimit ,
1777
+ GatherGlobalVars : defaultGatherGlobalVars ,
1770
1778
}
1771
1779
})
1772
1780
}
0 commit comments