Getting Data In

How to count total number of events from 2 fields that contains a port number?

akke
Explorer

I have a .csv with fields tcp_srcport, and tcp_dstport. I want to find the total amount of traffic using each port.

For example
Query 1:

index="index" 
| stats count by tcp_srcport

Results:

tcp_srcport  |  count
    22            6 
    80            54

Query 2:

index="index" 
| stats count by tcp_dstport

Results:

tcp_dstport  |  count
    22            1 
    80            73

However, what I'm looking for is:

Traffic per port  |  count
       22              7 
       80             127

How do I do this?

Tags (3)
0 Karma
1 Solution

renjith_nair
Legend

@akke,

Try

index="index" | eval Traffic_Per_Port=tcp_srcport+"#"+tcp_dstport|makemv Traffic_Per_Port delim="#"
| stats count by Traffic_Per_Port
---
What goes around comes around. If it helps, hit it with Karma 🙂

View solution in original post

renjith_nair
Legend

@akke,

Try

index="index" | eval Traffic_Per_Port=tcp_srcport+"#"+tcp_dstport|makemv Traffic_Per_Port delim="#"
| stats count by Traffic_Per_Port
---
What goes around comes around. If it helps, hit it with Karma 🙂

akke
Explorer

It works perfectly! Thank you!

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...