Splunk Search
Highlighted

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

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
Highlighted

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

Contributor

What does your search look like so far?

0 Karma
Highlighted

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

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

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

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
Highlighted

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

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
Highlighted

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

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