Splunk Search

How to return all results if field is not exist?

Dalador
Path Finder

Hi, i use regex to extract fields 
My query is
 | rex field=_raw "(?P<Command>((?<=\bCommand>).*(?=<)))" | rex field=_raw "(?P<Arguments>((?<=\bArguments>).*(?=<)))" |table Task_Name, ComputerName,Command,_time,Arguments |dedup Task_Name, ComputerName,Command,_time,Arguments

How can i return results if Arguments field is not exist? For example: 

...some xml log....
<Command>C:\Windows\System32\wevtutil.exe</Command>
<
Arguments>sl Microsoft-Windows-PrintService/Operational /e:true</Arguments>
...some xml log....

Is Ok


And 

...some xml log....
<Command>C:\Windows\System32\wevtutil.exe</Command>
...some xml log....

Is not OK. 

Labels (4)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @Dalador,

if you share your search I could be more prefice.

Anyway, you have to manage the absence of a field at search level, e.g. putting a fixed value for the missing fields (e.g. | fillnull arguments value="-").

Otherwise commands as stats or dedup don't consider in the search the events with a missing field.

Ciao.

Giuseppe

View solution in original post

diogofgm
SplunkTrust
SplunkTrust

Hi Dalador,

You can try using the keepempty in the dedup:

 

| rex field=_raw "Command\>(?<Command>[^\<]*)" 
| rex field=_raw "Arguments\>(?< Arguments >[^\<]*)" 
| table Task_Name, ComputerName,Command,_time,Arguments 
| dedup Task_Name, ComputerName,Command,_time,Arguments keepempty=true 

 

Or you can try to use the fill null command:

 

| rex field=_raw "Command\>(?<Command>[^\<]*)" 
| rex field=_raw "Arguments\>(?< Arguments >[^\<]*)" 
| table Task_Name, ComputerName,Command,_time,Arguments
| fillnull value="none" 
| dedup Task_Name, ComputerName,Command,_time,Arguments

 

------------
Hope I was able to help you. If so, some karma would be appreciated.
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Dalador,

if you share your search I could be more prefice.

Anyway, you have to manage the absence of a field at search level, e.g. putting a fixed value for the missing fields (e.g. | fillnull arguments value="-").

Otherwise commands as stats or dedup don't consider in the search the events with a missing field.

Ciao.

Giuseppe

Dalador
Path Finder

This works for me, Thanks!

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...