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!

Splunk Observability Cloud’s AI Assistant in Action Series: Analyzing and ...

This is the second post in our Splunk Observability Cloud’s AI Assistant in Action series, in which we look at ...

Elevate Your Organization with Splunk’s Next Platform Evolution

 Thursday, July 10, 2025  |  11AM PDT / 2PM EDT Whether you're managing complex deployments or looking to ...

Splunk Answers Content Calendar, June Edition

Get ready for this week’s post dedicated to Splunk Dashboards! We're celebrating the power of community by ...