Setting Up Grafana and Prometheus Monitoring for DBLE JVM Metrics Using Docker
This tutorial explains how to use Docker to deploy DBLE, Prometheus, and Grafana, configure JMX Exporter for JVM metrics, and create a monitoring dashboard that visualizes CPU, memory pool, GC, and thread statistics of DBLE instances.
1 Introduction
This article demonstrates how to build a monitoring system for DBLE JVM-related metrics (CPU, Memory Pool, GC, Thread) using Docker, Grafana, and Prometheus.
Preparation
Linux server: 10.186.63.8
Docker already installed
2 Environment Setup
1. Deploy DBLE
The following steps are based on the Docker quick‑start guide.
Prepare MySQL containers
# Create a Docker network dble-net: 172.18.0.0/16
docker network create -o "com.docker.network.bridge.name"="dble-net" --subnet 172.18.0.0/16 dble-net
# Create two MySQL containers mapped to host ports 33061 and 33062
docker run --name backend-mysql1 --ip 172.18.0.2 -e MYSQL_ROOT_PASSWORD=123456 -p 33061:3306 --network=dble-net -d mysql:5.7 --server-id=1
docker run --name backend-mysql2 --ip 172.18.0.3 -e MYSQL_ROOT_PASSWORD=123456 -p 33062:3306 --network=dble-net -d mysql:5.7 --server-id=2If the docker run... command returns a 408 Request Time‑out error, retry a few times.
Deploy DBLE
Deploy DBLE service with Docker.
docker run -d -i -t --name dble-server --ip 172.18.0.4 -p 8066:8066 -p 9066:9066 -p 8099:8099 \
-v /opt/jmx-exporter:/jmx-exporter \
--network=dble-net \
actiontech/dble:latestPort 8099 is used to expose monitoring metrics.
JMX Exporter runs as a Java agent inside the JVM, exposing metrics in Prometheus format.
# Create directory for JMX Exporter
mkdir /opt/jmx-exporter
# Download the exporter jar
wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.15.0/jmx_prometheus_javaagent-0.15.0.jarDBLE currently supports up to jmx_prometheus_javaagent-0.15.0.jar ; using a newer version will cause DBLE startup failure.
Add a prometheus-jmx-config.yaml file with the following content:
ssl: false
lowercaseOutputName: false
lowercaseOutputLabelNames: falseEnter the dble‑server container and modify the bootstrap configuration:
docker exec -it dble-server bash
vi /opt/dble/conf/bootstrap.cnf
# Add Java agent configuration
-javaagent:/jmx-exporter/jmx_prometheus_javaagent-0.15.0.jar=8099:/jmx-exporter/prometheus-jmx-config.yamlRestart DBLE and verify it starts correctly.
/opt/dble/bin/dble restart
vi /opt/dble/logs/wrraper.logView DBLE JVM metrics
Access http://10.186.63.8:8099 to see the exported metrics.
2. Deploy Prometheus
Run Prometheus in Docker:
docker run -itd --name prometheus --ip 172.18.0.5 -p 9090:9090 --network=dble-net prom/prometheusEnter the container, edit prometheus.yml , and add a job named DBLE_Job targeting 172.18.0.4:8099 :
docker exec -it prometheus sh
vi /etc/prometheus/prometheus.yml
# Overwrite with the following configuration
scrape_configs:
- job_name: 'DBLE_Job'
scrape_interval: 30s
static_configs:
- targets:
- '172.18.0.4:8099'Note: 172.18.0.4 is the IP of the dble‑server container.
Restart the Prometheus container and verify the target at http://10.186.63.8:9090/targets is up.
3. Deploy Grafana
Run Grafana in Docker:
docker run -itd --name=grafana --ip 172.18.0.6 -p 3000:3000 --network=dble-net grafana/grafanaOpen http://10.186.63.8:3000 and log in with the default credentials admin/admin .
4 Monitoring Dashboards
Import JVM Monitoring Template
In Grafana, add a Prometheus data source pointing to http://172.18.0.5:9090 .
Import dashboard ID 8878 (or the corresponding JSON file; another JVM template ID is 8563 ).
Customize the dashboard name as needed. The resulting view displays CPU, Memory Pool, GC, Thread and other JVM metrics.
5 Version Notes
For DBLE versions ≤ 2.20.04.0, add the Java agent configuration in the bin/wrapper.cnf file.
DBLE versions 3.20.07.0 and 3.20.10.0 do not support the -javaagent option, so JVM monitoring cannot be configured.
DBLE versions ≥ 3.21.02.0 follow the configuration described above.
wrapper.java.additional.
=-javaagent:/jmx-exporter/jmx_prometheus_javaagent-0.15.0.jar=8099:/jmx-exporter/prometheus-jmx-config.yamlReferences
[1] Docker Quick Start: https://actiontech.github.io/dble-docs-cn/0.overview/0.3_quick_start/0.3.1_dble_quick_start_docker.html
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.