Getting Data In

Outputlookup creating csv with columns that are alphabetical?

maxsteel
Explorer

I have a search that gathers a bunch of data from various sources and appends to 1 big stats that I have reporting in a customized column order.
After I weed out some things I don't like, it looks perfect in search, so I appended a:
| outputlookup file.csv
to the very bottom so it'd write to a reusable csv.

When I look at the dataset/csv it is rearranging my columns into an alphabetical order (caps first).

Is there any way to keep my order in the csv so when I reference it later in an inputlookup I don't need to manually reorder it everytime?

 

Labels (1)
0 Karma
1 Solution

maxsteel
Explorer

So table "works" but it was too much to keep adding this logic as I have a few columns, and I didn't want to have to keep editing them everywhere as I add/remove them.

In the end, I fixed it differently (going to share how for the next person).  Instead of using a csv (that, once again, gets read in will alphabetize the columns (booooo!)) I leveraged a report!  It's probably a better way anyway.

Once the report was scheduled, I leverage it using 

loadjob savedseach="user:app:reportname" 

This preserves column order!!

 

 

 

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Do you have a table command in the query?  That's a sure way to set the order in which fields appear.

Why do you have to reorder fields following inputlookup?  Splunk doesn't care what the order is.

---
If this reply helps you, Karma would be appreciated.
0 Karma

maxsteel
Explorer

I leveraged stats to create the output in a specific order, not table.

It appears that the outputlookup is rearranging my reusable csv alphabetically and then when I call it later it's showing this new alphabetical order.

I'd rather it be in the same order as my stats so that I don't have to reorder every time I call the csv.

(you are right that splunk doesn't care about order, but I do 🙂 )

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try putting a table command before outputlookup to enforce the field order.  Not sure if it will help, but it might.

---
If this reply helps you, Karma would be appreciated.
0 Karma

maxsteel
Explorer

I was hoping to not have to create a table for each, hence the original question.  

That being said, if splunk likes to alphabetize outputlookup tables, then I guess I have to use a table and specify order each time.. yuk..

 

0 Karma

maxsteel
Explorer

So table "works" but it was too much to keep adding this logic as I have a few columns, and I didn't want to have to keep editing them everywhere as I add/remove them.

In the end, I fixed it differently (going to share how for the next person).  Instead of using a csv (that, once again, gets read in will alphabetize the columns (booooo!)) I leveraged a report!  It's probably a better way anyway.

Once the report was scheduled, I leverage it using 

loadjob savedseach="user:app:reportname" 

This preserves column order!!

 

 

 

Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Laser Bananas and Edge Hubs: Exploring Operational Technology (OT) Data Through a ...

  OT is a different environment to traditional IT and can have interesting challenges when interfacing the ...

Event Series: Mastering AI Tokenomics and Splunk Agent Observability

Beyond the Black Box: Correlating AI Performance and Tokenomics with Splunk Agent Observability   As ...

span_metrics: The OpenTelemetry-Idiomatic Way to See Inside Your Services

You open a trace in Splunk Observability Cloud and everything looks fine. One root span, order-pipeline, with ...