Skip to content

Commit 732c372

Browse files
danielnelsonidohalevi
authored andcommitted
Show default settings in mysql sample config (influxdata#6484)
1 parent 1f42aa8 commit 732c372

File tree

2 files changed

+104
-79
lines changed

2 files changed

+104
-79
lines changed

plugins/inputs/mysql/README.md

Lines changed: 57 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,71 +21,87 @@ This plugin gathers the statistic data from MySQL server
2121
### Configuration
2222

2323
```toml
24-
# Read metrics from one or many mysql servers
2524
[[inputs.mysql]]
2625
## specify servers via a url matching:
27-
## [username[:password]@][protocol[(address)]]/[?tls=[true|false|skip-verify]]
26+
## [username[:password]@][protocol[(address)]]/[?tls=[true|false|skip-verify|custom]]
2827
## see https://github.com/go-sql-driver/mysql#dsn-data-source-name
2928
## e.g.
3029
## servers = ["user:passwd@tcp(127.0.0.1:3306)/?tls=false"]
3130
## servers = ["user@tcp(127.0.0.1:3306)/?tls=false"]
3231
#
3332
## If no servers are specified, then localhost is used as the host.
3433
servers = ["tcp(127.0.0.1:3306)/"]
35-
## the limits for metrics form perf_events_statements
36-
perf_events_statements_digest_text_limit = 120
37-
perf_events_statements_limit = 250
38-
perf_events_statements_time_limit = 86400
39-
#
40-
## if the list is empty, then metrics are gathered from all database tables
41-
table_schema_databases = []
42-
#
34+
35+
## Selects the metric output format.
36+
##
37+
## This option exists to maintain backwards compatibility, if you have
38+
## existing metrics do not set or change this value until you are ready to
39+
## migrate to the new format.
40+
##
41+
## If you do not have existing metrics from this plugin set to the latest
42+
## version.
43+
##
44+
## Telegraf >=1.6: metric_version = 2
45+
## <1.6: metric_version = 1 (or unset)
46+
metric_version = 2
47+
48+
## if the list is empty, then metrics are gathered from all databasee tables
49+
# table_schema_databases = []
50+
4351
## gather metrics from INFORMATION_SCHEMA.TABLES for databases provided above list
44-
gather_table_schema = false
45-
#
52+
# gather_table_schema = false
53+
4654
## gather thread state counts from INFORMATION_SCHEMA.PROCESSLIST
47-
gather_process_list = true
48-
#
49-
## gather thread state counts from INFORMATION_SCHEMA.USER_STATISTICS
50-
gather_user_statistics = true
51-
#
55+
# gather_process_list = false
56+
57+
## gather user statistics from INFORMATION_SCHEMA.USER_STATISTICS
58+
# gather_user_statistics = false
59+
5260
## gather auto_increment columns and max values from information schema
53-
gather_info_schema_auto_inc = true
54-
#
61+
# gather_info_schema_auto_inc = false
62+
5563
## gather metrics from INFORMATION_SCHEMA.INNODB_METRICS
56-
gather_innodb_metrics = true
57-
#
64+
# gather_innodb_metrics = false
65+
5866
## gather metrics from SHOW SLAVE STATUS command output
59-
gather_slave_status = true
60-
#
67+
# gather_slave_status = false
68+
6169
## gather metrics from SHOW BINARY LOGS command output
62-
gather_binary_logs = false
63-
#
70+
# gather_binary_logs = false
71+
6472
## gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE
65-
gather_table_io_waits = false
66-
#
73+
# gather_table_io_waits = false
74+
6775
## gather metrics from PERFORMANCE_SCHEMA.TABLE_LOCK_WAITS
68-
gather_table_lock_waits = false
69-
#
76+
# gather_table_lock_waits = false
77+
7078
## gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_INDEX_USAGE
71-
gather_index_io_waits = false
72-
#
79+
# gather_index_io_waits = false
80+
7381
## gather metrics from PERFORMANCE_SCHEMA.EVENT_WAITS
74-
gather_event_waits = false
75-
#
82+
# gather_event_waits = false
83+
7684
## gather metrics from PERFORMANCE_SCHEMA.FILE_SUMMARY_BY_EVENT_NAME
77-
gather_file_events_stats = false
78-
#
85+
# gather_file_events_stats = false
86+
7987
## gather metrics from PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_SUMMARY_BY_DIGEST
80-
gather_perf_events_statements = false
81-
#
88+
# gather_perf_events_statements = false
89+
90+
## the limits for metrics form perf_events_statements
91+
# perf_events_statements_digest_text_limit = 120
92+
# perf_events_statements_limit = 250
93+
# perf_events_statements_time_limit = 86400
94+
8295
## Some queries we may want to run less often (such as SHOW GLOBAL VARIABLES)
83-
interval_slow = "30m"
96+
## example: interval_slow = "30m"
97+
# interval_slow = ""
8498

8599
## Optional TLS Config (will be used if tls=custom parameter specified in server uri)
86-
tls_ca = "/etc/telegraf/ca.pem"
87-
tls_cert = "/etc/telegraf/cert.pem"
88-
tls_key = "/etc/telegraf/key.pem"
100+
# tls_ca = "/etc/telegraf/ca.pem"
101+
# tls_cert = "/etc/telegraf/cert.pem"
102+
# tls_key = "/etc/telegraf/key.pem"
103+
## Use TLS but skip chain & host verification
104+
# insecure_skip_verify = false
89105
```
90106

91107
#### Metric Version

plugins/inputs/mysql/mysql.go

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ import (
99
"sync"
1010
"time"
1111

12+
"github.com/go-sql-driver/mysql"
1213
"github.com/influxdata/telegraf"
1314
"github.com/influxdata/telegraf/internal/tls"
1415
"github.com/influxdata/telegraf/plugins/inputs"
1516
"github.com/influxdata/telegraf/plugins/inputs/mysql/v1"
16-
17-
"github.com/go-sql-driver/mysql"
1817
)
1918

2019
type Mysql struct {
@@ -68,55 +67,56 @@ const sampleConfig = `
6867
## <1.6: metric_version = 1 (or unset)
6968
metric_version = 2
7069
71-
## the limits for metrics form perf_events_statements
72-
perf_events_statements_digest_text_limit = 120
73-
perf_events_statements_limit = 250
74-
perf_events_statements_time_limit = 86400
75-
#
7670
## if the list is empty, then metrics are gathered from all databasee tables
77-
table_schema_databases = []
78-
#
71+
# table_schema_databases = []
72+
7973
## gather metrics from INFORMATION_SCHEMA.TABLES for databases provided above list
80-
gather_table_schema = false
81-
#
74+
# gather_table_schema = false
75+
8276
## gather thread state counts from INFORMATION_SCHEMA.PROCESSLIST
83-
gather_process_list = true
84-
#
77+
# gather_process_list = false
78+
8579
## gather user statistics from INFORMATION_SCHEMA.USER_STATISTICS
86-
gather_user_statistics = true
87-
#
80+
# gather_user_statistics = false
81+
8882
## gather auto_increment columns and max values from information schema
89-
gather_info_schema_auto_inc = true
90-
#
83+
# gather_info_schema_auto_inc = false
84+
9185
## gather metrics from INFORMATION_SCHEMA.INNODB_METRICS
92-
gather_innodb_metrics = true
93-
#
86+
# gather_innodb_metrics = false
87+
9488
## gather metrics from SHOW SLAVE STATUS command output
95-
gather_slave_status = true
96-
#
89+
# gather_slave_status = false
90+
9791
## gather metrics from SHOW BINARY LOGS command output
98-
gather_binary_logs = false
99-
#
92+
# gather_binary_logs = false
93+
10094
## gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE
101-
gather_table_io_waits = false
102-
#
95+
# gather_table_io_waits = false
96+
10397
## gather metrics from PERFORMANCE_SCHEMA.TABLE_LOCK_WAITS
104-
gather_table_lock_waits = false
105-
#
98+
# gather_table_lock_waits = false
99+
106100
## gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_INDEX_USAGE
107-
gather_index_io_waits = false
108-
#
101+
# gather_index_io_waits = false
102+
109103
## gather metrics from PERFORMANCE_SCHEMA.EVENT_WAITS
110-
gather_event_waits = false
111-
#
104+
# gather_event_waits = false
105+
112106
## gather metrics from PERFORMANCE_SCHEMA.FILE_SUMMARY_BY_EVENT_NAME
113-
gather_file_events_stats = false
114-
#
107+
# gather_file_events_stats = false
108+
115109
## gather metrics from PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_SUMMARY_BY_DIGEST
116-
gather_perf_events_statements = false
117-
#
110+
# gather_perf_events_statements = false
111+
112+
## the limits for metrics form perf_events_statements
113+
# perf_events_statements_digest_text_limit = 120
114+
# perf_events_statements_limit = 250
115+
# perf_events_statements_time_limit = 86400
116+
118117
## Some queries we may want to run less often (such as SHOW GLOBAL VARIABLES)
119-
interval_slow = "30m"
118+
## example: interval_slow = "30m"
119+
# interval_slow = ""
120120
121121
## Optional TLS Config (will be used if tls=custom parameter specified in server uri)
122122
# tls_ca = "/etc/telegraf/ca.pem"
@@ -126,7 +126,12 @@ const sampleConfig = `
126126
# insecure_skip_verify = false
127127
`
128128

129-
const defaultTimeout = time.Second * time.Duration(5)
129+
const (
130+
defaultTimeout = 5 * time.Second
131+
defaultPerfEventsStatementsDigestTextLimit = 120
132+
defaultPerfEventsStatementsLimit = 250
133+
defaultPerfEventsStatementsTimeLimit = 86400
134+
)
130135

131136
func (m *Mysql) SampleConfig() string {
132137
return sampleConfig
@@ -1734,6 +1739,10 @@ func getDSNTag(dsn string) string {
17341739

17351740
func init() {
17361741
inputs.Add("mysql", func() telegraf.Input {
1737-
return &Mysql{}
1742+
return &Mysql{
1743+
PerfEventsStatementsDigestTextLimit: defaultPerfEventsStatementsDigestTextLimit,
1744+
PerfEventsStatementsLimit: defaultPerfEventsStatementsLimit,
1745+
PerfEventsStatementsTimeLimit: defaultPerfEventsStatementsTimeLimit,
1746+
}
17381747
})
17391748
}

0 commit comments

Comments
 (0)