Splunk Search

How to properly evaluate integer list from inputlookup subsearch?

oneillryan93
New Member

I'm attempting to use a subsearch to extract a number of integers in order to transpose those integers as columns. Here is the code for the subsearch:

|eval thing=[| inputlookup lookup.csv
| stats values(tests) by tests
| sort 15 -tests
| stats values(tests) as str
| return $str]

The search run by itself returns something like "123 124 125 126 127...", so I'm confused why when I run it as a subsearch it returns:

"Error in 'eval' command: The expression is malformed."

I've tried following some similar examples I've seen here, but I can't seem to find anything that works for me.
Thanks.

Tags (1)
0 Karma

somesoni2
Revered Legend

The return command, by default, returns only the single value from first row of specified field (as string). The field 'str' in your subsearch is a multivalued field and thus causes issue in eval. Assuming you want to return list of all 15 'tests' values in a space-delimited string and save it to field 'thing', try something like this

...|eval thing=[| inputlookup lookup.csv | stats values(tests) by tests | sort 15 -tests | stats values(tests) as str | nomv str | eval str="\"".str."\"" | return $str]

The nomv command changes 'str' to a single valued field and next eval will add double qoutes around values as it'll be a space delimited string.

0 Karma
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!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

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 ...