All Apps and Add-ons

How to write the regex for a field extraction to return "nil" if the field contains no data?

appserv
New Member

We are running Server 2008 R2 with NPS services for Radius Auth. Below is an example of the NPS Database-compatible format entries that come through in the log files. Each field is stored in a CSV format

"CLIENTCOMP","IAS",03/07/2008,13:04:33,1,"client",,,,,,,,,9,"10.10.10.10","npsclient",,,,,,,1,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
"CLIENTCOMP","IAS",03/07/2008,13:04:33,2,,"npsclientdc/Users/client",,,,,,,,9,"10.10.10.10","npsclient",,,,,,2,1,"Allow access if dial-in permission is enabled",0,"311 1 10.10.10.11 03/07/2008 20:04:30 1",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

My question is, how can I get a regex query to return 'nil' if the field contains no data? e.g. if we look at the 6th field you will see on the first log entry it contains data

,"client", 

but in the second log entry it comes through empty as

,,

I've used the field extraction in the current spunk release and it works fine until it encounters records that have these empty fields.

0 Karma

jayannah
Builder

I dont think you can put such condition in rex itself. But you can do with fillnull.

E.g:

To fill all fields those doesn't value with "nil"
index=aaaa | rex *************** | fillnull value=nil

To fill field1 & field2 value with "nil" when value for these fields not present
index=aaaa | rex *************** | fillnull value=nil field1 field2

Hope this helps.

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...