All Apps and Add-ons

how can I get the value of a user embedded field named "index"?

juniormint
Communicator

I have log events that contain an user embedded field named "index". Out of the box Splunk seems to effectively ignore user's index when auto extracting field.

My goal is to find a good way to get the value for user's index field. I'm not really sure of the right way to deal with this situation, so please feel free to suggest anything (I'm already working on getting rid of the poorly named field).

My initial thought was to use rex, but I'm having a bit of a time getting the right regex. Suggestions for a correct rex expression?

rex field=_raw ".*index=\"(<app>.*)\""

_raw is something like:

data="xxxx",index="allgoodman",session="12345"

Thanks for any help.
-J

0 Karma
1 Solution

yannK
Splunk Employee
Splunk Employee

You have the right approach,
the splunk index will overwrite your automatic field extraction.

if you data is like data="xxxx",index="allgoodman",session="12345"

you can define a new field and use a rex.

<mysearch> | rex "index=\"<?index_app>\w+\"" | table index index_app _raw

and if you create an automatic field extraction, you can drop the escaped double quotes.

View solution in original post

yannK
Splunk Employee
Splunk Employee

You have the right approach,
the splunk index will overwrite your automatic field extraction.

if you data is like data="xxxx",index="allgoodman",session="12345"

you can define a new field and use a rex.

<mysearch> | rex "index=\"<?index_app>\w+\"" | table index index_app _raw

and if you create an automatic field extraction, you can drop the escaped double quotes.

yannK
Splunk Employee
Splunk Employee

The field is optional, by default is applied to _raw.
You need to specify it if you already have the text in a field to narrow the extraction.

0 Karma

juniormint
Communicator

This seems to work. Thanks so much!

<mysearch> | rex field=_raw "index=\"(?<index_app>\w+)\"" | table index, index_app, _raw
0 Karma

juniormint
Communicator

does that rex expression really work? do you need a field or sed in there and probably an _raw?

0 Karma
Get Updates on the Splunk Community!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...