一 官方文档
Kafka-exporter的GitHub地址(包含了部署的helm chart和指标明细说明等):https://github.com/danielqsj/kafka_exporter
二 安装kafka-exporter
安装可以使用Github上的HelmChart直接安装。或者直接写yaml文件安装,如下:
kafka-exporter-deployment.yaml1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57apiVersion: apps/v1
kind: Deployment
metadata:
name: kafka-exporter
namespace: kube-system
labels:
k8s-app: kafka-exporter
spec:
selector:
matchLabels:
k8s-app: kafka-exporter
template:
metadata:
labels:
k8s-app: kafka-exporter
spec:
containers:
- name: kafka-exporter
image: danielqsj/kafka-exporter:v1.4.2
args: ["--kafka.server", "10.0.43.250:9092"]
livenessProbe:
failureThreshold: 1
httpGet:
path: /healthz
port: 9308
scheme: HTTP
initialDelaySeconds: 3
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 9
readinessProbe:
failureThreshold: 1
httpGet:
path: /healthz
port: 9308
scheme: HTTP
initialDelaySeconds: 3
periodSeconds: 15
successThreshold: 1
timeoutSeconds: 9
ports:
- containerPort: 9308
name: http
apiVersion: v1
kind: Service
metadata:
name: kafka-exporter
namespace: kube-system
spec:
ports:
- name: http
port: 9308
protocol: TCP
selector:
k8s-app: kafka-exporter
prometheus的configmap增加配置如下:1
2
3- job_name: 'kafka_cluster'
static_configs:
- targets: ['kafka-exporter:9308']
再通过命令 curl -XPOST http://[prometheus-host]:9090/-/reload
刷新Prometheus配置。
如果不想在Prometheus中增加configmap配置,也可在kafka-exporter的yaml文件中增加以下annotation,通过同一个k8s中部署的Prometheus的监控配置服务发现自动发现。1
2
3
4
5spec:
template:
metadata:
annotations:
prometheus.io/scrape: "true"