Configure Grafana Alloy for MySQL monitoring

In this milestone, you configure Grafana Alloy using the configuration snippets provided by the MySQL integration. These snippets enable Grafana Alloy to collect MySQL metrics and logs and send them to your Grafana Cloud instance.

The configuration includes components for MySQL metrics collection using the Prometheus MySQL exporter component and log collection using Loki source file components. You’ll customize the configuration with your MySQL connection details and ensure secure credential handling.

To configure Grafana Alloy for MySQL monitoring, complete the following steps:

  1. On the MySQL integration page in Grafana Cloud, scroll to the Set up Grafana Alloy to use the MySQL integration section.

  2. At the bottom of the snippet, click Copy to clipboard.

  3. Open the Grafana Alloy configuration file on your system.

    For example, on a Linux machine, run:

    sudo nano /etc/alloy/config.alloy
  4. Paste the integration snippet into the configuration file.

  5. Update the data_source_name parameter with your MySQL connection details:

    For example, alloy_monitor:secure_password@(localhost:3306)/.

  6. Review the log path in the logs configuration and update it if necessary:

    • For Linux systems, the default path is /var/log/mysql/*.log.
    • For Windows systems, the default path is C:\ProgramData\MySQL\MySQL Server*\Data\*.log.
  7. Save the configuration file and exit the editor.

  8. Restart the Grafana Alloy service to apply the configuration:

    On Linux, run the command:

    sudo systemctl restart alloy
  9. Check the service status to ensure it started successfully:

    On Linux, run the command:

    sudo systemctl status alloy

The Grafana Alloy service should restart successfully and begin collecting MySQL metrics and logs based on your configuration.

In the next milestone, you test the connection to verify that data is being collected and sent to Grafana Cloud.

Were you successful?

More to explore (optional)

At this point in your journey, you can explore the following paths:

Configure Grafana Alloy to collect all metrics and logs (advanced)

Configure Grafana Alloy

Logs and relabeling basics in Grafana Alloy (tutorial)

Grafana Alloy configuration reference


page 6 of 10