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.

  1. On the Kafka integration page, scroll to the Set up Grafana Alloy to use the Kafka integration section and copy the provided Alloy configuration snippet for Kafka.

  2. On the machine where Alloy is installed, open the Alloy configuration file:

    • Linux: /etc/alloy/config.alloy
    • macOS (Homebrew): /opt/homebrew/etc/alloy/config.alloy
    • Windows: C:\Program Files\GrafanaLabs\Alloy\config.alloy
    • Docker: Depends on your volume mount configuration

    For more information, refer to Grafana Alloy configuration file locations.

  3. Paste the Kafka configuration snippet into the config file, then update the targets list with your Kafka broker addresses and JMX ports. For example:

    targets = [{__address__ = "kafka-broker-1:9999"}, {__address__ = "kafka-broker-2:9999"}]
  4. 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.

  5. Restart the Alloy service to apply the new configuration:

    • Linux: sudo systemctl restart alloy
    • macOS: brew services restart alloy
    • Windows: Restart the Alloy service from Services Manager
  6. Check the Alloy logs to confirm the service restarted successfully and is connecting to your Kafka brokers.

In the next milestone, you install the pre-built Kafka dashboards and alerts.


More to explore (optional)

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


Troubleshooting

Explore the following troubleshooting topics if you need help:

Were you successful?


page 6 of 12