Configure Alloy for Kafka metrics
Grafana Alloy collects Kafka metrics by scraping JMX metrics from your Kafka brokers. This requires adding a Kafka integration configuration block to the Alloy config file, which tells Alloy where to find your brokers, how often to collect metrics, and where to send the collected data.
The key configuration parameters include broker endpoints with their JMX ports, scrape intervals that determine how frequently metrics are collected, and Grafana Cloud remote write settings that enable metrics forwarding. The configuration provided through Grafana Cloud comes pre-populated with your stack-specific connection details.
To configure Grafana Alloy for Kafka metrics collection, complete the following steps:
In the Grafana Cloud Kafka integration page, locate the Configure Grafana Alloy section.
Copy the provided Alloy configuration snippet for Kafka.
On the machine where Alloy is installed, open the Alloy configuration file:
- Linux:
/etc/alloy/config.alloy - macOS:
/opt/homebrew/etc/alloy/config.alloy(Homebrew) or/usr/local/etc/alloy/config.alloy - Windows:
C:\Program Files\GrafanaLabs\Alloy\config.alloy - Docker: The configuration file location depends on your volume mount configuration
For more information, refer to Grafana Alloy configuration file locations.
- Linux:
Paste the Kafka configuration snippet into the config file.
Update the targets list with your Kafka broker addresses and JMX ports.
For example, replace the placeholder with:
targets = [{__address__ = "kafka-broker-1:9999"}, {__address__ = "kafka-broker-2:9999"}]Review the forward_to parameter to ensure it points to your Grafana Cloud remote write endpoint.
Optionally, adjust the scrape_interval (default is typically 60s).
Save the configuration file.
Restart the Alloy service using the command:
sudo systemctl restart alloy(on Linux) or the appropriate command for your platform.
The Alloy service restarts successfully without configuration errors. Check the Alloy logs for successful connection messages to your Kafka brokers.
In the next milestone, you verify that Kafka metrics are flowing to Grafana Cloud.
Troubleshooting options
Please tell us what didn't work:
At this point in your journey, you can explore the following paths:
