docker容器部署
docker run -d --name=grafana -v /etc/localtime:/etc/localtime:ro --restart=always -p 23000:3000 grafana/grafanadocker 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/prometheusdocker run -itd --name=zookeeper -p 22181:2181 --restart=always -e ALLOW_ANONYMOUS_LOGIN=yes bitnami/zookeeper:3docker 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:2docker run -itd --name=kafka-manager -p 29500:9000 -e ZK_HOSTS="172.17.0.6:2181" sheepkiller/kafka-managerdocker run -itd --restart=always --name kafka-exporter -p 29308:9308 danielqsj/kafka-exporter --kafka.server=172.17.0.6:9092 --kafka.version=2.8.0docker 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: metricsapp.kubernetes.io/instance: wb-kafka-48d5058787c84f71app.kubernetes.io/name: wb-kafka-48d5058787c84f71name: wb-kafka-48d5058787c84f71-exporternamespace: wb
spec:selector:matchLabels:app.kubernetes.io/component: metricsapp.kubernetes.io/instance: wb-kafka-48d5058787c84f71app.kubernetes.io/name: wb-kafka-48d5058787c84f71template:metadata:labels:app.kubernetes.io/component: metricsapp.kubernetes.io/instance: wb-kafka-48d5058787c84f71app.kubernetes.io/name: wb-kafka-48d5058787c84f71spec:affinity:nodeAffinity:requiredDuringSchedulingIgnoredDuringExecution:nodeSelectorTerms:- matchExpressions:- key: role/tenants-wboperator: Invalues:- "true"containers:- args:- --kafka.server=wb-kafka-48d5058787c84f71:9092- --web.listen-address=:9308- --kafka.labels=instance=wb-kafka-48d5058787c84f71,instanceType=kafkaimage: harbor.wb.com/wb/kafka-exporter:1.3.1imagePullPolicy: Alwaysname: kafka-exporterports:- containerPort: 9308name: metricsprotocol: TCPresources:limits:cpu: 100mmemory: 128Mirequests:cpu: 100mmemory: 128Mi---apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:labels:app.kubernetes.io/component: metricsapp.kubernetes.io/instance: wb-kafka-48d5058787c84f71app.kubernetes.io/name: wb-kafka-48d5058787c84f71name: wb-kafka-48d5058787c84f71-exporter-servicemonitornamespace: wb
spec:endpoints:- honorLabels: truepath: /metricsport: metricsscrapeTimeout: 25snamespaceSelector:matchNames:- wbselector:matchLabels:app.kubernetes.io/component: metricsapp.kubernetes.io/instance: wb-kafka-48d5058787c84f71app.kubernetes.io/name: wb-kafka-48d5058787c84f71