Bird
Raised Fist0
Hadoopdata~20 mins

Flume for log collection in Hadoop - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Flume Log Collection Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the primary role of a Flume agent in log collection?

In Apache Flume, what does an agent mainly do when collecting logs?

AIt converts logs into SQL queries for database insertion.
BIt collects data from sources, processes it, and sends it to sinks.
CIt only monitors the health of the Hadoop cluster.
DIt stores logs permanently in HDFS without processing.
Attempts:
2 left
💡 Hint

Think about the flow of data from where logs are generated to where they are stored.

❓ query_result
intermediate
2:00remaining
What output does this Flume configuration produce?

Given this Flume configuration snippet, what is the expected output destination for the logs?

Hadoop
agent.sources = source1
agent.channels = channel1
agent.sinks = sink1

agent.sources.source1.type = exec
agent.sources.source1.command = tail -F /var/log/syslog

agent.channels.channel1.type = memory
agent.channels.channel1.capacity = 1000

agent.sinks.sink1.type = hdfs
agent.sinks.sink1.hdfs.path = hdfs://namenode/flume/logs/
agent.sinks.sink1.hdfs.filePrefix = syslog-

agent.sources.source1.channels = channel1
agent.sinks.sink1.channel = channel1
ALogs are sent to a Kafka topic named 'syslog'.
BLogs are collected from /var/log/syslog and stored locally on the agent machine.
CLogs are continuously collected from /var/log/syslog and stored in HDFS under /flume/logs/ with prefix 'syslog-'.
DLogs are discarded after being read from /var/log/syslog.
Attempts:
2 left
💡 Hint

Look at the sink type and path settings.

📝 Syntax
advanced
2:00remaining
Identify the syntax error in this Flume configuration snippet

Which option contains a syntax error that will prevent the Flume agent from starting?

Hadoop
agent.sources = source1
agent.channels = channel1
agent.sinks = sink1

agent.sources.source1.type = exec
agent.sources.source1.command = tail -F /var/log/syslog

agent.channels.channel1.type = memory
agent.channels.channel1.capacity = 1000

agent.sinks.sink1.type = hdfs
agent.sinks.sink1.hdfs.path = hdfs://namenode/flume/logs/
agent.sinks.sink1.hdfs.filePrefix = syslog-

agent.sources.source1.channels = channel1
agent.sinks.sink1.channel = channel1
Aagent.sinks.sink1.channel = channel1
Bagent.sources.source1.channels = channel1
Cagent.channels.channel1.capacity = 1000
Dagent.sinks.sink1.channels = channel1
Attempts:
2 left
💡 Hint

Check the property names for sinks connecting to channels.

❓ optimization
advanced
2:00remaining
How to optimize Flume for high log throughput?

You want to improve Flume's performance to handle a large volume of logs with minimal delay. Which option is the best optimization?

AUse a memory channel instead of a file channel to reduce disk I/O latency.
BDisable batch processing to send each event immediately.
CSet the source type to 'avro' to compress logs before sending.
DIncrease the number of sinks but keep a single channel to avoid complexity.
Attempts:
2 left
💡 Hint

Think about buffering and speed trade-offs.

🔧 Debug
expert
3:00remaining
Why does this Flume agent fail to deliver logs to HDFS?

Given this Flume agent configuration, logs are not appearing in HDFS. What is the most likely cause?

Hadoop
agent.sources = source1
agent.channels = channel1
agent.sinks = sink1

agent.sources.source1.type = exec
agent.sources.source1.command = tail -F /var/log/syslog

agent.channels.channel1.type = file
agent.channels.channel1.checkpointDir = /tmp/flume/checkpoint
agent.channels.channel1.dataDirs = /tmp/flume/data

agent.sinks.sink1.type = hdfs
agent.sinks.sink1.hdfs.path = hdfs://namenode/flume/logs/
agent.sinks.sink1.hdfs.filePrefix = syslog-

agent.sources.source1.channels = channel1
agent.sinks.sink1.channel = channel1
AThe file channel directories (/tmp/flume/checkpoint and /tmp/flume/data) do not have proper write permissions.
BThe source command 'tail -F /var/log/syslog' is incorrect and does not produce output.
CThe sink type 'hdfs' is deprecated and should be replaced with 'hdfs_sink'.
DThe channel type 'file' is incompatible with the exec source.
Attempts:
2 left
💡 Hint

Check file system permissions for channel directories.

Practice

(1/5)
1. What is the main purpose of Apache Flume in Hadoop ecosystems?
easy
A. To perform complex SQL queries on Hadoop data
B. To manage user permissions in Hadoop clusters
C. To collect and transport large amounts of log data from various sources to storage systems
D. To visualize data stored in HDFS

Solution

  1. Step 1: Understand Flume's role

    Flume is designed to collect and move log data efficiently from many sources.
  2. Step 2: Identify Flume's main function

    It transports this data reliably to storage like HDFS for further processing.
  3. Final Answer:

    To collect and transport large amounts of log data from various sources to storage systems -> Option C
  4. Quick Check:

    Flume = log data collection and transport [OK]
