Splunk Search

Combine two searches

qysplunk
Loves-to-Learn Lots

Hi, I have 2 sample logs and I need to combine them into 1 query to grab the "Accesses" values,

qysplunk_0-1624983483540.pngqysplunk_0-1624983483540.png

Due to the log format differences, I have combined 2 different queries using append/sub-search. However I noticed, the subquery results will shows up in the "CE" field, but does not show up in "TC" field .

Or is there another way I can do to capture the Accesses value of these 2 log?

index=nginx (("SourceName=Microsoft Windows security auditing" AND EventCode=4663 AND "Message=An attempt was made to access an object" AND Object_Name="C:\\Program Files\\nginx-1.18.0\\conf\\*.conf" AND ("Accesses:*")) OR (SourceName=Microsoft-Windows-TerminalServices-LocalSessionManager AND EventCode=21))
| eval Date = strftime(_time, "%Y-%d-%m")
| eval Hostname = upper(host)
| eval Date = strftime(_time, "%Y-%d-%m")
| eval Time = strftime(_time, "%Y-%d-%m %H:%M:%S")
| rex field=Message "Accesses:\s+(?P<Action>[^<]+)"\s+Access
| append
[ search index=nginx ((EventCode=4656 Object_Name="C:\\Program Files\\nginx-1.18.0\\conf\\*.conf" Process_Name=C:\\Windows\\explorer.exe) OR (SourceName=Microsoft-Windows-TerminalServices-LocalSessionManager AND EventCode=21))
| rex field=Message max_match=0 "Accesses:\s+(?P<Action>[^>]+)"\s+Access\sReasons]
| rex field=Action mode=sed "s/\s{2,}/\n/g"
| strcat Action "-> " Object_Name CE
| eval TC = mvzip(Time,'CE')
| stats values(TC) as TC latest(Source_Network_Address) as "IP Address" by Date index Hostname
| where isnotnull(TC)
| mvexpand TC
| makemv TC delim=","
| eval Time=mvindex(TC, 0)
| eval "Events"=mvindex(TC, 1)
| fields Time Events Hostname "IP Address"
| where Events' != "-> "

Thank you

Labels (3)
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Free Professional Services for .conf26 Attendees

This year at .conf26, we are doing something a little different. We are bringing the best minds from ...

Defend at Machine Speed: Your Guide to Security Sessions at .conf26

Splunk .conf26   With threats moving at machine speed and attack surfaces expanding across hybrid ...

Where Innovation Takes Flight: The Splunk4Aviation Flight Sim Lands at .conf26

If you hear someone at .conf26 shouting "gear down, GEAR DOWN" across the show floor, you have found us.  The ...