You've already forked mysqld_exporter
mirror of
https://github.com/prometheus/mysqld_exporter.git
synced 2025-07-31 17:44:21 +03:00
Add MySQL TLS configurations (#718)
This PR is a modified version of the #674 to match the FormDSN supported by the #708. Fixes: https://github.com/prometheus/mysqld_exporter/issues/673 Signed-off-by: Nico Braun <rainbowstack@gmail.com> Signed-off-by: Yasushi MIYAZAKI <MIYAZAKI.Yasushi@gmail.com> Co-authored-by: Nico Braun <rainbowstack@gmail.com>
This commit is contained in:
@ -70,6 +70,7 @@ type MySqlConfig struct {
|
||||
SslCert string `ini:"ssl-cert"`
|
||||
SslKey string `ini:"ssl-key"`
|
||||
TlsInsecureSkipVerify bool `ini:"ssl-skip-verfication"`
|
||||
Tls string `ini:"tls"`
|
||||
}
|
||||
|
||||
type MySqlConfigHandler struct {
|
||||
@ -132,6 +133,8 @@ func (ch *MySqlConfigHandler) ReloadConfig(filename string, mysqldAddress string
|
||||
mysqlcfg := &MySqlConfig{
|
||||
TlsInsecureSkipVerify: tlsInsecureSkipVerify,
|
||||
}
|
||||
|
||||
// FIXME: this error check seems orphaned
|
||||
if err != nil {
|
||||
level.Error(logger).Log("msg", "failed to load config", "section", sectionName, "err", err)
|
||||
continue
|
||||
@ -197,12 +200,17 @@ func (m MySqlConfig) FormDSN(target string) (string, error) {
|
||||
config.Addr = target
|
||||
}
|
||||
|
||||
if m.SslCa != "" {
|
||||
if err := m.CustomizeTLS(); err != nil {
|
||||
err = fmt.Errorf("failed to register a custom TLS configuration for mysql dsn: %w", err)
|
||||
return "", err
|
||||
if m.TlsInsecureSkipVerify {
|
||||
config.TLSConfig = "skip-verify"
|
||||
} else {
|
||||
config.TLSConfig = m.Tls
|
||||
if m.SslCa != "" {
|
||||
if err := m.CustomizeTLS(); err != nil {
|
||||
err = fmt.Errorf("failed to register a custom TLS configuration for mysql dsn: %w", err)
|
||||
return "", err
|
||||
}
|
||||
config.TLSConfig = "custom"
|
||||
}
|
||||
config.TLSConfig = "custom"
|
||||
}
|
||||
|
||||
return config.FormatDSN(), nil
|
||||
|
Reference in New Issue
Block a user