Splunk Search

How to find SSH session in past month

disasters
Explorer

I want to know that there are or not SSH sessions which is in last 5 minutes in past 1 month. (except today)

- I want to compare srcip and dstip

- Time range picker (last 5 minutes)

index=fw AND dstport=22 NOT [ search  index=fw AND dstport=22 earliest=-1mon@mon latest=-1day@day | fields + srcip, dstip]
| dedup srcip, dstip
| table _time, srcip, dstip, dstport, protocal, action, hostname

 

this is not working correctly.


Labels (1)
0 Karma
1 Solution

manjunathmeti
Champion

Hi @disasters 

Try this query,

index=fw dstport=22 NOT [ search  index=fw dstport=22 earliest=-1mon@d latest=-1d@d  | stats count by srcip, dstip |  fields srcip, dstip | format]
| dedup srcip, dstip
| table _time, srcip, dstip, dstport, protocal, action, hostname

 

If this reply helps you, an upvote/like would be appreciated.

View solution in original post

disasters
Explorer

It works.

Could you explain purpose of stats, format?

0 Karma

manjunathmeti
Champion

stats is used as dedup to remove duplicate records and format is used to convert results into a single linear search string.

More on format here: https://docs.splunk.com/Documentation/SplunkCloud/latest/Search/Changetheformatofsubsearchresults#Ch...

0 Karma

manjunathmeti
Champion

Hi @disasters 

Try this query,

index=fw dstport=22 NOT [ search  index=fw dstport=22 earliest=-1mon@d latest=-1d@d  | stats count by srcip, dstip |  fields srcip, dstip | format]
| dedup srcip, dstip
| table _time, srcip, dstip, dstport, protocal, action, hostname

 

If this reply helps you, an upvote/like would be appreciated.

Get Updates on the Splunk Community!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...