linkedin / cruise-control

Cruise-control is the first of its kind to fully automate the dynamic workload rebalance and self-healing of a Kafka cluster. It provides great value to Kafka users by simplifying the operation of Kafka clusters.
https://github.com/linkedin/cruise-control/tags
BSD 2-Clause "Simplified" License
2.74k stars 587 forks source link

CORS issue #1845

Open sankalpwako opened 2 years ago

sankalpwako commented 2 years ago

Apache kafka version : 2.2.1 Cruise-control release : 2.0.191

Error logs:

User-Task-ID header is not found in the response from the server. If you are using [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), please add necessary configuration to your Cruise Control as described [in this wiki.](https://github.com/linkedin/cruise-control-ui/wiki/CORS-Method)

ERROR: Error processing GET request '/proposals' due to: 'com.linkedin.kafka.cruisecontrol.exception.KafkaCruiseControlException: com.linkedin.cruisecontrol.exception.NotEnoughValidWindowsException: There are only 0 valid windows when aggregating in range [-1, 1653993428595] for aggregation options (minValidEntityRatio=0.95, minValidEntityGroupRatio=0.00, minValidWindows=1, numEntitiesToInclude=4367, granularity=ENTITY)'.

Facing issues while trying to enable CORS.

cruisecontrol properties file :

#
# Copyright 2017 LinkedIn Corp. Licensed under the BSD 2-Clause License (the "License"). See License in the project root for license information.
#

# This is an example property file for Kafka Cruise Control. See com.linkedin.kafka.cruisecontrol.config.constants for more details.

# Configuration for the metadata client.
# =======================================

# The Kafka cluster to control.
bootstrap.servers= b-3.abc.def.gh.kafka.ap-southeast-1.amazonaws.com:9092,b-6.abc.def.gh.kafka.ap-southeast-1.amazonaws.com:9092,b-1.abc.def.gh.kafka.ap-southeast-1.amazonaws.com:9092

# The maximum interval in milliseconds between two metadata refreshes.
#metadata.max.age.ms=300000

# Client id for the Cruise Control. It is used for the metadata client.
#client.id=kafka-cruise-control

# The size of TCP send buffer bytes for the metadata client.
#send.buffer.bytes=131072

# The size of TCP receive buffer size for the metadata client.
#receive.buffer.bytes=131072

# The time to wait before disconnect an idle TCP connection.
#connections.max.idle.ms=540000

# The time to wait before reconnect to a given host.
#reconnect.backoff.ms=50

# The time to wait for a response from a host after sending a request.
#request.timeout.ms=30000

# The time to wait for broker logdir to respond after sending a request.
#logdir.response.timeout.ms=10000

# Configurations for the load monitor
# =======================================

# The number of metric fetcher thread to fetch metrics for the Kafka cluster
num.metric.fetchers=1

# The metric sampler class
metric.sampler.class=com.linkedin.kafka.cruisecontrol.monitor.sampling.prometheus.PrometheusMetricSampler

# True if the sampling process allows CPU capacity estimation of brokers used for CPU utilization estimation.
sampling.allow.cpu.capacity.estimation=true

# Configurations for CruiseControlMetricsReporterSampler
metric.reporter.topic=__CruiseControlMetrics

# The sample store class name
sample.store.class=com.linkedin.kafka.cruisecontrol.monitor.sampling.KafkaSampleStore

# The config for the Kafka sample store to save the partition metric samples
partition.metric.sample.store.topic=__KafkaCruiseControlPartitionMetricSamples

# The config for the Kafka sample store to save the model training samples
broker.metric.sample.store.topic=__KafkaCruiseControlModelTrainingSamples

# The replication factor of Kafka metric sample store topic
sample.store.topic.replication.factor=2

# The config for the number of Kafka sample store consumer threads
num.sample.loading.threads=8

# The partition assignor class for the metric samplers
metric.sampler.partition.assignor.class=com.linkedin.kafka.cruisecontrol.monitor.sampling.DefaultMetricSamplerPartitionAssignor

# The metric sampling interval in milliseconds
metric.sampling.interval.ms=120000

# The partition metrics window size in milliseconds
partition.metrics.window.ms=300000

# The number of partition metric windows to keep in memory. Partition-load-history = num.partition.metrics.windows * partition.metrics.window.ms
num.partition.metrics.windows=5

# The minimum partition metric samples required for a partition in each window
min.samples.per.partition.metrics.window=1

# The broker metrics window size in milliseconds
broker.metrics.window.ms=300000

# The number of broker metric windows to keep in memory. Broker-load-history = num.broker.metrics.windows * broker.metrics.window.ms
num.broker.metrics.windows=20

# The minimum broker metric samples required for a partition in each window
min.samples.per.broker.metrics.window=1

# The configuration for the BrokerCapacityConfigFileResolver (supports JBOD, non-JBOD, and heterogeneous CPU core capacities)
#capacity.config.file=config/capacity.json
capacity.config.file=config/capacityCores.json

# Configurations for the analyzer
# =======================================

# The list of goals to optimize the Kafka cluster for with pre-computed proposals -- consider using RackAwareDistributionGoal instead of RackAwareGoal in clusters with partitions whose replication factor > number of racks
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.LeaderReplicaDistributionGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.LeaderBytesInDistributionGoal

# The list of supported goals
goals=com.linkedin.kafka.cruisecontrol.analyzer.goals.RackAwareGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.RackAwareDistributionGoal,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.LeaderReplicaDistributionGoal,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

# The list of supported intra-broker goals
intra.broker.goals=com.linkedin.kafka.cruisecontrol.analyzer.goals.IntraBrokerDiskCapacityGoal,com.linkedin.kafka.cruisecontrol.analyzer.goals.IntraBrokerDiskUsageDistributionGoal

# The list of supported hard goals -- consider using RackAwareDistributionGoal instead of RackAwareGoal in clusters with partitions whose replication factor > number of racks
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

# The minimum percentage of well monitored partitions out of all the partitions
min.valid.partition.ratio=0.95

# The balance threshold for CPU
cpu.balance.threshold=1.1

# The balance threshold for disk
disk.balance.threshold=1.1

# The balance threshold for network inbound utilization
network.inbound.balance.threshold=1.1

# The balance threshold for network outbound utilization
network.outbound.balance.threshold=1.1

# The balance threshold for the replica count
replica.count.balance.threshold=1.1

# The capacity threshold for CPU in percentage
cpu.capacity.threshold=0.7

# The capacity threshold for disk in percentage
disk.capacity.threshold=0.8

# The capacity threshold for network inbound utilization in percentage
network.inbound.capacity.threshold=0.8

# The capacity threshold for network outbound utilization in percentage
network.outbound.capacity.threshold=0.8

# The threshold to define the cluster to be in a low CPU utilization state
cpu.low.utilization.threshold=0.0

# The threshold to define the cluster to be in a low disk utilization state
disk.low.utilization.threshold=0.0

# The threshold to define the cluster to be in a low network inbound utilization state
network.inbound.low.utilization.threshold=0.0

# The threshold to define the cluster to be in a low network outbound utilization state
network.outbound.low.utilization.threshold=0.0

# The metric anomaly percentile upper threshold
metric.anomaly.percentile.upper.threshold=90.0

# The metric anomaly percentile lower threshold
metric.anomaly.percentile.lower.threshold=10.0

# How often should the cached proposal be expired and recalculated if necessary
proposal.expiration.ms=60000

# The maximum number of replicas that can reside on a broker at any given time.
max.replicas.per.broker=10000

# The number of threads to use for proposal candidate precomputing.
num.proposal.precompute.threads=1

# the topics that should be excluded from the partition movement.
#topics.excluded.from.partition.movement

# The impact of having one level higher goal priority on the relative balancedness score.
#goal.balancedness.priority.weight

# The impact of strictness on the relative balancedness score.
#goal.balancedness.strictness.weight

# Configurations for the executor
# =======================================

# The zookeeper connect of the Kafka cluster
zookeeper.connect= z-1.abc.def.gh.kafka.ap-southeast-1.amazonaws.com:2181,z-2.abc.def.gh.kafka.ap-southeast-1.amazonaws.com:2181,z-3.abc.def.gh.kafka.ap-southeast-1.amazonaws.com:2181/

# If true, appropriate zookeeper Client { .. } entry required in jaas file located at $base_dir/config/cruise_control_jaas.conf
zookeeper.security.enabled=false

# The max number of partitions to move in/out on a given broker at a given time.
num.concurrent.partition.movements.per.broker=10

# The max number of partitions to move between disks within a given broker at a given time.
num.concurrent.intra.broker.partition.movements=2

# The max number of leadership movement within the whole cluster at a given time.
num.concurrent.leader.movements=1000

# Default replica movement throttle. If not specified, movements unthrottled by default.
# default.replication.throttle=

# The interval between two execution progress checks.
execution.progress.check.interval.ms=10000

# Configurations for anomaly detector
# =======================================

# The goal violation notifier class
anomaly.notifier.class=com.linkedin.kafka.cruisecontrol.detector.notifier.SelfHealingNotifier

# The metric anomaly finder class
metric.anomaly.finder.class=com.linkedin.kafka.cruisecontrol.detector.KafkaMetricAnomalyFinder

# The anomaly detection interval
#anomaly.detection.interval.ms=10000

# The goal violation to detect -- consider using RackAwareDistributionGoal instead of RackAwareGoal in clusters with partitions whose replication factor > number of racks
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

# The interested metrics for metric anomaly analyzer.
metric.anomaly.analyzer.metrics=BROKER_PRODUCE_LOCAL_TIME_MS_50TH,BROKER_PRODUCE_LOCAL_TIME_MS_999TH,BROKER_CONSUMER_FETCH_LOCAL_TIME_MS_50TH,BROKER_CONSUMER_FETCH_LOCAL_TIME_MS_999TH,BROKER_FOLLOWER_FETCH_LOCAL_TIME_MS_50TH,BROKER_FOLLOWER_FETCH_LOCAL_TIME_MS_999TH,BROKER_LOG_FLUSH_TIME_MS_50TH,BROKER_LOG_FLUSH_TIME_MS_999TH

# True if recently demoted brokers are excluded from optimizations during self healing, false otherwise
self.healing.exclude.recently.demoted.brokers=true

# True if recently removed brokers are excluded from optimizations during self healing, false otherwise
self.healing.exclude.recently.removed.brokers=true

# The zk path to store failed broker information.
failed.brokers.zk.path=/CruiseControlBrokerList

# Topic config provider class
topic.config.provider.class=com.linkedin.kafka.cruisecontrol.config.KafkaAdminTopicConfigProvider

# The cluster configurations for the TopicConfigProvider
cluster.configs.file=config/clusterConfigs.json

# The maximum time in milliseconds to store the response and access details of a completed kafka monitoring user task.
completed.kafka.monitor.user.task.retention.time.ms=86400000

# The maximum time in milliseconds to store the response and access details of a completed cruise control monitoring user task.
completed.cruise.control.monitor.user.task.retention.time.ms=86400000

# The maximum time in milliseconds to store the response and access details of a completed kafka admin user task.
completed.kafka.admin.user.task.retention.time.ms=604800000

# The maximum time in milliseconds to store the response and access details of a completed cruise control admin user task.
completed.cruise.control.admin.user.task.retention.time.ms=604800000

# The fallback maximum time in milliseconds to store the response and access details of a completed user task.
completed.user.task.retention.time.ms=86400000

# The maximum time in milliseconds to retain the demotion history of brokers.
demotion.history.retention.time.ms=1209600000

# The maximum time in milliseconds to retain the removal history of brokers.
removal.history.retention.time.ms=1209600000

# The maximum number of completed kafka monitoring user tasks for which the response and access details will be cached.
max.cached.completed.kafka.monitor.user.tasks=20

# The maximum number of completed cruise control monitoring user tasks for which the response and access details will be cached.
max.cached.completed.cruise.control.monitor.user.tasks=20

# The maximum number of completed kafka admin user tasks for which the response and access details will be cached.
max.cached.completed.kafka.admin.user.tasks=30

# The maximum number of completed cruise control admin user tasks for which the response and access details will be cached.
max.cached.completed.cruise.control.admin.user.tasks=30

# The fallback maximum number of completed user tasks of certain type for which the response and access details will be cached.
max.cached.completed.user.tasks=25

# The maximum number of user tasks for concurrently running in async endpoints across all users.
max.active.user.tasks=5

# Enable self healing for all anomaly detectors, unless the particular anomaly detector is explicitly disabled
self.healing.enabled=false

# Enable self healing for broker failure detector
#self.healing.broker.failure.enabled=true

# Enable self healing for goal violation detector
#self.healing.goal.violation.enabled=true

# Enable self healing for metric anomaly detector
#self.healing.metric.anomaly.enabled=true

# Enable self healing for disk failure detector
#self.healing.disk.failure.enabled=true

# Enable self healing for topic anomaly detector
#self.healing.topic.anomaly.enabled=true
#topic.anomaly.finder.class=com.linkedin.kafka.cruisecontrol.detector.TopicReplicationFactorAnomalyFinder

# Enable self healing for maintenance event detector
#self.healing.maintenance.event.enabled=true

# The multiplier applied to the threshold of distribution goals used by goal.violation.detector.
#goal.violation.distribution.threshold.multiplier=2.50

# configurations for the webserver
# ================================

# HTTP listen port
webserver.http.port=9091

# HTTP listen address
webserver.http.address=0.0.0.0

# Whether CORS support is enabled for API or not
webserver.http.cors.enabled=true

# Value for Access-Control-Allow-Origin
webserver.http.cors.origin=*

# Value for Access-Control-Request-Method
webserver.http.cors.allowmethods=OPTIONS,GET,POST

# Headers that should be exposed to the Browser (Webapp)
# This is a special header that is used by the
# User Tasks subsystem and should be explicitly
# Enabled when CORS mode is used as part of the
# Admin Interface
webserver.http.cors.exposeheaders=User-Task-ID,Content-Type

# REST API default prefix (dont forget the ending /*)
webserver.api.urlprefix=/kafkacruisecontrol/*

# Location where the Cruise Control frontend is deployed
webserver.ui.diskpath=./cruise-control-ui/dist/

# URL path prefix for UI (dont forget the ending /*)
webserver.ui.urlprefix=/*

# Time After which request is converted to Async
webserver.request.maxBlockTimeMs=10000

# Default Session Expiry Period
webserver.session.maxExpiryTimeMs=60000

# Session cookie path
webserver.session.path=/

# Server Access Logs
webserver.accesslog.enabled=true

# Location of HTTP Request Logs
webserver.accesslog.path=access.log

# HTTP Request Log retention days
webserver.accesslog.retention.days=14

# Configurations for servlet
# ==========================

# Enable two-step verification for processing POST requests.
two.step.verification.enabled=true

# The maximum time in milliseconds to retain the requests in two-step (verification) purgatory.
two.step.purgatory.retention.time.ms=1209600000

# The maximum number of requests in two-step (verification) purgatory.
two.step.purgatory.max.requests=25
prometheus.server.endpoint=localhost:9090

Output of curl -X -v OPTIONS https://endpoint-of-kafka.abc.xyz/kafkacruisecontrol/kafka_cluster_state?json=true

The first error message says that User-Task-ID header was not found, but this curl request is returning the same. Have not been able to figure this issue out. Tried changing the prometheus scrape interval, tried changing the allowed allowed cors origin to exact value, and *

CCisGG commented 2 years ago

Hi @sankalpwako , the description is a bit confusing and seems to be incomplete. I tried to better formatted the description. Meanwhile would you mind to add more clarification to the problem and what is the exact issue you're facing?

mohitpali commented 2 years ago

@sankalpwako were you able to solve this ?

imbelkhir commented 2 years ago

any fixes for this issue please ?