Splunk Search

Flatten Search Results

shinglau
New Member

I am currently trying to use the Splunk REST API to extract a heap of data.
I have written a search query:

(index=* OR index=_*) (index="myindex") | table "order-no", "order-date", "price"

But it provides a result set which looks like this:

"Order-no", "order-date", "price","quantity"
1        ,       20/05/2017        , 1.0, 1
--------------------, 2.0, 1
---------------------,3.0, 2

It rolls 2.0 and 3.0 up to 1 record along side row order-no = 1.
So when i try to export this as a CSV using REST API, the output is all jumbled up.

Is there a way to flatten this in the search so it shows as:

"Order-no", "order-date", "price","quantity"
1        ,       20/05/2017        , 1.0, 1
1        ,       20/05/2017        , 2.0, 1
1        ,       20/05/2017        , 3.0, 2

I've tried to use mvexpand, but it appears that it works on a individual column level and if i do a mvexpand on both of those last 2 columns, it effectively does a cross join on the entire data which causes incorrect values
Thanks in advance.

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...