Knowledge Management

Selecting all remaining fields as data fields in xyseries

kshashank004
Loves-to-Learn

Hello,

I am trying to use xyseries to transform the table and needed to know a way to select all columns as data field for xyseries command.

For instance: 

I have a table like this:

xAxisyAxisrandomField1randomField2
abcghi132
defghi2242

 

I want the output as follows:

xAxisrandomField1: ghirandomField2:ghi
abc132
def2242

 

I can do this using the following command

 

 

xyseries xAxix, yAxis, randomField1, randomField2

 

 

But the catch is that the field names and number of fields will not be the same for each search. Meaning, in the next search I might have 3 fields (randomField1, randomField2, randomField3).

Is there any way of using xyseries with dynamic field names? Or is there any other command that can be used?

Thanks

Labels (1)
0 Karma

to4kawa
Ultra Champion
| makeresults 
| eval _raw="xAxis,yAxis,randomField1,randomField2,randomField3
abc,ghi,1,32,56
def,ghi,22,42,67" 
| multikv forceheader=1 
| table xAxis,yAxis,randomField1,randomField2,randomField3 
| xyseries xAxis,yAxis 
    [| makeresults 
    | eval _raw="xAxis,yAxis,randomField1,randomField2,randomField3
abc,ghi,1,32,56
def,ghi,22,42,67" 
    | multikv forceheader=1 
    | table xAxis,yAxis,randomField1,randomField2,randomField3 
    | untable xAxis randomField count 
    | where randomField!="yAxis" 
    | stats values(randomField) as query 
    | nomv query 
    | return $query ]

xyseries needs double search.

0 Karma

renjith_nair
Legend

@kshashank004,

Try

"your search"
|foreach * [eval <<FIELD>>:{yAxis}=<<FIELD>>]

Or if don't want actual fields and only want to persist xAxis

"your search"
|eval _xaxis=xAxis
|foreach * [eval <<FIELD>>:{audittrail}=<<FIELD>>]|fields *:*
|rename _xaxis as xAxis

 

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
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!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Observability Simplified: Combining User Experience, Application Performance & ...

Tech Talk Observability Simplified: Combining User Experience, Application Performance & Network ...

Event Series May & June: From Network Visibility to Service Intelligence

Unifying the Network: Moving from Alert Noise to Service Intelligence with Splunk ITSI In today’s hybrid ...