Prometheus监控Kafka

这里只是对prometheus监控kafka的配置过程做个记录,方便以后查阅。

1.下载kafka_exporter

1
https://github.com/danielqsj/kafka_exporter

2.配置kafka_exporter

1
2
tar xf downloads/kafka_exporter-1.2.0.linux-amd64.tar.gz
mv -f kafka_exporter-1.2.0.linux-amd64 kafka_exporter

3.启动kafka_exporter

1
/work/admin/kafka_exporter/kafka_exporter --kafka.server=192.168.6.213:9092

4.prometheus配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
- job_name: 'kafka'
static_configs:
- targets: ['192.168.6.213:9100']
labels: {cluster: 'product',type: 'basic',env: 'kafka',job: 'kafka1',export: 'kafka'}
- targets: ['192.168.6.213:9308']
labels: {cluster: 'product',type: 'middle',env: 'kafka',job: 'kafka1',export: 'kafka_exporter'}
- targets: ['192.168.3.94:9100']
labels: {cluster: 'product',type: 'basic',env: 'kafka',job: 'kafka2',export: 'kafka'}
- targets: ['192.168.3.94:9308']
labels: {cluster: 'product',type: 'middle',env: 'kafka',job: 'kafka2',export: 'kafka_exporter'}
- targets: ['192.168.5.245:9100']
labels: {cluster: 'product',type: 'basic',env: 'kafka',job: 'kafka3',export: 'kafka'}
- targets: ['192.168.5.245:9308']
labels: {cluster: 'product',type: 'middle',env: 'kafka',job: 'kafka3',export: 'kafka_exporter'}

重启prometheus

如果开启了api管理功能,可以如下方式热加载配置

1
curl -X POST http://127.0.0.1:9090/-/reload

5.grafana出图

推荐使用7589

效果如下

-------------本文结束感谢您的阅读-------------