Skip to content

Commit c583a49

Browse files
committed
initial cruise-control
1 parent d973cb1 commit c583a49

File tree

5 files changed

+424
-0
lines changed

5 files changed

+424
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
kind: ConfigMap
2+
metadata:
3+
name: broker-cruise-control-reporter-config
4+
namespace: kafka
5+
apiVersion: v1
6+
data:
7+
cruise-control-reporter-init.sh: |-
8+
#!/bin/bash
9+
set -xe
10+
VERSION=2.0.6
11+
curl -L -o /opt/kafka/libs/extensions/cruise-control-metrics-reporter.jar https://linkedin.jfrog.io/linkedin/cruise-control/com/linkedin/cruisecontrol/cruise-control-metrics-reporter/${VERSION}/cruise-control-metrics-reporter-${VERSION}.jar
12+
echo -e "\n\nmetric.reporters = com.linkedin.kafka.cruisecontrol.metricsreporter.CruiseControlMetricsReporter" >> /etc/kafka/server.properties
Lines changed: 311 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,311 @@
1+
kind: ConfigMap
2+
metadata:
3+
name: broker-cruise-control-config
4+
namespace: kafka
5+
apiVersion: v1
6+
data:
7+
cruisecontrol.properties: |-
8+
#
9+
# Copyright 2017 LinkedIn Corp. Licensed under the BSD 2-Clause License (the "License"). See License in the project root for license information.
10+
#
11+
12+
# This is an example property file for Kafka Cruise Control. See KafkaCruiseControlConfig for more details.
13+
14+
# Configuration for the metadata client.
15+
# =======================================
16+
17+
# The Kafka cluster to control.
18+
bootstrap.servers=bootstrap:9092
19+
20+
# The maximum interval in milliseconds between two metadata refreshes.
21+
#metadata.max.age.ms=300000
22+
23+
# Client id for the Cruise Control. It is used for the metadata client.
24+
#client.id=kafka-cruise-control
25+
26+
# The size of TCP send buffer bytes for the metadata client.
27+
#send.buffer.bytes=131072
28+
29+
# The size of TCP receive buffer size for the metadata client.
30+
#receive.buffer.bytes=131072
31+
32+
# The time to wait before disconnect an idle TCP connection.
33+
#connections.max.idle.ms=540000
34+
35+
# The time to wait before reconnect to a given host.
36+
#reconnect.backoff.ms=50
37+
38+
# The time to wait for a response from a host after sending a request.
39+
#request.timeout.ms=30000
40+
41+
42+
# Configurations for the load monitor
43+
# =======================================
44+
45+
# The number of metric fetcher thread to fetch metrics for the Kafka cluster
46+
num.metric.fetchers=1
47+
48+
# The metric sampler class
49+
metric.sampler.class=com.linkedin.kafka.cruisecontrol.monitor.sampling.CruiseControlMetricsReporterSampler
50+
# Configurations for CruiseControlMetricsReporterSampler
51+
metric.reporter.topic.pattern=__CruiseControlMetrics
52+
53+
# The sample store class name
54+
sample.store.class=com.linkedin.kafka.cruisecontrol.monitor.sampling.KafkaSampleStore
55+
56+
# The config for the Kafka sample store to save the partition metric samples
57+
partition.metric.sample.store.topic=__KafkaCruiseControlPartitionMetricSamples
58+
59+
# The config for the Kafka sample store to save the model training samples
60+
broker.metric.sample.store.topic=__KafkaCruiseControlModelTrainingSamples
61+
62+
# The replication factor of Kafka metric sample store topic
63+
sample.store.topic.replication.factor=2
64+
65+
# The config for the number of Kafka sample store consumer threads
66+
num.sample.loading.threads=8
67+
68+
# The partition assignor class for the metric samplers
69+
metric.sampler.partition.assignor.class=com.linkedin.kafka.cruisecontrol.monitor.sampling.DefaultMetricSamplerPartitionAssignor
70+
71+
# The metric sampling interval in milliseconds
72+
metric.sampling.interval.ms=120000
73+
74+
# The partition metrics window size in milliseconds
75+
partition.metrics.window.ms=300000
76+
77+
# The number of partition metric windows to keep in memory
78+
num.partition.metrics.windows=1
79+
80+
# The minimum partition metric samples required for a partition in each window
81+
min.samples.per.partition.metrics.window=1
82+
83+
# The broker metrics window size in milliseconds
84+
broker.metrics.window.ms=300000
85+
86+
# The number of broker metric windows to keep in memory
87+
num.broker.metrics.windows=20
88+
89+
# The minimum broker metric samples required for a partition in each window
90+
min.samples.per.broker.metrics.window=1
91+
92+
# The configuration for the BrokerCapacityConfigFileResolver (supports JBOD and non-JBOD broker capacities)
93+
capacity.config.file=config/capacity.json
94+
#capacity.config.file=config/capacityJBOD.json
95+
96+
# Configurations for the analyzer
97+
# =======================================
98+
99+
# The list of goals to optimize the Kafka cluster for with pre-computed proposals
100+
default.goals=com.linkedin.kafka.cruisecontrol.analyzer.goals.RackAwareGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.ReplicaCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.DiskCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkInboundCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkOutboundCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.CpuCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.ReplicaDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.PotentialNwOutGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.DiskUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkInboundUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkOutboundUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.CpuUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.TopicReplicaDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.LeaderBytesInDistributionGoal
101+
102+
# The list of supported goals
103+
goals=com.linkedin.kafka.cruisecontrol.analyzer.goals.RackAwareGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.ReplicaCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.DiskCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkInboundCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkOutboundCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.CpuCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.ReplicaDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.PotentialNwOutGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.DiskUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkInboundUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkOutboundUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.CpuUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.TopicReplicaDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.LeaderBytesInDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.kafkaassigner.KafkaAssignerDiskUsageDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.kafkaassigner.KafkaAssignerEvenRackAwareGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.PreferredLeaderElectionGoal
104+
105+
# The list of supported hard goals
106+
hard.goals=com.linkedin.kafka.cruisecontrol.analyzer.goals.RackAwareGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.ReplicaCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.DiskCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkInboundCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkOutboundCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.CpuCapacityGoal
107+
108+
# The minimum percentage of well monitored partitions out of all the partitions
109+
min.monitored.partition.percentage=0.95
110+
111+
# The balance threshold for CPU
112+
cpu.balance.threshold=1.1
113+
114+
# The balance threshold for disk
115+
disk.balance.threshold=1.1
116+
117+
# The balance threshold for network inbound utilization
118+
network.inbound.balance.threshold=1.1
119+
120+
# The balance threshold for network outbound utilization
121+
network.outbound.balance.threshold=1.1
122+
123+
# The balance threshold for the replica count
124+
replica.count.balance.threshold=1.1
125+
126+
# The capacity threshold for CPU in percentage
127+
cpu.capacity.threshold=0.8
128+
129+
# The capacity threshold for disk in percentage
130+
disk.capacity.threshold=0.8
131+
132+
# The capacity threshold for network inbound utilization in percentage
133+
network.inbound.capacity.threshold=0.8
134+
135+
# The capacity threshold for network outbound utilization in percentage
136+
network.outbound.capacity.threshold=0.8
137+
138+
# The threshold to define the cluster to be in a low CPU utilization state
139+
cpu.low.utilization.threshold=0.0
140+
141+
# The threshold to define the cluster to be in a low disk utilization state
142+
disk.low.utilization.threshold=0.0
143+
144+
# The threshold to define the cluster to be in a low network inbound utilization state
145+
network.inbound.low.utilization.threshold=0.0
146+
147+
# The threshold to define the cluster to be in a low disk utilization state
148+
network.outbound.low.utilization.threshold=0.0
149+
150+
# The metric anomaly percentile upper threshold
151+
metric.anomaly.percentile.upper.threshold=90.0
152+
153+
# The metric anomaly percentile lower threshold
154+
metric.anomaly.percentile.lower.threshold=10.0
155+
156+
# How often should the cached proposal be expired and recalculated if necessary
157+
proposal.expiration.ms=60000
158+
159+
# The maximum number of replicas that can reside on a broker at any given time.
160+
max.replicas.per.broker=10000
161+
162+
# The number of threads to use for proposal candidate precomputing.
163+
num.proposal.precompute.threads=1
164+
165+
# the topics that should be excluded from the partition movement.
166+
#topics.excluded.from.partition.movement
167+
168+
# Configurations for the executor
169+
# =======================================
170+
171+
# The zookeeper connect of the Kafka cluster
172+
zookeeper.connect=zookeeper:2181
173+
174+
# The max number of partitions to move in/out on a given broker at a given time.
175+
num.concurrent.partition.movements.per.broker=10
176+
177+
# The interval between two execution progress checks.
178+
execution.progress.check.interval.ms=10000
179+
180+
181+
# Configurations for anomaly detector
182+
# =======================================
183+
184+
# The goal violation notifier class
185+
anomaly.notifier.class=com.linkedin.kafka.cruisecontrol.detector.notifier.SelfHealingNotifier
186+
187+
# The metric anomaly finder class
188+
metric.anomaly.finder.class=com.linkedin.kafka.cruisecontrol.detector.KafkaMetricAnomalyFinder
189+
190+
# The anomaly detection interval
191+
anomaly.detection.interval.ms=10000
192+
193+
# The goal violation to detect.
194+
anomaly.detection.goals=com.linkedin.kafka.cruisecontrol.analyzer.goals.RackAwareGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.ReplicaCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.DiskCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkInboundCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.NetworkOutboundCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.CpuCapacityGoal
195+
196+
# The interested metrics for metric anomaly analyzer.
197+
metric.anomaly.analyzer.metrics=BROKER_PRODUCE_LOCAL_TIME_MS_MAX,BROKER_PRODUCE_LOCAL_TIME_MS_MEAN,BROKER_CONSUMER_FETCH_LOCAL_TIME_MS_MAX,BROKER_CONSUMER_FETCH_LOCAL_TIME_MS_MEAN,BROKER_FOLLOWER_FETCH_LOCAL_TIME_MS_MAX,BROKER_FOLLOWER_FETCH_LOCAL_TIME_MS_MEAN,BROKER_LOG_FLUSH_TIME_MS_MAX,BROKER_LOG_FLUSH_TIME_MS_MEAN
198+
199+
# The zk path to store failed broker information.
200+
failed.brokers.zk.path=/CruiseControlBrokerList
201+
202+
# Topic config provider class
203+
topic.config.provider.class=com.linkedin.kafka.cruisecontrol.config.KafkaTopicConfigProvider
204+
205+
# The cluster configurations for the KafkaTopicConfigProvider
206+
cluster.configs.file=config/clusterConfigs.json
207+
208+
# Enable self healing for all anomaly detectors, unless the particular anomaly detector is explicitly disabled
209+
self.healing.enabled=true
210+
211+
# Enable self healing for broker failure detector
212+
#self.healing.broker.failure.enabled=true
213+
214+
# Enable self healing for goal violation detector
215+
#self.healing.goal.violation.enabled=true
216+
217+
# Enable self healing for metric anomaly detector
218+
#self.healing.metric.anomaly.enabled=true
219+
220+
capacityJBOD.json: |-
221+
{
222+
"brokerCapacities":[
223+
{
224+
"brokerId": "-1",
225+
"capacity": {
226+
"DISK": {"/tmp/kafka-logs-1": "100000", "/tmp/kafka-logs-2": "100000", "/tmp/kafka-logs-3": "50000",
227+
"/tmp/kafka-logs-4": "50000", "/tmp/kafka-logs-5": "150000", "/tmp/kafka-logs-6": "50000"},
228+
"CPU": "100",
229+
"NW_IN": "10000",
230+
"NW_OUT": "10000"
231+
},
232+
"doc": "The default capacity for a broker with multiple logDirs each on a separate heterogeneous disk."
233+
},
234+
{
235+
"brokerId": "0",
236+
"capacity": {
237+
"DISK": {"/tmp/kafka-logs": "500000"},
238+
"CPU": "100",
239+
"NW_IN": "50000",
240+
"NW_OUT": "50000"
241+
},
242+
"doc": "This overrides the capacity for broker 0. This broker is not a JBOD broker."
243+
},
244+
{
245+
"brokerId": "1",
246+
"capacity": {
247+
"DISK": {"/tmp/kafka-logs-1": "250000", "/tmp/kafka-logs-2": "250000"},
248+
"CPU": "100",
249+
"NW_IN": "50000",
250+
"NW_OUT": "50000"
251+
},
252+
"doc": "This overrides the capacity for broker 1. This broker is a JBOD broker."
253+
}
254+
]
255+
}
256+
257+
capacity.json: |-
258+
{
259+
"brokerCapacities":[
260+
{
261+
"brokerId": "-1",
262+
"capacity": {
263+
"DISK": "100000",
264+
"CPU": "100",
265+
"NW_IN": "10000",
266+
"NW_OUT": "10000"
267+
},
268+
"doc": "This is the default capacity. Capacity unit used for disk is in MB, cpu is in percentage, network throughput is in KB."
269+
},
270+
{
271+
"brokerId": "0",
272+
"capacity": {
273+
"DISK": "500000",
274+
"CPU": "100",
275+
"NW_IN": "50000",
276+
"NW_OUT": "50000"
277+
},
278+
"doc": "This overrides the capacity for broker 0."
279+
}
280+
]
281+
}
282+
283+
clusterConfigs.json: |-
284+
{
285+
"min.insync.replicas": 1,
286+
"an.example.cluster.config": false
287+
}
288+
289+
log4j2.xml: |-
290+
<?xml version="1.0" encoding="UTF-8"?>
291+
<Configuration status="INFO">
292+
<Appenders>
293+
<File name="Console" fileName="/dev/stdout">
294+
<PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
295+
</File>
296+
</Appenders>
297+
<Loggers>
298+
<Root level="info">
299+
<AppenderRef ref="Console" />
300+
</Root>
301+
</Loggers>
302+
</Configuration>
303+
304+
log4j.properties: |-
305+
log4j.rootLogger = INFO, FILE
306+
307+
log4j.appender.FILE=org.apache.log4j.FileAppender
308+
log4j.appender.FILE.File=/dev/stdout
309+
310+
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
311+
log4j.appender.FILE.layout.conversionPattern=%-6r [%15.15t] %-5p %30.30c %x - %m%n
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# meant to be applied using
2+
# kubectl --namespace kafka patch statefulset kafka --patch "$(cat cruise-control/20kafka-broker-reporter-patch.yml )"
3+
apiVersion: apps/v1
4+
kind: StatefulSet
5+
metadata:
6+
name: kafka
7+
namespace: kafka
8+
spec:
9+
template:
10+
spec:
11+
initContainers:
12+
- name: cruise-control-reporter
13+
image: hortonworks/alpine-curl:3.1
14+
command: ['/bin/sh', '/tmp/cruise-control-reporter-configmap/cruise-control-reporter-init.sh']
15+
volumeMounts:
16+
- name: cruiseconfigmap
17+
mountPath: /tmp/cruise-control-reporter-configmap
18+
- name: config
19+
mountPath: /etc/kafka
20+
- name: extensions
21+
mountPath: /opt/kafka/libs/extensions
22+
$setElementOrder/initContainers:
23+
- name: init-config
24+
- name: cruise-control-reporter
25+
containers:
26+
- name: broker
27+
env:
28+
- name: CLASSPATH
29+
value: /opt/kafka/libs/extensions/cruise-control-metrics-reporter.jar
30+
volumeMounts:
31+
- name: extensions
32+
mountPath: /opt/kafka/libs/extensions
33+
volumes:
34+
- name: cruiseconfigmap
35+
configMap:
36+
name: broker-cruise-control-reporter-config
37+
- name: extensions
38+
emptyDir: {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
kind: Service
2+
apiVersion: v1
3+
metadata:
4+
name: cruise-control
5+
namespace: kafka
6+
spec:
7+
selector:
8+
app: cruise-control
9+
ports:
10+
- protocol: TCP
11+
port: 8090
12+
targetPort: 8090

0 commit comments

Comments
 (0)