Splunk Search

Calculating percentages for source and destination IP data by source count and then by source-destination pair

splunkhelp
Explorer

Good Day!

Given the following data...

srcdst
1.2.3.49.8.7.6
1.2.3.49.8.7.6
1.2.3.49.8.7.6
4.3.2.16.7.8.9
1.2.3.45.6.7.8

I'd like to display a table showing the percentage of events by src and then breakdown this further by displaying the percentage of total events by src-dst pair...

The results would like like...

srcsrc %dst - dst %
1.2.3.480%9.8.7.6 60%
5.6.7.8 20%
4.3.2.120%6.7.8.9 20%

Any help would me much appreciated.

Thanks.

Tags (2)

rturk
Builder

Hi Splunkhelp (...if indeed that is your real name!...)

So I got bored and wrote what is probably an inefficient search that someone else is more than welcome to improve upon. After putting your table into a CSV file called ip_report.csv, I was able to get the following table:

alt text

With the following (ugly, ugly) search:

| inputlookup ip_report.csv 
| top src, dst 
| rename percent AS dst_perc 
| join src [
      | inputlookup ip_report.csv 
      | top src 
      | rename percent AS src_perc ]
| fields src, src_perc, dst, dst_perc 
| sort src

If you replace the "|inputlookup ip_report.csv" with your base search, it will hopefully give you what you're looking for 🙂

However I know a better way to do this exists...

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...