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!

How much can you really learn in 3 minutes?

Observability can certainly be hard to understand – there's a lot of jargon and buzzwords and it seems to ...

Event Series: The Agentic SOC: Trust Before Autonomy

AI is fundamentally changing security operations, but true progress requires more than just automation—it ...

Free Professional Services for .conf26 Attendees

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