A network operations team uses Splunk to monitor netflow data stored in index='net' and sourcetype='netflow'. The events contain fields: src_ip, dest_ip, bytes, and protocols. The team needs to identify the top 5 source IPs by total bytes transferred (based on the bytes field). For each of those top source IPs, they also want to list the destination IPs and the number of times they communicated. The data volume is large, so performance is important. Which SPL approach returns the desired results efficiently?
The subsearch calculates top IPs by total bytes; the outer search then counts destinations for those IPs.
Why this answer
It uses a subsearch to first identify the top 5 source IPs by total bytes, then passes those IPs to the outer search to efficiently compute the count of communications per destination IP. This approach minimizes the data processed in the outer search by filtering only the relevant source IPs, which is critical for performance on large netflow datasets.
Exam trap
The trap here is that candidates often choose option B, mistakenly thinking that sorting by total_bytes after a stats command that groups by both src_ip and dest_ip will correctly identify the top source IPs, but it actually ranks pairs, not individual source IPs.
How to eliminate wrong answers
Option A is wrong because eventstats adds the total_bytes field to every event but does not filter to the top 5 source IPs, and the subsequent stats count by src_ip, dest_ip ignores the total_bytes field entirely, failing to identify the top source IPs. Option B is wrong because it groups by src_ip and dest_ip before sorting, so the sort and head 5 operate on the combined src_ip-dest_ip pairs rather than on the total bytes per source IP, which does not yield the top 5 source IPs by total bytes. Option D is wrong because the top command with limit=5 src_ip by bytes is syntactically invalid (top does not support a by clause for bytes), and the subsequent search index=net sourcetype=netflow is a separate search that does not use the results from the top command, leading to incorrect or no filtering.