Bug #113196 MySQL Operator - Metrics provider doesn't take command line arguments
Description:
Greetings,
It looks like there is an issue or bug with the metrics provider. According to the documentation (https://dev.mysql.com/doc/mysql-operator/en/mysql-operator-properties.html#mysql-operator-...), we should be able to pass the exporter command-line arguments as options (InnoDBCluster.spec.metrics.options). I attempted this with the prom/mysqld_exporter image, including the required command-line arguments as options, the metrics: section form the manifest is furnished below.
metrics:
enable: true
image: prom/mysqld-exporter
monitor: true
monitorSpec:
labels:
release: prometheus-operator
options:
- --mysqld.address=localhost:3306
- --mysqld.username=metrics
However, it just ignores the operations, resulting in the metrics sidecar crash-looping with the below messages.
ts=2023-11-23T10:07:05.058Z caller=config.go:150 level=error msg="failed to validate config" section=client err="no user specified in section or parent"
ts=2023-11-23T10:07:05.058Z caller=mysqld_exporter.go:225 level=info msg="Error parsing host config" file=.my.cnf err="no configuration found"
It is because the command line arguments specified in the options: are not being recognized by the sidecar pod, resulting in the sidecar just running the mysql-process as shown below.
k run test --image prom/mysqld-exporter --command sleep infinity
pod/test created
k exec test -- mysqld_exporter
ts=2023-11-23T11:34:22.610Z caller=config.go:150 level=error msg="failed to validate config" section=client err="no user specified in section or parent"
ts=2023-11-23T11:34:22.610Z caller=mysqld_exporter.go:225 level=info msg="Error parsing host config" file=.my.cnf err="no configuration found"
The labels specified in the monitorSpec are also being ignored, resulting in the creation of a ServiceMonitor object without the mentioned labels.
monitorSpec:
labels:
release: prometheus-operator
How to repeat:
Enable metrics with the following parameters on an InnoDB cluster resource.
metrics:
enable: true
image: prom/mysqld-exporter
monitor: true
monitorSpec:
labels:
release: prometheus-operator
options:
- --mysqld.address=localhost:3306
- --mysqld.username=metrics
Once applied, the InnoDB pods will enter a crash loop due to issues with the metrics sidecar container. The metrics sidecar will display the following logs:
ts=2023-11-23T10:07:05.058Z caller=config.go:150 level=error msg="failed to validate config" section=client err="no user specified in section or parent"
ts=2023-11-23T10:07:05.058Z caller=mysqld_exporter.go:225 level=info msg="Error parsing host config" file=.my.cnf err="no configuration found"
Suggested fix:
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.042 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.