Skip to main content
⏳ Estimated read time: 2 min read

MySQL

StackGen's [Kubernetes agent](../../Collecting Telemetry/Install the OpsVerse Agent) can be used to collect metrics from MySQL DBs.

You can also install the [RDS exporter](Amazon RDS) on a single machine if you're running MySQL DB on RDS.

Kubernetes

Add the following YAML snippet to the agent's values.yaml and run the agent based on these [instructions](../../Collecting Telemetry/Install the OpsVerse Agent#VEqXM).

mysql-exporter:
enabled: true

# # Set a name for this DB. Will be used in dashboards and annotations
podLabels:
db-name: "your-db-name"

# # Not recommended for production usage
# # For production, define a secret with the DATA_SOURCE_URL as the key
# # See the example provided in the file
mysql:
host: <connection url>
pass: <password>
user: <username>

# For production
# existingSecret: mysql-secret-name

# The secret should be of this format
# Key: DATA_SOURCE_URL
# Value: Base64 encoded value of username:password@(mysql host:post)/

# apiVersion: v1
# data:
# DATA_SOURCE_NAME: <base64 encoded string>
# kind: Secret
# name: mysqld-exporter-prometheus-mysql-exporter
# namespace: default

Single Machine

Alternatively, you can install the Prometheus MySQL exporter on a single machine.

Prerequisite(s):

  • You have the [StackGen Agent running on the machine](../../Collecting Telemetry/Install the OpsVerse Agent#VEqXM)
  • Required Grants on DB are enabled

Run this command to install the MySQL exporter as a systemd unit:

# For amd64
curl https://raw.githubusercontent.com/OpsVerseIO/installers/main/prometheus-exporters/install-exporter-amd64.sh | sudo bash -s -- -e mysqld

# For arm64
curl https://raw.githubusercontent.com/OpsVerseIO/installers/main/prometheus-exporters/install-exporter-arm64.sh | sudo bash -s -- -e mysqld
  • The agent will begin scraping the metrics automatically; the script will drop the scrape target into /etc/opsverse/targets/, so the agent will begin automatically scraping
  • If you need to update MySQL connection info, after you install, you may edit /etc/opsverse/exporters/mysqld/.my.cnf and then restart the service:
sudo systemctl restart prom-mysqld-exporter