In this lesson, you will learn how to bridge the gap between your MySQL/MariaDB server and telemetry dashboards by installing an external monitoring agent.
While command-line tools like SHOW ENGINE INNODB STATUS or Performance Schema queries provide excellent point-in-time snapshots, they don't natively "push" data to centralized visualization platforms. To gain historical observability, we use a sidecar agent—typically the mysqld_exporter—which acts as a translator between your database and time-series databases like Prometheus.
The Role of the Exporter
The agent functions as a dedicated HTTP server that runs alongside your database instance. When a telemetry system (like Prometheus) "scrapes" this agent, the agent connects to MySQL as a low-privileged user, executes a collection of performance queries, and converts the results into a machine-readable format.
Setting Up the Agent
-
Grant Permissions: Create a user with minimal privileges so the agent can safely pull metrics without risk to data integrity.
CREATE USER 'exporter'@'localhost' IDENTIFIED BY 'password' WITH MAX_USER_CONNECTIONS 3; GRANT PROCESS, REPLICATION CLIENT, SELECT ON *.* TO 'exporter'@'localhost'; -
Configure the Agent: You provide the agent with the connection string via environment variables or a configuration file. The agent then maps internal database counters (like
Threads_connectedorInnodb_buffer_pool_reads) into metrics that visualization tools can aggregate. -
Scraping: Once the agent is live, you add the instance to your telemetry configuration. If your agent is running on port 9104, your configuration tells the monitoring system to poll
http://your-db-host:9104/metricsevery few seconds.
By offloading the metric collection to an external agent, you prevent the monitoring process from cluttering your standard query logs and ensure that your performance data is consistently captured, regardless of whether you are currently logged into the database shell. This setup transforms raw, volatile database counters into persistent trends you can monitor in a Grafana dashboard.
Key Takeaway: External monitoring agents act as a standardized bridge, converting complex database internals into consistent, historical metrics that your telemetry stack can ingest and visualize.