Deploy MySQL Metrics Prometheus Exporter
A Prometheus exporter for gathering metrics about your MySQL DB
mysql-metrics-collector
zuchka/railway-mysql-exporter
Just deployed
MySQL Metrics Collector for Railway
How to replace user root with user exporter
This template will work immediately on any railway project that has a MySQL database deployed. However, it uses the root user for access, which is not ideal.
For better security, you should set up a dedicated exporter user in your MySQL DB. The following are detailed instructions for setting that up and adjusting the Railway environmental variables:
-
log into your MySQL DB locally using Railway's connection procedures. These are listed in your MySQL details page.
-
run the following commands to create a new user named
exporter. Be sure to replaceXXXXXXXXwith a strong password of your choosing:
CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'XXXXXXXX' WITH MAX_USER_CONNECTIONS 3;
GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';
-
Return to the Railway UI. Navigate to your MySQL Collector service and add one new environmental variable: create a key called
MYSQL_EXPORT_PASSWORDand set the value to your new password. TheMYSQL_EXPORT_USERvariable is already set toexporter. -
Update the
Dockerfileand the.my.cnffile in your github repo. The appropriate replacement lines are already present, but commented out. Comment-out the old lines and uncomment these new lines. Push your changes. Railway will redeploy the collector with the new settings. Your collector is now using a dedicatedexporteruser instead of therootuser!
Template Content
mysql-metrics-collector
zuchka/railway-mysql-exporter