Bootstrap

部署kafka-exporter

docker容器部署

docker run -d --name=grafana -v /etc/localtime:/etc/localtime:ro --restart=always -p 23000:3000 grafana/grafana

docker run -d --name=prometheus -p 29090:9090 --restart=always -v /etc/localtime:/etc/localtime:ro  -v /home/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml  prom/prometheus




docker run -itd --name=zookeeper -p 22181:2181 --restart=always -e ALLOW_ANONYMOUS_LOGIN=yes bitnami/zookeeper:3

docker run -itd --restart=always --name=kafka -p 29092:9092 -p 5555:5555 -e KAFKA_CFG_ZOOKEEPER_CONNECT=172.17.0.5:2181 -e ALLOW_PLAINTEXT_LISTENER=yes -e JMX_PORT=5555 bitnami/kafka:2

docker run -itd  --name=kafka-manager -p 29500:9000 -e ZK_HOSTS="172.17.0.6:2181" sheepkiller/kafka-manager

docker run -itd  --restart=always  --name kafka-exporter -p 29308:9308 danielqsj/kafka-exporter --kafka.server=172.17.0.6:9092 --kafka.version=2.8.0

docker run -itd -p 5556:5556 --restart=always --name jmx-exporter -v /home/jmx-exporter/httpserver_sample_config.yml:/opt/bitnami/jmx-exporter/example_configs/httpserver_sample_config.yml harbor.ceclouddyn.com/cmq/jmx-exporter:0.16.1-debian-10-r43


/home/prometheus/prometheus.yml
scrape_configs:
  - job_name: 'prometheus'
    static_configs:
    - targets: ['localhost:29090']
  - job_name: 'kafka'
    static_configs:
    - targets: ['192.168.109.131:29308']
      labels:
        instance: 192.168.109.131

k8s部署


apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/component: metrics
    app.kubernetes.io/instance: wb-kafka-48d5058787c84f71
    app.kubernetes.io/name: wb-kafka-48d5058787c84f71
  name: wb-kafka-48d5058787c84f71-exporter
  namespace: wb
spec:
  selector:
    matchLabels:
      app.kubernetes.io/component: metrics
      app.kubernetes.io/instance: wb-kafka-48d5058787c84f71
      app.kubernetes.io/name: wb-kafka-48d5058787c84f71
  template:
    metadata:
      labels:
        app.kubernetes.io/component: metrics
        app.kubernetes.io/instance: wb-kafka-48d5058787c84f71
        app.kubernetes.io/name: wb-kafka-48d5058787c84f71
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: role/tenants-wb
                operator: In
                values:
                - "true"
      containers:
      - args:
        - --kafka.server=wb-kafka-48d5058787c84f71:9092
        - --web.listen-address=:9308
        - --kafka.labels=instance=wb-kafka-48d5058787c84f71,instanceType=kafka
        image: harbor.wb.com/wb/kafka-exporter:1.3.1
        imagePullPolicy: Always
        name: kafka-exporter
        ports:
        - containerPort: 9308
          name: metrics
          protocol: TCP
        resources:
          limits:
            cpu: 100m
            memory: 128Mi
          requests:
            cpu: 100m
            memory: 128Mi

---

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    app.kubernetes.io/component: metrics
    app.kubernetes.io/instance: wb-kafka-48d5058787c84f71
    app.kubernetes.io/name: wb-kafka-48d5058787c84f71
  name: wb-kafka-48d5058787c84f71-exporter-servicemonitor
  namespace: wb
spec:
  endpoints:
  - honorLabels: true
    path: /metrics
    port: metrics
    scrapeTimeout: 25s
  namespaceSelector:
    matchNames:
    - wb
  selector:
    matchLabels:
      app.kubernetes.io/component: metrics
      app.kubernetes.io/instance: wb-kafka-48d5058787c84f71
      app.kubernetes.io/name: wb-kafka-48d5058787c84f71



;