How can I monitor the performance of a Managed Database cluster?
Linode's Cloud Manager doesn't have any statistics or graphs for Managed Database clusters, so how can I monitor one if I don't have direct access to the database server?
2 Replies
✓ Best Answer
While we don't currently have this capability built into Linode's Cloud Manager, you can set up a third party application called netdata using a Linode or any other supported platform to monitor your cluster's performance.
After you've created your Managed Database and waited for it to finish provisioning (which could take 15-30 minutes), you are ready to install a database client and setup netdata.
Make sure you add access to your Managed Database for any IP addresses that will be connecting to it (your own IP, your Linode's IP, etc.)
In this example, we'll be installing netdata on a new Linode running Ubuntu 22.04 LTS and connecting to a MySQL Managed Database cluster.
To install a MySQL client, you will need to pick the appropriate Client package for your operating system. For Ubuntu 22.04, the appropriate command to run as root or with sudo at the beginning is:
apt update
apt install mysql-client-core-8.0
Once you have installed a MySQL client, you are ready to connect to your Managed Database using the provided username and password. This should look something like this:
mysql --host=lin-1234-5678-mysql-primary-private.servers.linodedb.net --user=linroot --password --ssl-mode=required
In this example, we're connecting with the default username linroot
and the password provided by clicking Show under the cluster's Connection Details. While you can use the default credentials with netdata, it is recommended to create an additional MySQL user with only the needed permissions via a mysql>
prompt:
CREATE USER 'netdata'@'%' IDENTIFIED BY 'MySecurePassword';
GRANT USAGE, REPLICATION CLIENT, PROCESS ON *.* TO 'netdata'@'%';
FLUSH PRIVILEGES;
You'll need to replace MySecurePassword
with a secure password of your choice. For a Managed Database, your password will need at least: 8 characters, one uppercase, one lowercase, one number, and one special character.
Once this is complete, you can proceed to install netdata. The following command should automatically install netdata with automatic updates enabled for their stable channel and telemetry disabled:
wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh --stable-channel --disable-telemetry
After the install is complete, you can get a default netdata configuration for MySQL via:
cd /etc/netdata
sudo ./edit-config go.d/mysql.conf
This will create a default configuration file for the netdata MySQL connector and open the nano
text editor. Here you can add your Managed Database connection parameters at the end of the file, replacing the items between braces {} with your appropriate values. The spacing at the beginning of each line will need to match the ones above it, or the configuration file will not be parsed correctly.
- name: Managed Database
dsn: '{username}:{password}@tcp({database hostname})/?tls=skip-verify'
This could look like the following:
- name: Managed Database
dsn: 'netdata:MySecurePassword@tcp(lin-1234-5678-mysql-primary-private.servers.linodedb.net)/?tls=skip-verify'
Once you have added the connection parameters, save the file and restart the netdata service by running the following command as root or with sudo in front:
systemctl restart netdata
If everything is set up correctly, you should now be able to browse to your Linode's IP address over port 19999 to see your netdata instance (such as http://111.222.333.444:19999).
If you don't see your Managed Database in the bottom right corner of the dashboard, you may need to troubleshoot your configuration and restart the netdata service again after correcting any errors.
Note: double check that your Linode's IP address has been given access to your Managed Database.
From here, you'll want to secure your netdata dashboard as while the information presented by netdata isn't necessarily sensitive, it could be used for nefarious purposes.
Congratulations, you can now monitor a variety of metrics for your Managed Database cluster!
I was able to use this guide to connect to my postgres managed database monitoring with the netdata-cloud but with some difficulty.
The postgres.conf file below worked for me but only with the default username and new password for my db. I was not able to create a username with limited permissions, as recommended. I'm wondering if its because I don't have superuser capabilities when connecting via psql shell?
I used the default username/password to access the psql shell. I was able to create a new user with new password and used postgres recommended command below to grant permissions:
GRANT pg_monitor TO netdata;
However, when used in my postgres.conf file, i got a permissions error with this username.
The postgres.conf file that worked for me was:
# netdata go.d/postgres.conf configuration
jobs:
- name: Managed_Database
#working with default userid
dsn: 'postgres://linpostgres:<default_password>@lin-XXXXX-XXXXX-pgsql-primary-private.servers.linodedb.net:5432/postgres?sslmode=require'
update_every: 10
autodetection_retry: 0
priority: 70000
What is recommended way to create a new username using psql shell? Thanks.