Monitoring your DigitalOcean Managed Databases is crucial for ensuring their performance, stability, and security. By implementing monitoring solutions like Prometheus and Grafana, you gain valuable insights into your database clusters’ health and performance metrics, enabling proactive management and troubleshooting. You can programmatically access your database cluster’s metrics through the metrics endpoint, providing access to over twenty times the metrics compared to what’s accessible in the Insights tab within the cloud control panel.
This tutorial outlines the steps to set up monitoring for Managed Databases on DigitalOcean (except MongoDB) using Prometheus and Grafana. We use a script here that utilizes the scrapable metrics endpoint to export logs, enabling comprehensive monitoring of your DigitalOcean Managed Databases. We’ll cover accessing the metrics endpoint, configuring Prometheus to scrape metrics, and visualizing the data in Grafana.
jq
The setup time should be around 25 minutes.
Step 1: SSH into the Prometheus Droplet.
Step 2: Download the script DO_Managed_Databases_Monitoring_Manage.sh
using the wget
command:
wget https://solutions-files.ams3.cdn.digitaloceanspaces.com/DBaaS-Scrape-Metrics/DO_Managed_Databases_Monitoring_Manage.sh
Step 3: Once the script is downloaded, ensure it has executable permissions by running:
chmod +x DO_Managed_Databases_Monitoring_Manage.sh
Step 4: Execute the script DO_Managed_Databases_Monitoring_Manage.sh
by running:
./DO_Managed_Databases_Monitoring_Manage.sh
Note: If jq
is not installed on the Droplet, you will get this error:
root@prometheus:~# ./DO_Managed_Databases_Monitoring_Manage.sh
Checking dependencies...
Error: jq is not installed. Please install it before running this script.
In that case, you can install jq
on the Droplet by running the following commands:
sudo apt-get update && sudo apt-get install jq
If you get the below error when installing jq
, then remove the lock file by running the command sudo rm /var/lib/dpkg/lock*
root@prometheus:~# sudo apt-get install jq
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
root@prometheus:~# sudo dpkg --configure -a
dpkg: error: dpkg frontend is locked by another process
root@prometheus:~# sudo rm /var/lib/dpkg/lock*
root@prometheus:~# sudo apt-get install jq
Reading package lists... Done
Building dependency tree
Reading state information... Done
Run the script again after installing jq
.
Step 5: Select the managed database you want to manage by entering its number.
Step 6: Enter your DigitalOcean token.
Step 7: On the Main Menu, choose the required option and select the database.
Step 8: The script will add or remove the databases for monitoring.
Step 9: Once added or removed, check whether the targets are updated on prometheus_hostname:9090
Step 1: Log into the Grafana dashboard by visiting your browser’s URL Grafana_IP:3000
.
Step 2: Go to Configuration > Data Sources.
Step 3: Click on Add data source.
Step 4: Search and Select Prometheus.
Step 5: Enter Name as Prometheus, URL (Prometheushostname:9090) and click “Save & Test”. If you see “Data source is working”, you have successfully added the data source. Once done, go to Create > Import.
Step 6: You can manually configure the dashboard or import the dashboard by uploading the JSON file. Some sample dashboard JSON files are below:
MySQL | PostgreSQL | Redis | Kafka
Step 7: Fill in the fields and Import.
Step 8: The Grafana dashboard is ready. Select the host and check if the metrics are visible. You can modify and edit the dashboard as needed.
Setting up monitoring for DigitalOcean Managed Databases using Prometheus and Grafana enhances your ability to ensure your database clusters’ performance, stability, and security.
You gain comprehensive insights into database health and performance metrics by leveraging Prometheus to scrape metrics and Grafana to visualize them.
This proactive approach allows for efficient management and timely troubleshooting, which is crucial for maintaining optimal database operations. With the outlined steps in this documentation, you can easily implement robust monitoring tailored to your specific database needs, ensuring smooth operations of your DigitalOcean Managed Databases.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.