Hint: Flume moves logs from sources to storage reliably [OK]
Common Mistakes:
  • Confusing Flume with query engines
  • Thinking Flume manages permissions
  • Assuming Flume visualizes data
2. Which of the following is the correct way to define a source in a Flume configuration file?
easy
A. agent.channels = source1
B. agent.sinks = source1
C. agent.sources.source1.type = sink
D. agent.sources = source1

Solution

  1. Step 1: Recall Flume config syntax for sources

    Sources are defined with 'agent.sources' followed by source names.
  2. Step 2: Check each option

    agent.sources = source1 correctly assigns 'source1' as a source. Options A and B assign 'source1' incorrectly as channel or sink. agent.sources.source1.type = sink wrongly sets source type to sink.
  3. Final Answer:

    agent.sources = source1 -> Option D
  4. Quick Check:

    Sources start with 'agent.sources' [OK]
Hint: Sources start with 'agent.sources' in config [OK]
Common Mistakes:
  • Mixing sources with sinks or channels
  • Wrongly assigning types in config
  • Using incorrect property names
3. Given this Flume configuration snippet:
agent.sources = src1
agent.channels = ch1
agent.sinks = sink1

agent.sources.src1.type = exec
agent.sources.src1.command = tail -F /var/log/syslog
agent.channels.ch1.type = memory
agent.sinks.sink1.type = hdfs

agent.sources.src1.channels = ch1
agent.sinks.sink1.channel = ch1

What will happen when Flume runs?
medium
A. Flume will collect syslog data and write it to HDFS using a memory channel
B. Flume will fail because the channel type is invalid
C. Flume will collect data but not send it anywhere
D. Flume will write logs directly to local disk without using HDFS

Solution

  1. Step 1: Analyze source and command

    The source 'src1' uses 'exec' type to run 'tail -F /var/log/syslog', collecting live syslog data.
  2. Step 2: Check channel and sink setup

    The channel 'ch1' is memory type, and sink 'sink1' writes to HDFS. Source and sink both use channel 'ch1'.
  3. Final Answer:

    Flume will collect syslog data and write it to HDFS using a memory channel -> Option A
  4. Quick Check:

    Exec source + memory channel + HDFS sink = data flows correctly [OK]
Hint: Exec source tails logs; memory channel buffers; sink writes to HDFS [OK]
Common Mistakes:
  • Thinking memory channel is invalid
  • Assuming data is not sent to sink
  • Confusing sink type with local disk
4. You have this Flume config snippet:
agent.sources = src1
agent.channels = ch1
agent.sinks = sink1

agent.sources.src1.type = exec
agent.sources.src1.command = tail -F /var/log/syslog
agent.channels.ch1.type = memory
agent.sinks.sink1.type = hdfs

agent.sources.src1.channels = ch1
agent.sinks.sink1.channel = ch2

What is the problem in this configuration?
medium
A. The sink is connected to a channel 'ch2' which is not defined
B. The source command is invalid
C. The channel type 'memory' is not supported
D. The source is not assigned to any channel

Solution

  1. Step 1: Check channel definitions

    Only channel 'ch1' is defined; 'ch2' is missing from config.
  2. Step 2: Check sink channel assignment

    Sink 'sink1' is assigned to channel 'ch2', which does not exist, causing an error.
  3. Final Answer:

    The sink is connected to a channel 'ch2' which is not defined -> Option A
  4. Quick Check:

    Sink channel must be defined and match existing channel [OK]
Hint: Sink channel must exist in config [OK]
Common Mistakes:
  • Ignoring missing channel definitions
  • Assuming source command is wrong
  • Thinking memory channel is unsupported
5. You want to configure Flume to collect logs from two different servers and write them into separate directories in HDFS. Which configuration approach is best?
hard
A. Use one agent with one source and one sink writing to a single HDFS directory
B. Create two agents, each with its own source, channel, and sink writing to different HDFS paths
C. Use one agent with multiple sinks but share the same channel for both sources
D. Configure two sources in one agent but only one sink writing to HDFS

Solution

  1. Step 1: Understand requirement for separate directories

    Each server's logs must go to a different HDFS directory, so sinks must be separate.
  2. Step 2: Design configuration for isolation

    Two agents with separate sources, channels, and sinks allow independent paths and better fault isolation.
  3. Step 3: Evaluate other options

    Sharing channels or sinks mixes data and cannot guarantee separate directories.
  4. Final Answer:

    Create two agents, each with its own source, channel, and sink writing to different HDFS paths -> Option B
  5. Quick Check:

    Separate agents isolate data paths for different servers [OK]
Hint: Use separate agents for separate log paths [OK]
Common Mistakes:
  • Sharing channels causing mixed data
  • Using one sink for multiple sources
  • Not isolating sinks for different directories
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard