Splunk Search

How to generate a search that determines inactivity of firewall rules?

elpfarr
Explorer

I'm having issues creating a search that determines inactivity of firewall rules. I'd like to determine if a firewall rule was seen 31+ days ago, but has not reported in the last 30 days.

For example, if "fwrule=3001" was triggered 31 days ago, but not since, it should populate my report.

0 Karma
1 Solution

elpfarr
Explorer

This search is working for me, I've validated the output and it's accurate. I can change "-30d" to whatever time frame the search should alert on.

ex. "-7d" = displays rules that haven't fired in the last 7 days, but have before that

I've set my time range to "All Time."
I'm open for comments on making this more efficient

 sourcetype="my_source" fwrule="*"
| stats latest(_time) as Time by fwrule
| where relative_time(now(), "-30d") > Time
| eval Last_seen=strftime(Time, "%m/%d/%y %H:%M:%S")
| fields - Time
| sort - Last_seen

View solution in original post

0 Karma

elpfarr
Explorer

This search is working for me, I've validated the output and it's accurate. I can change "-30d" to whatever time frame the search should alert on.

ex. "-7d" = displays rules that haven't fired in the last 7 days, but have before that

I've set my time range to "All Time."
I'm open for comments on making this more efficient

 sourcetype="my_source" fwrule="*"
| stats latest(_time) as Time by fwrule
| where relative_time(now(), "-30d") > Time
| eval Last_seen=strftime(Time, "%m/%d/%y %H:%M:%S")
| fields - Time
| sort - Last_seen
0 Karma

troyward
Explorer
<base search>
| stats latest by fwrule as last_seen
| eval days_since = (now() - last_seen) / 86400 
0 Karma

elpfarr
Explorer

I performed the search, and had to make a few adjustments (no results from above search):

| stats latest(_time) as Time by fwrule

From here, I'm having issues with the eval function. My stats statement records 'Time' in epochtime, but I need to then find all rules that have had their latest 30 days before now. Any other ideas?

0 Karma

troyward
Explorer

When you do the eval and get the difference between now and the event date and then device that by 86400 that gives you the number of days since it fired. Then just filter with the search command for days_since > 30

0 Karma

adayton20
Contributor

What does your search look like so far?

0 Karma
Get Updates on the Splunk Community!

What You Read The Most: Splunk Lantern’s Most Popular Articles!

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Announcing the General Availability of Splunk Enterprise Security 8.1!

We are pleased to announce the general availability of Splunk Enterprise Security 8.1. Splunk becomes the only ...

Developer Spotlight with William Searle

The Splunk Guy: A Developer’s Path from Web to Cloud William is a Splunk Professional Services Consultant with ...