0
0
Hadoopdata~10 mins

Log management and troubleshooting in Hadoop - Interactive Code Practice

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

Complete the code to display the last 10 lines of the Hadoop log file.

Hadoop
tail -n [1] /var/log/hadoop/hadoop.log
Drag options to blanks, or click blank then click option'
A5
B10
C20
D50
Attempts:
3 left
💡 Hint
Common Mistakes
Using too few lines like 5 might miss important info.
Using too many lines like 50 can be overwhelming.
2fill in blank
medium

Complete the command to search for error messages in the Hadoop log file.

Hadoop
grep '[1]' /var/log/hadoop/hadoop.log
Drag options to blanks, or click blank then click option'
Awarning
Bdebug
Cinfo
Derror
Attempts:
3 left
💡 Hint
Common Mistakes
Searching for info or debug shows too much detail.
Using warning might miss actual errors.
3fill in blank
hard

Fix the error in the command to continuously monitor the Hadoop log file.

Hadoop
tail [1] /var/log/hadoop/hadoop.log
Drag options to blanks, or click blank then click option'
A-c
B-n
C-f
D-r
Attempts:
3 left
💡 Hint
Common Mistakes
Using -n only shows a fixed number of lines and exits.
Using -r reverses the output order, not follow.
4fill in blank
hard

Fill both blanks to create a dictionary of log levels and their counts from a log file.

Hadoop
import collections
log_counts = [1](line.split()[2] for line in open('/var/log/hadoop/hadoop.log'))
print(log_counts.[2]())
Drag options to blanks, or click blank then click option'
Acollections.Counter
Bmost_common
Citems
Ddefaultdict
Attempts:
3 left
💡 Hint
Common Mistakes
Using defaultdict alone does not count automatically.
Using items() returns all items but not sorted by frequency.
5fill in blank
hard

Fill all three blanks to filter and print unique IP addresses from Hadoop access logs.

Hadoop
with open('/var/log/hadoop/access.log') as f:
    ips = set()
    for line in f:
        if '[1]' in line:
            ip = line.split()[[2]]
            ips.[3](ip)
print(ips)
Drag options to blanks, or click blank then click option'
AGET
B0
Cadd
DPOST
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of GET filters different requests.
Using append instead of add on a set causes errors.