Set up comprehensive MariaDB monitoring with Prometheus mysqld_exporter metrics collection and Grafana visualization. Configure database performance alerts, query monitoring, and custom dashboards for production MariaDB instances.
Prerequisites
- Root or sudo access
- At least 2GB RAM
- Basic MariaDB knowledge
What this solves
MariaDB database monitoring provides visibility into query performance, connection usage, replication lag, and resource consumption. This tutorial shows you how to configure Prometheus with mysqld_exporter to collect MariaDB metrics and create Grafana dashboards with automated alerts for database health monitoring.
Step-by-step configuration
Update system packages
Start by updating your package manager to ensure you get the latest versions of all components.
sudo apt update && sudo apt upgrade -y
Install MariaDB 11.6
Install MariaDB server with the performance schema enabled for detailed monitoring capabilities.
sudo apt install -y mariadb-server mariadb-client
sudo systemctl enable --now mariadb
Secure MariaDB installation
Run the security script to set root password and remove test databases that could interfere with monitoring.
sudo mysql_secure_installation
Configure MariaDB for monitoring
Enable performance schema and slow query logging to provide detailed metrics for Prometheus collection.
[mysqld]
performance_schema = ON
performance-schema-instrument = 'stage/%=ON'
performance-schema-consumer-events-stages-current = ON
performance-schema-consumer-events-stages-history = ON
performance-schema-consumer-events-stages-history-long = ON
performance-schema-consumer-statements-digest = ON
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 2
log_queries_not_using_indexes = 1
Create monitoring database user
Create a dedicated MariaDB user for Prometheus mysqld_exporter with minimal privileges needed for metrics collection.
sudo mysql -u root -p
CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'StrongExporterPass123!';
GRANT PROCESS, REPLICATION CLIENT ON . TO 'exporter'@'localhost';
GRANT SELECT ON performance_schema.* TO 'exporter'@'localhost';
GRANT SELECT ON information_schema.* TO 'exporter'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Restart MariaDB service
Restart MariaDB to apply the performance schema and logging configuration changes.
sudo systemctl restart mariadb
sudo systemctl status mariadb
Install Prometheus
Download and install Prometheus server for metrics collection and storage.
cd /tmp
wget https://github.com/prometheus/prometheus/releases/download/v2.47.0/prometheus-2.47.0.linux-amd64.tar.gz
tar xzf prometheus-2.47.0.linux-amd64.tar.gz
sudo cp prometheus-2.47.0.linux-amd64/prometheus /usr/local/bin/
sudo cp prometheus-2.47.0.linux-amd64/promtool /usr/local/bin/
sudo mkdir -p /etc/prometheus /var/lib/prometheus
sudo cp -r prometheus-2.47.0.linux-amd64/consoles /etc/prometheus/
sudo cp -r prometheus-2.47.0.linux-amd64/console_libraries /etc/prometheus/
Create Prometheus user and directories
Set up a dedicated system user for Prometheus with correct ownership of data directories.
sudo useradd --system --no-create-home --shell /bin/false prometheus
sudo chown -R prometheus:prometheus /etc/prometheus /var/lib/prometheus
sudo chmod 755 /etc/prometheus /var/lib/prometheus
Install mysqld_exporter
Download and install the MySQL/MariaDB exporter that will collect database metrics for Prometheus.
cd /tmp
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 cp mysqld_exporter-0.15.0.linux-amd64/mysqld_exporter /usr/local/bin/
sudo chown prometheus:prometheus /usr/local/bin/mysqld_exporter
sudo chmod 755 /usr/local/bin/mysqld_exporter
Configure mysqld_exporter credentials
Create a configuration file with database connection details for the mysqld_exporter.
[client]
user=exporter
password=StrongExporterPass123!
host=localhost
port=3306
sudo chown prometheus:prometheus /etc/prometheus/mysqld_exporter.cnf
sudo chmod 600 /etc/prometheus/mysqld_exporter.cnf
Create mysqld_exporter systemd service
Set up the mysqld_exporter as a systemd service for automatic startup and management.
[Unit]
Description=MariaDB Exporter
Wants=network-online.target
After=network-online.target
Requires=mariadb.service
After=mariadb.service
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/mysqld_exporter --config.my-cnf=/etc/prometheus/mysqld_exporter.cnf --collect.info_schema.innodb_metrics --collect.info_schema.innodb_tablespaces --collect.info_schema.processlist --collect.perf_schema.tablelocks --collect.perf_schema.file_events --collect.perf_schema.eventswaits --collect.perf_schema.indexiowaits --collect.perf_schema.tableiowaits --collect.slave_lag_seconds
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
Configure Prometheus
Set up the main Prometheus configuration to scrape metrics from mysqld_exporter and define alerting rules.
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
- "mariadb_alerts.yml"
alerting:
alertmanagers:
- static_configs:
- targets:
- localhost:9093
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'mariadb'
static_configs:
- targets: ['localhost:9104']
scrape_interval: 10s
metrics_path: /metrics
Create MariaDB alerting rules
Define Prometheus alerting rules for common MariaDB issues like high connection usage and slow queries.
groups:
- name: mariadb_alerts
rules:
- alert: MariaDBDown
expr: mysql_up == 0
for: 1m
labels:
severity: critical
annotations:
summary: "MariaDB instance is down"
description: "MariaDB instance {{ $labels.instance }} has been down for more than 1 minute."
- alert: MariaDBHighConnections
expr: (mysql_global_status_threads_connected / mysql_global_variables_max_connections) * 100 > 80
for: 2m
labels:
severity: warning
annotations:
summary: "MariaDB high connection usage"
description: "MariaDB instance {{ $labels.instance }} is using {{ $value }}% of available connections."
- alert: MariaDBSlowQueries
expr: rate(mysql_global_status_slow_queries[5m]) > 5
for: 2m
labels:
severity: warning
annotations:
summary: "MariaDB slow query rate high"
description: "MariaDB instance {{ $labels.instance }} has {{ $value }} slow queries per second."
- alert: MariaDBInnoDBLogWaits
expr: rate(mysql_global_status_innodb_log_waits[5m]) > 0
for: 1m
labels:
severity: warning
annotations:
summary: "MariaDB InnoDB log waits detected"
description: "MariaDB instance {{ $labels.instance }} has InnoDB log waits, consider increasing innodb_log_file_size."
Create Prometheus systemd service
Configure Prometheus as a systemd service with proper resource limits and restart behavior.
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus/ --web.console.templates=/etc/prometheus/consoles --web.console.libraries=/etc/prometheus/console_libraries --web.listen-address=0.0.0.0:9090 --web.enable-lifecycle --storage.tsdb.retention.time=30d
Restart=always
RestartSec=5
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
Install Grafana
Add the Grafana repository and install the latest version for dashboard visualization.
sudo apt install -y software-properties-common wget
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
Enable and start all services
Start mysqld_exporter, Prometheus, and Grafana services and enable them for automatic startup.
sudo systemctl daemon-reload
sudo systemctl enable --now mysqld_exporter
sudo systemctl enable --now prometheus
sudo systemctl enable --now grafana-server
Configure firewall access
Open the necessary ports for Prometheus and Grafana web interfaces.
sudo ufw allow 9090/tcp comment "Prometheus"
sudo ufw allow 3000/tcp comment "Grafana"
sudo ufw reload
Configure Grafana data source
Access Grafana at http://your-server-ip:3000 with default login admin/admin. Add Prometheus as a data source.
Name: Prometheus
Type: Prometheus
URL: http://localhost:9090
Access: Server (default)
Scrape interval: 15s
Import MariaDB dashboard template
Create a comprehensive MariaDB monitoring dashboard with key performance indicators and alerts.
{
"dashboard": {
"title": "MariaDB Monitoring",
"panels": [
{
"title": "Database Status",
"type": "stat",
"targets": [{
"expr": "mysql_up",
"legendFormat": "MariaDB Up"
}]
},
{
"title": "Active Connections",
"type": "graph",
"targets": [{
"expr": "mysql_global_status_threads_connected",
"legendFormat": "Active Connections"
}]
},
{
"title": "Query Rate",
"type": "graph",
"targets": [{
"expr": "rate(mysql_global_status_queries[5m])",
"legendFormat": "Queries/sec"
}]
},
{
"title": "Slow Queries",
"type": "graph",
"targets": [{
"expr": "rate(mysql_global_status_slow_queries[5m])",
"legendFormat": "Slow Queries/sec"
}]
}
]
}
}
Verify your setup
Check that all services are running and collecting metrics properly.
sudo systemctl status mariadb mysqld_exporter prometheus grafana-server
curl http://localhost:9104/metrics | grep mysql_up
curl http://localhost:9090/api/v1/targets
ss -tlnp | grep -E ':(3000|9090|9104|3306)'
Verify MariaDB metrics collection:
curl -s http://localhost:9104/metrics | grep -E "mysql_(up|global_status_queries|global_status_threads_connected)"
prometheus --version
grafana-server --version
Configure custom alerts
Install Alertmanager
Set up Alertmanager to handle Prometheus alerts and send notifications.
cd /tmp
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 cp alertmanager-0.26.0.linux-amd64/alertmanager /usr/local/bin/
sudo cp alertmanager-0.26.0.linux-amd64/amtool /usr/local/bin/
sudo mkdir -p /etc/alertmanager /var/lib/alertmanager
sudo chown -R prometheus:prometheus /etc/alertmanager /var/lib/alertmanager
Configure Alertmanager
Set up email notifications for critical MariaDB alerts like database downtime and connection issues.
global:
smtp_smarthost: 'smtp.example.com:587'
smtp_from: 'alerts@example.com'
smtp_auth_username: 'alerts@example.com'
smtp_auth_password: 'YourEmailPassword'
route:
group_by: ['alertname']
group_wait: 10s
group_interval: 10s
repeat_interval: 1h
receiver: 'web.hook'
routes:
- match:
severity: critical
receiver: 'critical-email'
receivers:
- name: 'web.hook'
webhook_configs:
- url: 'http://127.0.0.1:5001/'
- name: 'critical-email'
email_configs:
- to: 'admin@example.com'
subject: 'MariaDB Alert: {{ .GroupLabels.alertname }}'
body: |
{{ range .Alerts }}
Alert: {{ .Annotations.summary }}
Description: {{ .Annotations.description }}
Instance: {{ .Labels.instance }}
{{ end }}
Create Alertmanager service
Configure Alertmanager as a systemd service for reliable alert handling.
[Unit]
Description=Alertmanager
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/alertmanager --config.file=/etc/alertmanager/alertmanager.yml --storage.path=/var/lib/alertmanager/ --web.listen-address=0.0.0.0:9093
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
Enable Alertmanager
Start the Alertmanager service and verify it's receiving alerts from Prometheus.
sudo systemctl daemon-reload
sudo systemctl enable --now alertmanager
sudo systemctl status alertmanager
Common issues
| Symptom | Cause | Fix |
|---|---|---|
| mysqld_exporter fails to connect | Wrong credentials or permissions | Verify user exists: mysql -u exporter -p -e "SELECT 1" |
| No metrics in Prometheus | Exporter not running or wrong port | Check service: sudo systemctl status mysqld_exporter |
| Grafana shows no data | Wrong Prometheus URL | Use http://localhost:9090 in data source |
| Permission denied on log files | Wrong file ownership | Fix ownership: sudo chown mysql:mysql /var/log/mysql/slow.log |
| Alerts not firing | Alertmanager not configured | Check config: amtool config check /etc/alertmanager/alertmanager.yml |
| High memory usage | Too many metrics collected | Reduce retention: --storage.tsdb.retention.time=15d |
Performance optimization
Optimize MariaDB for monitoring
Fine-tune MariaDB settings to balance monitoring visibility with performance impact.
[mysqld]
Performance Schema optimization
performance-schema-max-table-instances = 400
performance-schema-max-table-handles = 4000
performance-schema-events-statements-history-long-size = 1000
performance-schema-events-statements-history-size = 10
Query cache for read-heavy workloads
query_cache_type = 1
query_cache_size = 128M
query_cache_limit = 2M
Connection and buffer optimization
max_connections = 200
thread_cache_size = 16
table_open_cache = 2000
innodb_buffer_pool_size = 1G
Configure Prometheus retention
Adjust data retention and storage settings based on your monitoring requirements and disk space.
sudo systemctl edit prometheus
[Service]
ExecStart=
ExecStart=/usr/local/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus/ --web.console.templates=/etc/prometheus/consoles --web.console.libraries=/etc/prometheus/console_libraries --web.listen-address=0.0.0.0:9090 --web.enable-lifecycle --storage.tsdb.retention.time=30d --storage.tsdb.retention.size=10GB
sudo systemctl daemon-reload
sudo systemctl restart prometheus
Advanced dashboard configuration
You can also explore existing MariaDB dashboard templates and customize them for your specific monitoring needs. The MySQL monitoring tutorial covers additional dashboard patterns that work well with MariaDB. For clustered setups, consider implementing the monitoring patterns from the MariaDB Galera cluster tutorial.
Next steps
- Monitor MariaDB Galera cluster performance and replication health
- Configure automated MariaDB backup monitoring with retention alerts
- Set up advanced MariaDB query performance analysis and slow query tracking
- Monitor MariaDB replication lag and master-slave health metrics
Running this in production?
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'
# Configuration variables
EXPORTER_PASSWORD="${EXPORTER_PASSWORD:-$(openssl rand -base64 32)}"
PROMETHEUS_VERSION="2.47.0"
MYSQLD_EXPORTER_VERSION="0.15.0"
# Usage function
usage() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -p, --password PASSWORD Set custom exporter password (default: auto-generated)"
echo " -h, --help Show this help message"
exit 1
}
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
-p|--password)
EXPORTER_PASSWORD="$2"
shift 2
;;
-h|--help)
usage
;;
*)
echo -e "${RED}Unknown option: $1${NC}"
usage
;;
esac
done
# Error cleanup function
cleanup() {
echo -e "${RED}Installation failed. Cleaning up...${NC}"
systemctl stop prometheus mariadb mysqld_exporter 2>/dev/null || true
userdel prometheus 2>/dev/null || true
rm -rf /etc/prometheus /var/lib/prometheus /usr/local/bin/prometheus /usr/local/bin/promtool /usr/local/bin/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 OS and set package manager
echo -e "${YELLOW}[1/12] Detecting operating system...${NC}"
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"
MARIADB_CONFIG="/etc/mysql/mariadb.conf.d/50-server.cnf"
MYSQL_LOG_DIR="/var/log/mysql"
;;
almalinux|rocky|centos|rhel|ol|fedora)
PKG_MGR="dnf"
PKG_INSTALL="dnf install -y"
PKG_UPDATE="dnf update -y"
MARIADB_CONFIG="/etc/my.cnf.d/mariadb-server.cnf"
MYSQL_LOG_DIR="/var/log/mariadb"
;;
amzn)
PKG_MGR="yum"
PKG_INSTALL="yum install -y"
PKG_UPDATE="yum update -y"
MARIADB_CONFIG="/etc/my.cnf.d/mariadb-server.cnf"
MYSQL_LOG_DIR="/var/log/mariadb"
;;
*)
echo -e "${RED}Unsupported distribution: $ID${NC}"
exit 1
;;
esac
echo -e "${GREEN}Detected: $PRETTY_NAME${NC}"
else
echo -e "${RED}Cannot detect OS. /etc/os-release not found.${NC}"
exit 1
fi
# Update system packages
echo -e "${YELLOW}[2/12] Updating system packages...${NC}"
$PKG_UPDATE
# Install MariaDB
echo -e "${YELLOW}[3/12] Installing MariaDB 11.6...${NC}"
if [[ "$PKG_MGR" == "apt" ]]; then
$PKG_INSTALL mariadb-server mariadb-client
else
$PKG_INSTALL mariadb-server mariadb
fi
systemctl enable --now mariadb
echo -e "${GREEN}MariaDB installed and started${NC}"
# Create MySQL log directory
echo -e "${YELLOW}[4/12] Configuring directories...${NC}"
mkdir -p "$MYSQL_LOG_DIR"
chown mysql:mysql "$MYSQL_LOG_DIR"
chmod 755 "$MYSQL_LOG_DIR"
# Configure MariaDB for monitoring
echo -e "${YELLOW}[5/12] Configuring MariaDB for monitoring...${NC}"
cat > /etc/mysql/conf.d/monitoring.cnf << 'EOF'
[mysqld]
performance_schema = ON
performance-schema-instrument = 'stage/%=ON'
performance-schema-consumer-events-stages-current = ON
performance-schema-consumer-events-stages-history = ON
performance-schema-consumer-events-stages-history-long = ON
performance-schema-consumer-statements-digest = ON
slow_query_log = 1
long_query_time = 2
log_queries_not_using_indexes = 1
EOF
if [[ "$PKG_MGR" == "apt" ]]; then
echo "slow_query_log_file = /var/log/mysql/slow.log" >> /etc/mysql/conf.d/monitoring.cnf
else
echo "slow_query_log_file = /var/log/mariadb/slow.log" >> /etc/mysql/conf.d/monitoring.cnf
fi
chown root:root /etc/mysql/conf.d/monitoring.cnf
chmod 644 /etc/mysql/conf.d/monitoring.cnf
# Restart MariaDB
echo -e "${YELLOW}[6/12] Restarting MariaDB...${NC}"
systemctl restart mariadb
systemctl status mariadb --no-pager -l
# Create monitoring user
echo -e "${YELLOW}[7/12] Creating monitoring database user...${NC}"
mysql -u root << EOF
CREATE USER IF NOT EXISTS 'exporter'@'localhost' IDENTIFIED BY '$EXPORTER_PASSWORD';
GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'exporter'@'localhost';
GRANT SELECT ON performance_schema.* TO 'exporter'@'localhost';
GRANT SELECT ON information_schema.* TO 'exporter'@'localhost';
FLUSH PRIVILEGES;
EOF
echo -e "${GREEN}Database user created${NC}"
# Install Prometheus
echo -e "${YELLOW}[8/12] Installing Prometheus...${NC}"
cd /tmp
wget -q "https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz"
tar xzf "prometheus-${PROMETHEUS_VERSION}.linux-amd64.tar.gz"
cp "prometheus-${PROMETHEUS_VERSION}.linux-amd64/prometheus" /usr/local/bin/
cp "prometheus-${PROMETHEUS_VERSION}.linux-amd64/promtool" /usr/local/bin/
mkdir -p /etc/prometheus /var/lib/prometheus
cp -r "prometheus-${PROMETHEUS_VERSION}.linux-amd64/consoles" /etc/prometheus/
cp -r "prometheus-${PROMETHEUS_VERSION}.linux-amd64/console_libraries" /etc/prometheus/
# Create Prometheus user
echo -e "${YELLOW}[9/12] Creating Prometheus user...${NC}"
useradd --system --no-create-home --shell /bin/false prometheus || true
chown -R prometheus:prometheus /etc/prometheus /var/lib/prometheus /usr/local/bin/prometheus /usr/local/bin/promtool
chmod 755 /etc/prometheus /var/lib/prometheus /usr/local/bin/prometheus /usr/local/bin/promtool
# Install mysqld_exporter
echo -e "${YELLOW}[10/12] Installing mysqld_exporter...${NC}"
wget -q "https://github.com/prometheus/mysqld_exporter/releases/download/v${MYSQLD_EXPORTER_VERSION}/mysqld_exporter-${MYSQLD_EXPORTER_VERSION}.linux-amd64.tar.gz"
tar xzf "mysqld_exporter-${MYSQLD_EXPORTER_VERSION}.linux-amd64.tar.gz"
cp "mysqld_exporter-${MYSQLD_EXPORTER_VERSION}.linux-amd64/mysqld_exporter" /usr/local/bin/
chown prometheus:prometheus /usr/local/bin/mysqld_exporter
chmod 755 /usr/local/bin/mysqld_exporter
# Configure mysqld_exporter
echo -e "${YELLOW}[11/12] Configuring services...${NC}"
cat > /etc/prometheus/mysqld_exporter.cnf << EOF
[client]
user=exporter
password=$EXPORTER_PASSWORD
host=localhost
port=3306
EOF
chown prometheus:prometheus /etc/prometheus/mysqld_exporter.cnf
chmod 600 /etc/prometheus/mysqld_exporter.cnf
# Create systemd services
cat > /etc/systemd/system/mysqld_exporter.service << 'EOF'
[Unit]
Description=MySQL Exporter
After=network.target
[Service]
Type=simple
User=prometheus
Group=prometheus
ExecStart=/usr/local/bin/mysqld_exporter --config.my-cnf=/etc/prometheus/mysqld_exporter.cnf
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
cat > /etc/prometheus/prometheus.yml << 'EOF'
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'mysqld'
static_configs:
- targets: ['localhost:9104']
EOF
chown prometheus:prometheus /etc/prometheus/prometheus.yml
chmod 644 /etc/prometheus/prometheus.yml
cat > /etc/systemd/system/prometheus.service << 'EOF'
[Unit]
Description=Prometheus Server
After=network.target
[Service]
Type=simple
User=prometheus
Group=prometheus
ExecStart=/usr/local/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus --web.console.templates=/etc/prometheus/consoles --web.console.libraries=/etc/prometheus/console_libraries
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
# Start services
echo -e "${YELLOW}[12/12] Starting services...${NC}"
systemctl daemon-reload
systemctl enable --now mysqld_exporter prometheus
# Verification
echo -e "${YELLOW}Verifying installation...${NC}"
sleep 5
if systemctl is-active --quiet mariadb; then
echo -e "${GREEN}✓ MariaDB is running${NC}"
else
echo -e "${RED}✗ MariaDB is not running${NC}"
fi
if systemctl is-active --quiet prometheus; then
echo -e "${GREEN}✓ Prometheus is running${NC}"
else
echo -e "${RED}✗ Prometheus is not running${NC}"
fi
if systemctl is-active --quiet mysqld_exporter; then
echo -e "${GREEN}✓ mysqld_exporter is running${NC}"
else
echo -e "${RED}✗ mysqld_exporter is not running${NC}"
fi
# Final information
echo -e "\n${GREEN}Installation completed successfully!${NC}"
echo -e "${YELLOW}Access Information:${NC}"
echo "- Prometheus: http://localhost:9090"
echo "- mysqld_exporter metrics: http://localhost:9104/metrics"
echo "- Exporter password: $EXPORTER_PASSWORD"
echo -e "\n${YELLOW}Next Steps:${NC}"
echo "1. Install Grafana for visualization"
echo "2. Import MariaDB dashboard templates"
echo "3. Configure alerting rules"
echo "4. Set up firewall rules if needed"
rm -rf /tmp/prometheus-* /tmp/mysqld_exporter-*
Review the script before running. Execute with: bash install.sh