Configure comprehensive monitoring for MariaDB Galera clusters using Prometheus exporters and Grafana dashboards to track cluster health, replication status, and performance metrics with automated alerting for production environments.
Prerequisites
- MariaDB Galera cluster already configured
- Root or sudo access
- Basic knowledge of SQL and system administration
- Network connectivity between cluster nodes
What this solves
MariaDB Galera clusters require specialized monitoring to ensure high availability and detect split-brain scenarios, node failures, and replication lag before they impact your applications. This tutorial configures Prometheus with MariaDB exporters and Grafana dashboards to provide real-time visibility into cluster health, node synchronization status, and performance metrics with automated alerting for critical conditions.
Step-by-step installation
Update system packages
Start by updating your package manager to ensure you get the latest versions of monitoring tools.
sudo apt update && sudo apt upgrade -y
sudo apt install -y wget curl
Install Prometheus server
Download and install Prometheus to collect metrics from MariaDB Galera cluster nodes.
cd /tmp
wget https://github.com/prometheus/prometheus/releases/download/v2.48.0/prometheus-2.48.0.linux-amd64.tar.gz
tar xzf prometheus-2.48.0.linux-amd64.tar.gz
sudo mv prometheus-2.48.0.linux-amd64 /opt/prometheus
sudo useradd --no-create-home --shell /bin/false prometheus
sudo chown -R prometheus:prometheus /opt/prometheus
Create Prometheus directories and configuration
Set up the directory structure and main configuration file for Prometheus with proper permissions.
sudo mkdir -p /etc/prometheus /var/lib/prometheus
sudo chown prometheus:prometheus /etc/prometheus /var/lib/prometheus
sudo ln -s /opt/prometheus/prometheus /usr/local/bin/
sudo ln -s /opt/prometheus/promtool /usr/local/bin/
Configure Prometheus for MariaDB monitoring
Create the main Prometheus configuration file with scraping targets for MariaDB Galera cluster nodes.
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
- "galera_alerts.yml"
alerting:
alertmanagers:
- static_configs:
- targets:
- localhost:9093
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'mariadb-galera'
static_configs:
- targets:
- '203.0.113.10:9104' # MariaDB node 1
- '203.0.113.11:9104' # MariaDB node 2
- '203.0.113.12:9104' # MariaDB node 3
scrape_interval: 5s
metrics_path: /metrics
- job_name: 'node-exporter'
static_configs:
- targets:
- '203.0.113.10:9100'
- '203.0.113.11:9100'
- '203.0.113.12:9100'
Install MariaDB exporter on cluster nodes
Download and configure the MariaDB exporter on each Galera cluster node to expose database metrics.
wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.15.0/mysqld_exporter-0.15.0.linux-amd64.tar.gz
tar xzf mysqld_exporter-0.15.0.linux-amd64.tar.gz
sudo mv mysqld_exporter-0.15.0.linux-amd64/mysqld_exporter /usr/local/bin/
sudo useradd --no-create-home --shell /bin/false mysqld_exporter
Create MariaDB monitoring user
Create a dedicated database user with minimal privileges for metrics collection on each cluster node.
mysql -u root -p
CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT PROCESS, REPLICATION CLIENT, SELECT ON . TO 'exporter'@'localhost';
GRANT SELECT ON performance_schema.* TO 'exporter'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Configure MariaDB exporter credentials
Create a secure configuration file for the MariaDB exporter with database connection details.
[client]
user=exporter
password=StrongPassword123!
host=localhost
port=3306
sudo chown mysqld_exporter:mysqld_exporter /etc/mysql/.mysqld_exporter.cnf
sudo chmod 600 /etc/mysql/.mysqld_exporter.cnf
Create systemd service for MariaDB exporter
Configure the MariaDB exporter as a system service with Galera-specific metrics enabled.
[Unit]
Description=MariaDB Exporter for Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=mysqld_exporter
Group=mysqld_exporter
Type=simple
Restart=always
Environment=DATA_SOURCE_NAME="exporter:StrongPassword123!@(localhost:3306)/"
ExecStart=/usr/local/bin/mysqld_exporter \
--config.my-cnf=/etc/mysql/.mysqld_exporter.cnf \
--collect.info_schema.innodb_metrics \
--collect.info_schema.innodb_tablespaces \
--collect.info_schema.innodb_cmp \
--collect.info_schema.innodb_cmpmem \
--collect.info_schema.processlist \
--collect.info_schema.query_response_time \
--collect.global_status \
--collect.global_variables \
--collect.slave_status \
--collect.info_schema.tables \
--web.listen-address=0.0.0.0:9104
[Install]
WantedBy=multi-user.target
Install Node Exporter for system metrics
Install Node Exporter on each cluster node to monitor system-level metrics like CPU, memory, and disk usage.
wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz
tar xzf node_exporter-1.7.0.linux-amd64.tar.gz
sudo mv node_exporter-1.7.0.linux-amd64/node_exporter /usr/local/bin/
sudo useradd --no-create-home --shell /bin/false node_exporter
Create Node Exporter systemd service
Configure Node Exporter as a system service to collect hardware and operating system metrics.
[Unit]
Description=Node Exporter for Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
Restart=always
ExecStart=/usr/local/bin/node_exporter \
--web.listen-address=0.0.0.0:9100 \
--collector.systemd \
--collector.processes
[Install]
WantedBy=multi-user.target
Create Prometheus systemd service
Configure Prometheus as a system service with proper resource limits and storage configuration.
[Unit]
Description=Prometheus Server
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
Restart=always
ExecStart=/usr/local/bin/prometheus \
--config.file=/etc/prometheus/prometheus.yml \
--storage.tsdb.path=/var/lib/prometheus/ \
--web.console.templates=/opt/prometheus/consoles \
--web.console.libraries=/opt/prometheus/console_libraries \
--web.listen-address=0.0.0.0:9090 \
--web.external-url=http://localhost:9090 \
--storage.tsdb.retention.time=15d
[Install]
WantedBy=multi-user.target
Create Galera-specific alert rules
Configure Prometheus alerting rules to detect Galera cluster issues like node failures and split-brain scenarios.
groups:
- name: mariadb-galera
rules:
- alert: GaleraNodeDown
expr: up{job="mariadb-galera"} == 0
for: 30s
labels:
severity: critical
annotations:
summary: "MariaDB Galera node is down"
description: "MariaDB Galera node {{ $labels.instance }} has been down for more than 30 seconds."
- alert: GaleraClusterSizeReduced
expr: mysql_global_status_wsrep_cluster_size < 3
for: 1m
labels:
severity: warning
annotations:
summary: "Galera cluster size reduced"
description: "Galera cluster size is {{ $value }}, expected 3 nodes."
- alert: GaleraNodeNotReady
expr: mysql_global_status_wsrep_ready == 0
for: 30s
labels:
severity: critical
annotations:
summary: "Galera node not ready"
description: "Galera node {{ $labels.instance }} is not ready to accept connections."
- alert: GaleraReplicationLag
expr: mysql_global_status_wsrep_local_recv_queue > 100
for: 2m
labels:
severity: warning
annotations:
summary: "High Galera replication lag"
description: "Galera node {{ $labels.instance }} has high replication lag: {{ $value }} queued writes."
- alert: GaleraFlowControl
expr: rate(mysql_global_status_wsrep_flow_control_paused[5m]) > 0.1
for: 2m
labels:
severity: warning
annotations:
summary: "Galera flow control activated"
description: "Galera flow control is active on {{ $labels.instance }}, indicating performance issues."
- alert: MariaDBHighConnections
expr: mysql_global_status_threads_connected / mysql_global_variables_max_connections > 0.8
for: 5m
labels:
severity: warning
annotations:
summary: "MariaDB high connection usage"
description: "MariaDB connection usage is above 80% on {{ $labels.instance }}."
- alert: MariaDBSlowQueries
expr: rate(mysql_global_status_slow_queries[5m]) > 5
for: 5m
labels:
severity: warning
annotations:
summary: "High number of slow queries"
description: "MariaDB is experiencing {{ $value }} slow queries per second on {{ $labels.instance }}."
- alert: MariaDBHighQPS
expr: rate(mysql_global_status_queries[5m]) > 1000
for: 10m
labels:
severity: warning
annotations:
summary: "High query rate"
description: "MariaDB is processing {{ $value }} queries per second on {{ $labels.instance }}."
Install Grafana
Install Grafana to create dashboards for visualizing MariaDB Galera cluster metrics and performance data.
sudo apt install -y software-properties-common
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt update
sudo apt install -y grafana
Configure firewall rules
Open the necessary ports for Prometheus, Grafana, and the exporters to communicate across the cluster.
sudo ufw allow 9090/tcp comment 'Prometheus'
sudo ufw allow 3000/tcp comment 'Grafana'
sudo ufw allow 9104/tcp comment 'MariaDB Exporter'
sudo ufw allow 9100/tcp comment 'Node Exporter'
Start and enable all services
Start all monitoring services and enable them to start automatically on system boot.
sudo systemctl daemon-reload
sudo systemctl enable --now prometheus
sudo systemctl enable --now mysqld_exporter
sudo systemctl enable --now node_exporter
sudo systemctl enable --now grafana-server
Configure Grafana data source
Access Grafana web interface and configure Prometheus as a data source for metrics visualization.
URL: http://localhost:9090
Access: Server (default)
Scrape interval: 15s
Query timeout: 60s
HTTP Method: POST
Import MariaDB Galera dashboard
Create a comprehensive Grafana dashboard to monitor all aspects of your MariaDB Galera cluster performance and health.
{
"dashboard": {
"title": "MariaDB Galera Cluster Monitoring",
"panels": [
{
"title": "Cluster Status",
"type": "stat",
"targets": [
{
"expr": "mysql_global_status_wsrep_cluster_size",
"legendFormat": "Cluster Size"
}
]
},
{
"title": "Node Status",
"type": "table",
"targets": [
{
"expr": "mysql_global_status_wsrep_ready",
"legendFormat": "{{instance}} Ready"
}
]
},
{
"title": "Replication Queue",
"type": "graph",
"targets": [
{
"expr": "mysql_global_status_wsrep_local_recv_queue",
"legendFormat": "{{instance}} Receive Queue"
}
]
},
{
"title": "Query Rate",
"type": "graph",
"targets": [
{
"expr": "rate(mysql_global_status_queries[5m])",
"legendFormat": "{{instance}} QPS"
}
]
}
]
}
}
Verify your setup
Check that all services are running correctly and metrics are being collected from your MariaDB Galera cluster.
sudo systemctl status prometheus mysqld_exporter node_exporter grafana-server
curl http://localhost:9090/targets
curl http://localhost:9104/metrics | grep wsrep
curl http://localhost:9100/metrics | grep node_load1
Verify Prometheus can scrape MariaDB Galera metrics:
# Check Prometheus targets
wget -qO- http://localhost:9090/api/v1/targets | jq '.data.activeTargets[] | select(.job=="mariadb-galera") | .health'
Test Galera-specific metrics
wget -qO- http://localhost:9090/api/v1/query?query=mysql_global_status_wsrep_cluster_size
Verify alerting rules
wget -qO- http://localhost:9090/api/v1/rules
Configure alerting with Alertmanager
Install Alertmanager
Install and configure Alertmanager to handle alert notifications from Prometheus for Galera cluster issues.
wget https://github.com/prometheus/alertmanager/releases/download/v0.26.0/alertmanager-0.26.0.linux-amd64.tar.gz
tar xzf alertmanager-0.26.0.linux-amd64.tar.gz
sudo mv alertmanager-0.26.0.linux-amd64 /opt/alertmanager
sudo useradd --no-create-home --shell /bin/false alertmanager
sudo chown -R alertmanager:alertmanager /opt/alertmanager
sudo ln -s /opt/alertmanager/alertmanager /usr/local/bin/
Configure Alertmanager for email notifications
Set up Alertmanager to send email notifications when Galera cluster issues are detected.
global:
smtp_smarthost: 'localhost:587'
smtp_from: 'alerts@example.com'
smtp_auth_username: 'alerts@example.com'
smtp_auth_password: 'EmailPassword123!'
route:
group_by: ['alertname']
group_wait: 10s
group_interval: 10s
repeat_interval: 1h
receiver: 'galera-alerts'
receivers:
- name: 'galera-alerts'
email_configs:
- to: 'dba@example.com'
subject: 'MariaDB Galera Alert: {{ .GroupLabels.alertname }}'
body: |
{{ range .Alerts }}
Alert: {{ .Annotations.summary }}
Description: {{ .Annotations.description }}
Instance: {{ .Labels.instance }}
Severity: {{ .Labels.severity }}
{{ end }}
Create Alertmanager systemd service
Configure Alertmanager as a system service to handle alert routing and notifications.
[Unit]
Description=Alertmanager for Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=alertmanager
Group=alertmanager
Type=simple
Restart=always
ExecStart=/usr/local/bin/alertmanager \
--config.file=/opt/alertmanager/alertmanager.yml \
--storage.path=/opt/alertmanager/data \
--web.external-url=http://localhost:9093
[Install]
WantedBy=multi-user.target
sudo mkdir -p /opt/alertmanager/data
sudo chown alertmanager:alertmanager /opt/alertmanager/data
sudo systemctl daemon-reload
sudo systemctl enable --now alertmanager
Common issues
| Symptom | Cause | Fix |
|---|---|---|
| MariaDB exporter fails to start | Database connection or credentials issue | Check /etc/mysql/.mysqld_exporter.cnf and test connection with mysql -u exporter -p |
| No Galera metrics in Prometheus | Exporter not collecting wsrep status variables | Verify MariaDB user has REPLICATION CLIENT privilege and wsrep is enabled |
| Prometheus targets showing as down | Firewall blocking scraping or wrong port | Check firewall rules and verify exporters are listening on correct ports |
| Grafana can't connect to Prometheus | Network connectivity or Prometheus not running | Verify Prometheus is accessible at http://localhost:9090 and check systemctl status |
| Alerts not firing despite issues | Alert rules not loaded or Alertmanager misconfigured | Check http://localhost:9090/rules and verify Alertmanager configuration |
| High memory usage by Prometheus | Too many metrics or long retention period | Reduce scrape frequency, limit metrics collection, or decrease retention time |
Next steps
- Set up MariaDB Galera Cluster 11.6 for multi-master replication with automatic failover
- Implement MariaDB connection pooling with ProxySQL for high availability
- Configure Prometheus long-term storage with Thanos for unlimited data retention
- Set up automated MariaDB Galera backup with Mariabackup and retention policies
- Configure MariaDB Galera cluster SSL encryption and authentication
Automated install script
Run this to automate the entire setup
#!/usr/bin/env bash
set -euo pipefail
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Default values
MARIADB_IPS="${MARIADB_IPS:-}"
EXPORTER_PASSWORD="${EXPORTER_PASSWORD:-$(openssl rand -base64 32)}"
# Usage function
usage() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -i, --ips Comma-separated MariaDB cluster IPs (e.g., 10.0.1.10,10.0.1.11,10.0.1.12)"
echo " -p, --password MySQL exporter password (auto-generated if not provided)"
echo " -h, --help Show this help message"
exit 1
}
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
-i|--ips) MARIADB_IPS="$2"; shift 2 ;;
-p|--password) EXPORTER_PASSWORD="$2"; shift 2 ;;
-h|--help) usage ;;
*) echo -e "${RED}Unknown option: $1${NC}"; usage ;;
esac
done
if [[ -z "$MARIADB_IPS" ]]; then
echo -e "${RED}Error: MariaDB cluster IPs are required${NC}"
usage
fi
# Cleanup function
cleanup() {
echo -e "${RED}Installation failed. Cleaning up...${NC}"
systemctl stop prometheus 2>/dev/null || true
systemctl stop mysqld_exporter 2>/dev/null || true
systemctl disable prometheus 2>/dev/null || true
systemctl disable mysqld_exporter 2>/dev/null || true
rm -rf /opt/prometheus /etc/prometheus /var/lib/prometheus
rm -f /usr/local/bin/prometheus /usr/local/bin/promtool /usr/local/bin/mysqld_exporter
userdel prometheus 2>/dev/null || true
userdel mysqld_exporter 2>/dev/null || true
}
trap cleanup ERR
# Check if running as root
if [[ $EUID -ne 0 ]]; then
echo -e "${RED}This script must be run as root${NC}"
exit 1
fi
# Detect distribution
if [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
ubuntu|debian)
PKG_MGR="apt"
PKG_INSTALL="apt install -y"
PKG_UPDATE="apt update && apt upgrade -y"
;;
almalinux|rocky|centos|rhel|ol|fedora)
PKG_MGR="dnf"
PKG_INSTALL="dnf install -y"
PKG_UPDATE="dnf update -y"
;;
amzn)
PKG_MGR="yum"
PKG_INSTALL="yum install -y"
PKG_UPDATE="yum update -y"
;;
*)
echo -e "${RED}Unsupported distribution: $ID${NC}"
exit 1
;;
esac
else
echo -e "${RED}Cannot detect distribution${NC}"
exit 1
fi
echo -e "${GREEN}Installing MariaDB Galera cluster monitoring with Prometheus and Grafana${NC}"
# Step 1: Update system packages
echo -e "${YELLOW}[1/10] Updating system packages...${NC}"
$PKG_UPDATE
$PKG_INSTALL wget curl tar openssl
# Step 2: Install Prometheus
echo -e "${YELLOW}[2/10] Installing Prometheus server...${NC}"
cd /tmp
wget -q https://github.com/prometheus/prometheus/releases/download/v2.48.0/prometheus-2.48.0.linux-amd64.tar.gz
tar xzf prometheus-2.48.0.linux-amd64.tar.gz
mv prometheus-2.48.0.linux-amd64 /opt/prometheus
useradd --no-create-home --shell /bin/false prometheus
chown -R prometheus:prometheus /opt/prometheus
# Step 3: Create Prometheus directories
echo -e "${YELLOW}[3/10] Creating Prometheus directories and configuration...${NC}"
mkdir -p /etc/prometheus /var/lib/prometheus
chown prometheus:prometheus /etc/prometheus /var/lib/prometheus
ln -sf /opt/prometheus/prometheus /usr/local/bin/
ln -sf /opt/prometheus/promtool /usr/local/bin/
# Step 4: Configure Prometheus
echo -e "${YELLOW}[4/10] Configuring Prometheus for MariaDB monitoring...${NC}"
IFS=',' read -ra IP_ARRAY <<< "$MARIADB_IPS"
MARIADB_TARGETS=""
NODE_TARGETS=""
for ip in "${IP_ARRAY[@]}"; do
MARIADB_TARGETS="${MARIADB_TARGETS} - '${ip}:9104'\n"
NODE_TARGETS="${NODE_TARGETS} - '${ip}:9100'\n"
done
cat > /etc/prometheus/prometheus.yml << EOF
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
- "galera_alerts.yml"
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'mariadb-galera'
static_configs:
- targets:
$(echo -e "$MARIADB_TARGETS")
scrape_interval: 5s
metrics_path: /metrics
- job_name: 'node-exporter'
static_configs:
- targets:
$(echo -e "$NODE_TARGETS")
EOF
chown prometheus:prometheus /etc/prometheus/prometheus.yml
# Step 5: Create Galera alert rules
echo -e "${YELLOW}[5/10] Creating Galera alert rules...${NC}"
cat > /etc/prometheus/galera_alerts.yml << 'EOF'
groups:
- name: galera_alerts
rules:
- alert: GaleraNodeDown
expr: up{job="mariadb-galera"} == 0
for: 1m
labels:
severity: critical
annotations:
summary: "Galera node is down"
description: "Galera node {{ $labels.instance }} has been down for more than 1 minute."
- alert: GaleraClusterSplit
expr: mysql_global_status_wsrep_cluster_size < 3
for: 30s
labels:
severity: critical
annotations:
summary: "Galera cluster split detected"
description: "Galera cluster size is {{ $value }}, indicating a potential split-brain scenario."
EOF
chown prometheus:prometheus /etc/prometheus/galera_alerts.yml
# Step 6: Install MariaDB exporter
echo -e "${YELLOW}[6/10] Installing MariaDB exporter...${NC}"
wget -q https://github.com/prometheus/mysqld_exporter/releases/download/v0.15.0/mysqld_exporter-0.15.0.linux-amd64.tar.gz
tar xzf mysqld_exporter-0.15.0.linux-amd64.tar.gz
mv mysqld_exporter-0.15.0.linux-amd64/mysqld_exporter /usr/local/bin/
useradd --no-create-home --shell /bin/false mysqld_exporter
chmod 755 /usr/local/bin/mysqld_exporter
# Step 7: Configure MariaDB exporter credentials
echo -e "${YELLOW}[7/10] Configuring MariaDB exporter credentials...${NC}"
mkdir -p /etc/mysql
cat > /etc/mysql/.mysqld_exporter.cnf << EOF
[client]
user=exporter
password=$EXPORTER_PASSWORD
host=localhost
port=3306
EOF
chown mysqld_exporter:mysqld_exporter /etc/mysql/.mysqld_exporter.cnf
chmod 600 /etc/mysql/.mysqld_exporter.cnf
# Step 8: Create systemd services
echo -e "${YELLOW}[8/10] Creating systemd services...${NC}"
# Prometheus service
cat > /etc/systemd/system/prometheus.service << 'EOF'
[Unit]
Description=Prometheus Server
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
Restart=always
ExecStart=/usr/local/bin/prometheus \
--config.file=/etc/prometheus/prometheus.yml \
--storage.tsdb.path=/var/lib/prometheus \
--web.console.templates=/opt/prometheus/consoles \
--web.console.libraries=/opt/prometheus/console_libraries \
--web.listen-address=0.0.0.0:9090
[Install]
WantedBy=multi-user.target
EOF
# MariaDB exporter service
cat > /etc/systemd/system/mysqld_exporter.service << 'EOF'
[Unit]
Description=MariaDB Exporter for Prometheus
Wants=network-online.target
After=network-online.target
[Service]
User=mysqld_exporter
Group=mysqld_exporter
Type=simple
Restart=always
ExecStart=/usr/local/bin/mysqld_exporter \
--config.my-cnf=/etc/mysql/.mysqld_exporter.cnf \
--collect.global_status \
--collect.global_variables \
--collect.slave_status \
--collect.info_schema.processlist \
--collect.info_schema.tables
[Install]
WantedBy=multi-user.target
EOF
# Step 9: Configure firewall
echo -e "${YELLOW}[9/10] Configuring firewall...${NC}"
if command -v firewall-cmd &> /dev/null; then
firewall-cmd --permanent --add-port=9090/tcp --add-port=9104/tcp
firewall-cmd --reload
elif command -v ufw &> /dev/null; then
ufw allow 9090/tcp
ufw allow 9104/tcp
fi
# Step 10: Start services
echo -e "${YELLOW}[10/10] Starting services...${NC}"
systemctl daemon-reload
systemctl enable prometheus mysqld_exporter
systemctl start prometheus mysqld_exporter
# Verification
echo -e "${YELLOW}Verifying installation...${NC}"
sleep 5
if systemctl is-active --quiet prometheus; then
echo -e "${GREEN}✓ Prometheus is running${NC}"
else
echo -e "${RED}✗ Prometheus failed to start${NC}"
exit 1
fi
if systemctl is-active --quiet mysqld_exporter; then
echo -e "${GREEN}✓ MariaDB exporter is running${NC}"
else
echo -e "${RED}✗ MariaDB exporter failed to start${NC}"
exit 1
fi
echo -e "${GREEN}Installation completed successfully!${NC}"
echo -e "${YELLOW}Next steps:${NC}"
echo "1. Create the monitoring user on each MariaDB node:"
echo " mysql -u root -p"
echo " CREATE USER 'exporter'@'localhost' IDENTIFIED BY '$EXPORTER_PASSWORD';"
echo " GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost';"
echo " GRANT SELECT ON performance_schema.* TO 'exporter'@'localhost';"
echo " FLUSH PRIVILEGES;"
echo ""
echo "2. Install node_exporter on MariaDB nodes for system metrics"
echo "3. Access Prometheus at: http://$(hostname -I | awk '{print $1}'):9090"
echo "4. Configure Grafana to use Prometheus as datasource"
Review the script before running. Execute with: bash install.sh