Skip to content

Commit e9cf734

Browse files
committed
Enable the mysqld_exporter without any required user changes
Signed-off-by: Matt Lord <mattalord@gmail.com>
1 parent 91c619f commit e9cf734

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

pkg/operator/vttablet/constants.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const (
3232

3333
mysqldExporterContainerName = "mysqld-exporter"
3434
mysqldExporterCommand = "/bin/mysqld_exporter"
35+
mysqldExporterMySQLCnf = "client.cnf"
3536
mysqldExporterUser = "vt_dba"
3637
mysqldExporterPort = 9104
3738
mysqldExporterPortName = "metrics"

pkg/operator/vttablet/mysqlctld.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ ln -sf /dev/stderr /mnt/vt/config/stderr.symlink
4040
echo "log-error = /vt/config/stderr.symlink" > /mnt/vt/config/mycnf/log-error.cnf
4141
echo "binlog_format=row" > /mnt/vt/config/mycnf/rbr.cnf
4242
echo "socket = ` + mysqlSocketPath + `" > /mnt/vt/config/mycnf/socket.cnf
43+
echo -n "[client]\nuser=` + mysqldExporterUser + `\nsocket=` + mysqlSocketPath + `\n" > /mnt/vt/config/mycnf/` + mysqldExporterMySQLCnf + `
4344
`
4445

4546
mysqlSocketInitScript = `set -ex

pkg/operator/vttablet/pod.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package vttablet
1818

1919
import (
20+
"path/filepath"
2021
"strconv"
2122
"strings"
2223

@@ -210,6 +211,9 @@ func UpdatePod(obj *corev1.Pod, spec *Spec) {
210211
key = strings.TrimLeft(key, "-")
211212
mysqldExporterAllFlags[key] = value
212213
}
214+
if _, ok := mysqldExporterAllFlags["config.my-cnf"]; !ok {
215+
mysqldExporterAllFlags["config.my-cnf"] = filepath.Join(vtMycnfPath, mysqldExporterMySQLCnf)
216+
}
213217
}
214218

215219
// TODO: Can/should we still run mysqld_exporter pointing at external mysql?

0 commit comments

Comments
 (0)