0
0
Kafkadevops~10 mins

Why monitoring prevents outages in Kafka - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a Kafka consumer that subscribes to a topic.

Kafka
consumer.subscribe([[1]])
Drag options to blanks, or click blank then click option'
A"my_topic"
Bmy_topic
Ctopic_name
D"topic"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the topic name
Passing a variable without quotes
2fill in blank
medium

Complete the code to set the consumer group id for Kafka monitoring.

Kafka
consumer_config = {"group.id": [1]
Drag options to blanks, or click blank then click option'
A"monitoring_group"
B123
Cmonitoring_group
Dgroup1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number without quotes
Using an undefined variable
3fill in blank
hard

Fix the error in the code to poll messages from Kafka with a timeout of 1 second.

Kafka
msg = consumer.poll(timeout_ms=[1])
Drag options to blanks, or click blank then click option'
A1
B1000
C1.0
D"1s"
Attempts:
3 left
💡 Hint
Common Mistakes
Using seconds as float or string
Using 1 instead of 1000
4fill in blank
hard

Fill both blanks to configure Kafka consumer to auto-commit offsets and set auto offset reset to earliest.

Kafka
consumer_config = {"enable.auto.commit": [1], "auto.offset.reset": [2]
Drag options to blanks, or click blank then click option'
ATrue
BFalse
C"earliest"
D"latest"
Attempts:
3 left
💡 Hint
Common Mistakes
Setting auto commit to False
Using 'latest' instead of 'earliest'
5fill in blank
hard

Complete the code to create a dictionary comprehension that maps topic partitions to their current offsets if the offset is greater than 0.

Kafka
offsets = {partition: offset for partition, offset in offsets_dict.items() if offset [1] 0}
Drag options to blanks, or click blank then click option'
A.partition
C>
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Adding .partition or .offset incorrectly
Using '>=' instead of '>'