Splunk Search

How to edit my search to find the channel connection count?

New Member

Hi All,

I have CSV file read by Splunk. Here is how the data look like. The field extraction is done.

APP  CHANNEL   IP
app1    chl1      1.1.1.1
app2    chl1      1.1.1.1
app3    chl1      1.1.1.2
app4    chl2      1.1.1.3
app5    chl2      1.1.1.3
app6    chl2      1.1.1.3

I wanted to extract what CHANNEL is connected from which IP and count for each IP connected.
Basically something like below

CHANNEL IP       Count
chl1       1.1.1.1  2
           1.1.1.2  1
chl2       1.1.1.3  3

I tried this, index=mycsv_index | stats count values(CHANNEL) as CHL_COUNT by IP. But it does not seems to give me desired results.
Please help.

Regards,
Abhijit

0 Karma
1 Solution

SplunkTrust
SplunkTrust

Try like this

index=mycsv_index | stats count by IP CHANNEL | stats list(IP) as IP list(count) as Count by CHANNEL

View solution in original post

0 Karma

SplunkTrust
SplunkTrust

Try like this

index=mycsv_index | stats count by IP CHANNEL | stats list(IP) as IP list(count) as Count by CHANNEL

View solution in original post

0 Karma

SplunkTrust
SplunkTrust

Try this

index=mycsv_index | stats count by IP CHANNEL | stats list(IP) as IP list(count) as Count sum(count) as TotalConn by CHANNEL
0 Karma

New Member

You are awesome..Thanks

0 Karma

New Member

Thanks @somesoni2. Worked perfectly for me. Appreciate your help.

Can I also get a total IPs count added to the same output. If this works out I can use that column (say - TotalChannelConn) to send alert when a channel total connection reaches a certain threshold.
Something like this.

+---------+---------+-------+-------------+
| CHANNEL | IP | COUNT | TOTAL_COUNT |
+---------+---------+-------+-------------+
| chl1 | 1.1.1.1 | 2 | 3 |
+---------+---------+-------+-------------+
| | 1.1.1.2 | 1 | |
+---------+---------+-------+-------------+
| chl2 | 1.1.1.3 | 3 | 3 |
+---------+---------+-------+-------------+

0 Karma