Complete the code to start the Kafka consumer with the correct group ID.
kafka-console-consumer --bootstrap-server localhost:9092 --topic metrics --group [1]
The --group option sets the consumer group ID. Here, consumer-1 is the correct group name to start consuming metrics.
Complete the command to produce a JSON metric message to the Kafka topic.
echo '{"metric":"cpu_usage","value":75}' | kafka-console-producer --bootstrap-server localhost:9092 --topic [1]
The --topic option specifies the Kafka topic to send messages to. Here, metrics is the correct topic for client metrics.
Fix the error in the consumer command to correctly read from the beginning of the topic.
kafka-console-consumer --bootstrap-server localhost:9092 --topic metrics --group consumer-1 --[1]
The correct option to read all messages from the start is --from-beginning. Other options are invalid and cause errors.
Fill both blanks to configure the Kafka consumer to use a specific offset reset policy and enable auto commit.
kafka-console-consumer --bootstrap-server localhost:9092 --topic metrics --group consumer-2 --consumer-property auto.offset.reset=[1] --consumer-property enable.auto.commit=[2]
latest misses old messages.The auto.offset.reset should be set to earliest to start from the beginning if no offset is found. The enable.auto.commit should be true to commit offsets automatically.
Fill all three blanks to create a Kafka topic with 3 partitions, replication factor 2, and a retention time of 7 days.
kafka-topics --create --bootstrap-server localhost:9092 --topic client-metrics --partitions [1] --replication-factor [2] --config retention.ms=[3]
Partitions should be 3, replication factor 2 for fault tolerance, and retention time set to 7 days in milliseconds (7*24*60*60*1000 = 604800000).