Ah, this is the perfect use case for this (still) undocumented command, multireport :
sourcetype=myhttpdata
| multireport
[ stats count by SourceIP ]
[ stats count by SourceIP DestinationIP ]
[ stats count by SourceIP DestinationIP HTTPStatus ]
This gives you the data you need.
Now, you need to sort the rows into the order you'd like better. This kind of works:
sourcetype=myhttpdata
| multireport
[ stats count by SourceIP ]
[ stats count by SourceIP DestinationIP ]
[ stats count by SourceIP DestinationIP HTTPStatus ]
| sort SourceIP DestinationIP HTTPStatus
But that puts the summary rows for SourceIP and Destination IP at the end of their categories. To move them to the beginning, you need to do something hacky:
sourcetype=myhttpdata
| multireport
[ stats count by SourceIP ]
[ stats count by SourceIP DestinationIP ]
[ stats count by SourceIP DestinationIP HTTPStatus ]
| fillnull value="_ANY_" SourceIP DestinationIP HTTPStatus
| sort SourceIP DestinationIP HTTPStatus
And then if you want you can do an "eval" to convert the "_ANY" back to an empty string or null. But that gives you things in lexicographic order. What if you want them in order of most common SourceIP, then most common DestinationIP? Then you'll have to do:
sourcetype=myhttpdata
| multireport
[ stats count as by SourceIP | eval count_sip=count ]
[ stats count as by SourceIP DestinationIP | eval count_sip_dip=count ]
[ stats count as by SourceIP DestinationIP HTTPStatus ]
| fillnull value="_ANY_" SourceIP DestinationIP HTTPStatus
| eventstats first(eval(coalesce(count_sip,null()))) as count_sip by SourceIP
| eventstats first(eval(coalesce(count_sip_dip,null()))) as count_sip_dip by SourceIP DestinationIP
| sort -count_sip +SourceIP -count_sip_dip +DestinationIP -count
| fields - count_sip count_sip_dip
Now, this gives similar results (but not the same, it lacks summary rows and instead uses different columns for the summary values):
sourcetype=myhttpdata
| eventstats count as count_sip by SourceIP
| eventstats count as count_sip_dip by SourceIP DestinationIP
| stats count first(count_sip) as count_sip
first(count_sip_dip) as count_sip_dip
by SourceIP DestinationIP HTTPStatus
| sort -count_sip +SourceIP -count_sip_dip +DestinationIP -count
but likely runs a lot slower. You could also use:
sourcetype=myhttpdata
| stats count by SourceIP DestinationIP HTTPStatus
| eventstats sum(count) as count_sip_dip by SourceIP DestinationIP
| eventstats sum(count_sip_dip) as count_sip by SourceIP
| sort -count_sip +SourceIP -count_sip_dip +DestinationIP -count
which will be a lot better, but for large data sets will still be slower than the version using multireport.
... View more