Splunk Search

Apply search field extraction to props.conf and/or transforms.conf so extraction done at index-time

gjlewis
Explorer

I have some BIG-IP data that I am ingesting as plain text files, as I can't directly connect to the BIG-IP servers due to security rules.

I have used regex field extractions to extract various data items at index-time, e.g. vs_pkts_in from props.conf:

EXTRACT-vs_pkts_in = VIRTUAL\s\w+\s+\w+\s+\w+\s+\|\s+\w+\s+\w+\s+\w+\s+\|\s+\(\w+,\s+\w+,\s+\w+,\s+\w+\)\s+=\s+\([\w.]+,\s+[\w.]+,\s+[\w.]+,\s+[\w.]+\)\s+\|\s+\(\w+,\w+\)\s+\w+\s+=\s+\((?P<vs_pkts_in>[\w.]+)

Unfortunately, this field value is recorded in various formats: 123, 1.23M, 1.23G and 1.23T. I have used the below search to convert the values into bytes, but so far I have been unable to work out how to apply this conversion at index-time, with the above extraction.

 index=bigip 
| makemv vs_pkts_in 
| mvexpand vs_pkts_in 
| rex field=vs_pkts_in "^(?<Value>[\d.]*)(?<Unit>[\w.]*)$" 
| eval factor=case(Unit="B",1,Unit="K",1024,Unit="M",1024*1024,Unit="G",1024*1024*1024,Unit="T",1024*1024*1024*1024,true(),1) 
| eval vs_pkts_in_bytes=Value*factor

I have approx 20 fields that this applies to, hence why I'd like to apply the conversion at index-time rather than search-time, as my search queries are very large.

Any help or advice on how to do this would be appreciated.

0 Karma
1 Solution

micahkemp
Champion

It's not possible to run eval or other such functions at index time. It's really only regex that is possible, and unfortunately unit conversion isn't something that would be possible with regex.

One option would be to use another process to modify your data prior to it being made available to Splunk. This could be a scripted or modular input, or even just a cron job. But unfortunately there is not a way to do that type of modification on standard splunk inputs at index time.

View solution in original post

micahkemp
Champion

It's not possible to run eval or other such functions at index time. It's really only regex that is possible, and unfortunately unit conversion isn't something that would be possible with regex.

One option would be to use another process to modify your data prior to it being made available to Splunk. This could be a scripted or modular input, or even just a cron job. But unfortunately there is not a way to do that type of modification on standard splunk inputs at index time.

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...