Prometheus MySQL Exporter

We use mysqld_exporter as a Prometheus exporter for MySQL server metrics.

mysqld_exporter is a platform specific binary which must be deployed on the server where mysqld is running. It basically provides an HTTP endpoint with all the statistics related to the database. This end point is fetched/requested by Prometheus on a periodic basis.

The set up is very straight forward.

Download the appropriate binary, usually mysqld_exporter-*.*.*.linux-amd64.tar.gz

uncompress the archive and set the environment variable as follows:

export DATA_SOURCE_NAME='login:password@(hostname:port)/'

Then execute the binary:

./mysqld_exporter <flags>

Prometheus Configuration

Once mysqld_exporter is running and it is confirmed that the endpoint is available, we can configure Prometheus as follows:

  - job_name: 'mysql performance'
    scrape_interval: 5m
    static_configs:
      - targets:
        - '10.91.100.125:9104'  #sfqadb1

Note: Due to Errigal's large database size, A single scrape requests takes a few seconds on the server and may hamper the speed of other running applications. Hence it is optimal to keep the scrape interval to 5 minutes or above.

Here is an extensive list of examples of rules that could be applied: Example Rules

For more information on how to setup your own rules in the Errigal environment, refer: prometheus-monitoring-config