mariadb_exporter
MariaDB metrics exporter for Prometheus written in Rust.
Goals
mariadb_exporter focuses on DBRE-friendly, selective metrics:
- Modular collectors – Enable only what you need; heavy/optional plugins stay off by default.
- Compatibility – Metric names align with Prometheus
mysqld_exporter(prefixedmariadb_). - Lean defaults – Useful availability/innodb/replication basics on by default; optional collectors gated.
- Low footprint – Avoid unnecessary cardinality and expensive scans.
Download or build
Install via Cargo:
Usage
Run the exporter:
Change port (default 9306):
Common DSN formats:
- TCP:
mysql://user:password@host:3306/database - Unix socket:
mysql:///mysql?socket=/var/run/mysqld/mysqld.sock&user=exporter - TLS required:
mysql://user@host/mysql?ssl-mode=REQUIRED - TLS verify identity:
mysql://user@host/mysql?ssl-mode=VERIFY_IDENTITY&ssl-ca=/path/to/ca.pem
Available collectors
Collectors are toggled with --collector.<name> or --no-collector.<name>.
--collector.default(enabled) – Core status (uptime, threads, connections, traffic), InnoDB basics, replication basics, binlog stats, config flags, version,mariadb_up.--collector.exporter(enabled) – Exporter self-metrics (process, scrape, cardinality).--collector.tls– TLS session + cipher info.--collector.query_response_time– Buckets fromquery_response_timeplugin.--collector.audit– Audit plugin status.--collector.statements– Statement digest summaries/top latency fromperformance_schema.--collector.schema– Table size/row estimates (largest 20 non-system tables).--collector.replication– Relay log size/pos, binlog file count.--collector.locks– Metadata/table lock waits fromperformance_schema.--collector.metadata–metadata_lock_infotable counts.--collector.userstat– Per-user stats (requires@@userstat=1andUSER_STATISTICS).
Enabled by default
defaultexporter
Everything else is opt-in.
Project layout
mariadb_exporter
├── bin
├── cli
├── collectors
│ ├── audit
│ ├── config.rs
│ ├── default
│ ├── exporter
│ ├── locks
│ ├── metadata
│ ├── mod.rs
│ ├── query_response_time
│ ├── register_macro.rs
│ ├── registry.rs
│ ├── replication
│ ├── schema
│ ├── statements
│ ├── tls
│ ├── userstat
│ └── util.rs
└── src/lib.rs
Each collector lives in its own subdirectory for clarity and easy extension.
Testing
Run tests:
Run with container-backed integration (requires podman/docker):
Lint:
Notes
- User statistics: enable with
SET GLOBAL userstat=ON;(or@@userstat=1) to exposeuserstatmetrics. - Metadata locks: load
metadata_lock_infoplugin for themetadatacollector. - Performance schema is needed for statements/locks collectors to return data.
- Optional collectors skip gracefully when prerequisites aren’t present.***