Monitoring Alibaba Cloud RDS with Prometheus, Grafana, and Custom Exporters
This guide explains how to monitor Alibaba Cloud RDS instances by deploying Prometheus and Grafana, using the official mysqld_exporter, a custom aliyun-exporter, rebuilding Docker images, configuring supervisor and Prometheus service discovery, and automating the entire workflow while noting limitations.
Cloud providers handle many operational tasks, but native RDS monitoring can be cumbersome, so the author adopts Prometheus and Grafana for a more flexible solution.
1. Tool collection phase
1.1 Deploy Prometheus and Grafana (installation details omitted; see the Prometheus book for reference).
1.2 Monitor Alibaba Cloud RDS (MySQL) using the official mysqld_exporter from GitHub . Example environment variable and start command:
export DATA_SOURCE_NAME='user:password@(hostname:3306)/'
./mysqld_exporter <flags>1.3 Collect resource metrics with node_exporter and a custom aliyun-exporter written by Aylei ( GitHub ), which gathers ECS, SLB, Redis, MongoDB, and RDS data in Prometheus format.
1.3.1 Rebuild the Docker image because the original image lacks the SLB module. Example Dockerfile:
FROM aylei/aliyun-exporter:0.3.0
RUN pip3 install -U aliyun-exporter==0.3.1 PyYAML==5.1.2
RUN pip3 install aliyun-python-sdk-slb aliyun-python-sdk-dds
COPY info_provider.py /usr/local/lib/python3.7/site-packages/aliyun_exporter/info_provider.py
# Build image
docker build -f docker.file -t aliyun-exporter:0.3.1 .1.3.2 Fix a bug where enabling rds_performance prevents the service from starting; use mysqld_exporter as a supplement.
1.3.3 Run the container:
docker run -d -p 9526:9525 \
-e "ALIYUN_ACCESS_ID=XXXX" \
-e "ALIYUN_ACCESS_SECRET=XXXX" \
-e "ALIYUN_REGION=cn-XXXX" \
-v $(pwd)/aliyun-exporter-test.yml:/aliyun-exporter.yml \
aliyun-exporter:0.3.1 -p 9525 -c /aliyun-exporter.yml1.3.4 Grafana dashboard configuration (details omitted).
2. Tool combination
2.1 Architecture diagram shows an ECS host running mysqld_exporter and aliyun_exporter , feeding metrics to Prometheus.
2.2 Manage mysqld_exporter with supervisor using a configuration template:
[program:mysqld_exporter]
directory = /opt/mysqld_exporter
command = /bin/nohup /opt/mysqld_exporter/mysqld_exporter --web.listen-address=[IP]:[PORT] ...
autostart = true
autorestart = true
user = root
environment=DATA_SOURCE_NAME='user:password@(hostname:3306)/'2.3 Prometheus service discovery using file‑sd configs for test, QA, and production environments, each with labels and target lists.
2.4 Final notes: the solution automates RDS monitoring, eliminating manual script updates, but each RDS still requires a separate mysqld_exporter instance and distinct ports.
3. Simple effect demonstration – screenshots of Grafana panels showing resource and MySQL metrics.
4. Limitations – API rate limits, occasional missing data, and the need for multiple exporter processes for multiple RDS instances.
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.