diff --git a/docker-compose.yml b/docker-compose.yml index c85a0b7..2da921c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,9 +7,13 @@ services: volumes: - "$PWD/kafka_distr:/opt/kafka" - "$PWD/zookeeper/data/zoo1:/opt/zookeeper" + - "$PWD/prometheus:/opt/prometheus" hostname: zoo1 networks: - kafka-lab + environment: + JMX_PORT: 9093 + EXTRA_ARGS: "-javaagent:/opt/prometheus/jmx_prometheus_javaagent-0.15.0.jar=16100:/opt/prometheus/zookeeper.yml" zoo2: build: zookeeper ports: @@ -17,9 +21,13 @@ services: volumes: - "$PWD/kafka_distr:/opt/kafka" - "$PWD/zookeeper/data/zoo2:/opt/zookeeper" + - "$PWD/prometheus:/opt/prometheus" hostname: zoo2 networks: - kafka-lab + environment: + JMX_PORT: 9093 + EXTRA_ARGS: "-javaagent:/opt/prometheus/jmx_prometheus_javaagent-0.15.0.jar=16100:/opt/prometheus/zookeeper.yml" zoo3: build: zookeeper ports: @@ -27,15 +35,22 @@ services: volumes: - "$PWD/kafka_distr:/opt/kafka" - "$PWD/zookeeper/data/zoo3:/opt/zookeeper" + - "$PWD/prometheus:/opt/prometheus" hostname: zoo3 networks: - kafka-lab + environment: + JMX_PORT: 9093 + EXTRA_ARGS: "-javaagent:/opt/prometheus/jmx_prometheus_javaagent-0.15.0.jar=16100:/opt/prometheus/zookeeper.yml" kafka1: build: kafka_server + ports: + - "127.0.0.21:16100:16100" volumes: - "$PWD/kafka_distr:/opt/kafka" - "$PWD/kafka_server/logs1:/logs/kafka" + - "$PWD/prometheus:/opt/prometheus" depends_on: - zoo1 - zoo2 @@ -45,12 +60,16 @@ services: - kafka-lab environment: JMX_PORT: 9093 + EXTRA_ARGS: "-javaagent:/opt/prometheus/jmx_prometheus_javaagent-0.15.0.jar=16100:/opt/prometheus/kafka_broker.yml" command: ["bin/kafka-server-start.sh", "config/server.properties", "--override", "broker.id=1"] kafka2: build: kafka_server + ports: + - "127.0.0.22:16100:16100" volumes: - "$PWD/kafka_distr:/opt/kafka" - "$PWD/kafka_server/logs2:/logs/kafka" + - "$PWD/prometheus:/opt/prometheus" depends_on: - zoo1 - zoo2 @@ -60,12 +79,16 @@ services: - kafka-lab environment: JMX_PORT: 9093 + EXTRA_ARGS: "-javaagent:/opt/prometheus/jmx_prometheus_javaagent-0.15.0.jar=16100:/opt/prometheus/kafka_broker.yml" command: ["bin/kafka-server-start.sh", "config/server.properties", "--override", "broker.id=2"] kafka3: build: kafka_server + ports: + - "127.0.0.23:16100:16100" volumes: - "$PWD/kafka_distr:/opt/kafka" - "$PWD/kafka_server/logs3:/logs/kafka" + - "$PWD/prometheus:/opt/prometheus" depends_on: - zoo1 - zoo2 @@ -75,6 +98,7 @@ services: - kafka-lab environment: JMX_PORT: 9093 + EXTRA_ARGS: "-javaagent:/opt/prometheus/jmx_prometheus_javaagent-0.15.0.jar=16100:/opt/prometheus/kafka_broker.yml" command: ["bin/kafka-server-start.sh", "config/server.properties", "--override", "broker.id=3"] phpfront1: diff --git a/prometheus/jmx_prometheus_javaagent-0.15.0.jar b/prometheus/jmx_prometheus_javaagent-0.15.0.jar new file mode 100644 index 0000000..d896a21 Binary files /dev/null and b/prometheus/jmx_prometheus_javaagent-0.15.0.jar differ diff --git a/prometheus/kafka_broker.yml b/prometheus/kafka_broker.yml new file mode 100644 index 0000000..04381e5 --- /dev/null +++ b/prometheus/kafka_broker.yml @@ -0,0 +1,69 @@ +lowercaseOutputName: true +rules: +# Special cases and very specific rules +- pattern : kafka.server<>Value + name: kafka_server_$1_$2 + type: GAUGE + labels: + clientId: "$3" + topic: "$4" + partition: "$5" +- pattern : kafka.server<>Value + name: kafka_server_$1_$2 + type: GAUGE + labels: + clientId: "$3" + broker: "$4:$5" + +- pattern : kafka.server<>OneMinuteRate + name: kafka_server_kafkarequesthandlerpool_requesthandleravgidlepercent_total + type: GAUGE + +- pattern : kafka.server<>connections + name: kafka_server_socketservermetrics_connections + type: GAUGE + labels: + client_software_name: "$1" + client_software_version: "$2" + listener: "$3" + network_processor: "$4" + +- pattern : 'kafka.server<>(.+):' + name: kafka_server_socketservermetrics_$3 + type: GAUGE + labels: + listener: "$1" + network_processor: "$2" + +# Count and Value +- pattern: kafka.(.*)<>(Count|Value) + name: kafka_$1_$2_$3 + labels: + "$4": "$5" + "$6": "$7" +- pattern: kafka.(.*)<>(Count|Value) + name: kafka_$1_$2_$3 + labels: + "$4": "$5" +- pattern: kafka.(.*)<>(Count|Value) + name: kafka_$1_$2_$3 + +# Percentile +- pattern: kafka.(.*)<>(\d+)thPercentile + name: kafka_$1_$2_$3 + type: GAUGE + labels: + "$4": "$5" + "$6": "$7" + quantile: "0.$8" +- pattern: kafka.(.*)<>(\d+)thPercentile + name: kafka_$1_$2_$3 + type: GAUGE + labels: + "$4": "$5" + quantile: "0.$6" +- pattern: kafka.(.*)<>(\d+)thPercentile + name: kafka_$1_$2_$3 + type: GAUGE + labels: + quantile: "0.$4" diff --git a/prometheus/zookeeper.yml b/prometheus/zookeeper.yml new file mode 100644 index 0000000..e62e9dd --- /dev/null +++ b/prometheus/zookeeper.yml @@ -0,0 +1,87 @@ +--- +lowercaseOutputName: true +lowercaseOutputLabelNames: true +whitelistObjectNames: + - org.apache.ZooKeeperService:name3=Connections,* + - org.apache.ZooKeeperService:name3=InMemoryDataTree,* + - org.apache.ZooKeeperService:name0=*,name1=replica*,name2=* + - org.apache.ZooKeeperService:name0=*,name1=replica* + - org.apache.ZooKeeperService:name0=* + # If you are running a Standalone Zookeeper, the whitelist objects below would help. + # If the zookeeper has a quorum, no need to worry about anything else. + - org.apache.ZooKeeperService:name1=InMemoryDataTree,name0=* + - org.apache.ZooKeeperService:name0=*,name1=Connections,name2=*,name3=* +rules: + # Below rule applies for Zookeeper Cluster having multiple ZK nodes + # org.apache.ZooKeeperService:name0=*,name3=Connections,name1=*,name2=*,name4=*,name5=* + - pattern: "org.apache.ZooKeeperService<>([^:]+)" + name: zookeeper_connections_$6 + labels: + server_name: "$1" + server_id: $2 + client_address: "$4" + connection_id: "$5" + member_type: "$3" + - pattern: "org.apache.ZooKeeperService<>(\\w+): (\\d+)" + name: zookeeper_$4 + labels: + server_name: "$1" + server_id: $2 + member_type: "$3" + # Below rule applies for Zookeeper Cluster having multiple ZK nodes + # org.apache.ZooKeeperService:name0=*,name3=InMemoryDataTree + - pattern: "org.apache.ZooKeeperService<>(WatchCount|NodeCount): (\\d+)" + name: zookeeper_inmemorydatatree_$4 + type: GAUGE + labels: + server_name: "$1" + server_id: $2 + member_type: "$3" + # Below rule applies for Zookeeper Cluster having multiple ZK nodes + # org.apache.ZooKeeperService:name0=*,name1=replica* + - pattern: "org.apache.ZooKeeperService<>(.+): (.+)" + name: zookeeper_status + type: UNTYPED + value: 1 + labels: + server_name: "$1" + server_id: $2 + $3: $4 + # Below rule applies for Zookeeper Cluster having multiple ZK nodes + # org.apache.ZooKeeperService:name0=* + - pattern: "org.apache.ZooKeeperService<>(QuorumSize): (\\d+)" + name: zookeeper_status_$2 + type: GAUGE + labels: + server_id: $1 + # ########################################################################### + # ########################################################################### + # Below rule applies to a Standalone ZK + # org.apache.ZooKeeperService:name0=*,name1=InMemoryDataTree + - pattern: "org.apache.ZooKeeperService<>(WatchCount|NodeCount): (\\d+)" + name: zookeeper_inmemorydatatree_$2 + type: GAUGE + labels: + server_name: $1 + server_id: "1" + # Below rule applies to a Standalone ZK + # org.apache.ZooKeeperService:name0=*,name1=Connections,name2=*,name3=* + - pattern: "org.apache.ZooKeeperService<>([^:]+)" + name: zookeeper_connections_$4 + labels: + server_name: "$1" + client_address: "$2" + connection_id: "$3" + # Below rule applies to a Standalone ZK + # org.apache.ZooKeeperService:name0=* + - pattern: "org.apache.ZooKeeperService<>(StartTime|ClientPort|SecureClientAddress|Version|SecureClientPort): (.+)" + name: zookeeper_$2 + value: 1 + labels: + server_name: "$1" + $2: "$3" + # Below rule applies to a Standalone ZK + # org.apache.ZooKeeperService:name0=* + - pattern: "org.apache.ZooKeeperService<>(.+): (.+)" + name: zookeeper_$2 + type: GAUGE