---
title: "Configure Alloy for Kafka metrics | Grafana Labs"
description: "Learn how to configure Grafana Alloy to collect metrics from your Kafka brokers."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# 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](/docs/alloy/latest/configure/).
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:
   
   ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```none
   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:

- [Configure Grafana Alloy](/docs/alloy/latest/configure/)
- [Prometheus Kafka receiver component reference](/docs/alloy/latest/reference/components/prometheus/prometheus.exporter.kafka/)

* * *

### Troubleshooting

Explore the following troubleshooting topics if you need help:

- [Alloy service fails to restart or shows configuration errors](/docs/grafana-cloud/monitor-infrastructure/integrations/troubleshoot/install-troubleshoot-linux-alloy/#alloy-service-fails-to-start)
- [Configuration file syntax errors](/docs/alloy/latest/configure/)
- [Cannot connect to Kafka JMX endpoints](/docs/grafana-cloud/monitor-infrastructure/integrations/troubleshoot/)
