3. MySQL Prometheus Exporter Setup
Prometheus must have implemented a MySQL Exporter in order to fetch the metrics from the MySQL systems.
3.1 Install MySQL Prometheus Exporter
3.1.1 Download the latest version of MySQL Exporter from their official repository:
... better use github endoipoints...
3.2 ... and untar for extracting files:
3.3 Move mysqld_exporter under /usr/local/bin, and make it executable:
3.2 Configure MySQL Prometheus Exporter
3.2.1 Create Exporter user to access databases
3.2.1 Create Exporter user to access databases
If you require details on how to login to OCI Mysql using mysql-shell, check tutorial"Access MySQL Instance"
We have deployed 3 MySQL systems with following private IPs: 10.0.0.28, 10.0.0.30, 10.0.0.32
We need to create an Exporter user on every MySQL data, and grant it permissions:
a) On MySQL system 10.0.0.28 (log into the system using mysqlsh)
b) On MySQL system 10.0.0.30 (log into the system using mysqlsh)
c) On MySQL system 10.0.0.32 (log into the system using mysqlsh)
3.2.2 Configure Exporter files on the host where Prometheus is installed
3.2.2 Configure Exporter files on the host where Prometheus is installedSince we have 3 hosts, each host needs its own configuration file for an Exporter service. (this seems to be a normal behavior for MySQL Exporter )
For the configuration files (/etc/.mysqld_exporter.cnf, for instance), you need to provide same MySQL user (along with its password) that you have provided at step 3.2.1. Also, the host is the private IP of the database:
Once you have created all three configuration files, change the ownership:
3.2.3. Configure Systemd for Exporter
3.2.3. Configure Systemd for ExporterAt this step, as you have guessed it, we need three different configuration files for Systemd. Pay attention to ports. The port for Exporter is 9104. Since we need 3 different Exporter services, we will provide three different ports in every mysql_exporter.service file: 9104, 9105, 9106
Systemd file that will use/etc/.mysqld_exporter.cnf && port 9104
Systemd file that will use/etc/.mysqld_exporter_1.cnf && port 9105
Systemd file that will use/etc/.mysqld_exporter_2.cnf && port 9106
3.3 Before loading and enabling Systemd Exporter
This has two parts - networking changes and Prometheus changes
3.3.1 Networking changes
3.3.1 Networking changesSince we are using new ports, we need to make a few changes:
3.3.1.1 In the Cloud
Add following ingress rules for ports 9104, 9105, respectively 9106:





... and the final result

3.3.1.2 On the host
Make sure you open the ports for listening:
3.3.1 Prometheus changes
3.3.1 Prometheus changesAdd the following changes for scrape_configs field in the /etc/prometheus/prometheus.yml file:
Load changes and restart prometheus service:
Now we are ready to start the three Exporter services
3.3 Start Exporter services and perform checking:
Check if MySQL Exporter is listening on the three ports:
Check in browser if mysql metric names are showing up in Prometheus:

Last updated