Splunk Search

Outputlookup followed by stats command causes extra column to be generated

Anders333
Explorer

Hello, I came across some unexpected search behaviour today.

When using the outputlookup command followed by a stats command, as in the example, an additional empty column is added to the lookup file.

| makeresults
| eval test = "this is a testing thing"
| outputlookup append=false testindjiasbhd8a0.csv
| stats values(test) as testing

Expected lookup table:

_time

test

2025-11-14 14:19:07this is a testing thing

Actual lookup table:

_timetesttesting
2025-11-14 14:19:07this is a testing thing 

 

I don't know if this is a bug or expected behaviour., and I was unable to find anything that would explain it.

Thanks 🙂

Labels (1)
Tags (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

My understanding is that as part of the search processing, the processor determines which fields are required at the end and those are then available to be output by the outputlookup command. It doesn't have to be a stats command or even a field with any values. For example, a similar result will be shown if you try this:

| makeresults
| eval test = "this is a testing thing"
| outputlookup append=false testindjiasbhd8a0.csv
| table testing

However, you can work around this by removing the field before it is created

| makeresults
| eval test = "this is a testing thing"
| fields - testing
| outputlookup append=false testindjiasbhd8a0.csv
| stats values(test) as testing

View solution in original post

PrewinThomas
Motivator

@Anders333 

The lookup file is created with the fields _time and test, then you run stats values(test) as testing. This produces a new field testing in the search results.
Splunk lookup files are schema‑flexible. If later commands introduce new fields, splunk adds them as new columns, even if they’re empty for existing rows.


If you need only testing field then write your outputlookup command after your stats.
Eg:

| makeresults
| eval test = "this is a testing thing"

| stats values(test) as testing | outputlookup append=false test.csv


Regards,
Prewin
🌟If this answer helped you, please consider marking it as the solution or giving a Karma. Thanks!

ITWhisperer
SplunkTrust
SplunkTrust

My understanding is that as part of the search processing, the processor determines which fields are required at the end and those are then available to be output by the outputlookup command. It doesn't have to be a stats command or even a field with any values. For example, a similar result will be shown if you try this:

| makeresults
| eval test = "this is a testing thing"
| outputlookup append=false testindjiasbhd8a0.csv
| table testing

However, you can work around this by removing the field before it is created

| makeresults
| eval test = "this is a testing thing"
| fields - testing
| outputlookup append=false testindjiasbhd8a0.csv
| stats values(test) as testing
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...