Splunk Search

How do you write a Regular expression in props.conf for only one field?

rakeshksingh
New Member

Hi All,

How do I write a regular expression in props.conf for only one field ?

like rex field=ab "regex"

thanks
Rakesh

0 Karma

dkeck
Influencer

HI,

if you want to add a search time field extraction within props.conf, just use EXTRACT

[your-sourcetype]    
EXTRACT-<class> = [<regex>|<regex> in <src_field>]
    * Used to create extracted fields (search-time field extractions) that do
      not reference transforms.conf stanzas.

for reference see : http://docs.splunk.com/Documentation/Splunk/7.2.1/Admin/Propsconf

Please keep in mind that this will require a refresh/debug= http[s]://[splunkweb hostname]:[splunkweb port]/debug/refresh

0 Karma

rakeshksingh
New Member

Hi

tried but no luck.

[your-sourcetype]

EXTRACT-ab1 = [(?{.) in ab]

Could you take a look and guide me which part i am missing ?

0 Karma

FrankVl
Ultra Champion

Those square brackets shouldn't be there.

0 Karma

rakeshksingh
New Member

Thanks for response,

in ab field, data is on json format

0 Karma

rakeshksingh
New Member

tried below also but no luck.

EXTRACT-ab1 = (?{.) in ab

ab as field name

and tried with props and conf but no luck

[mysourcetype]

REPORT-myextract = myextract

Then in transforms.conf:

[myextract]

SOURCE_KEY = ab

REGEX = regex

0 Karma

FrankVl
Ultra Champion

Your EXTRACT doesn't look like a valid regex (but perhaps some characters went missing by posting it here without using the post as code option (use the 101010 button in the message editor toolbar, or enclose the code in `)

Your transforms is impossible to comment on without posting the actual regex. Does that include named capturing groups (e.g. (?<fieldname>regex)? Otherwise you also need a FORMAT setting to specify what field(s) the capture group(s) should be mapped to.

0 Karma

dkeck
Influencer

Do you have an example of the data?

Did you test your regex? for example here: https://regex101.com/

Syntax for EXTRACT should look like this :

EXTRACT-threadid = (?<threadid>[0-9A-Fa-f]+)\s+
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...