Splunk Search

Table fields after using stats and xyseries

tommy0x2A
Engager

I apparently seem to be truncating fields after using the stats and xyseries commands. I found that if I include the fields being truncated to stats after like so then I retain these fields:
|stats values(TestResult) as Result by SN CoreName Temperature FrequencyPlanQSPR

However, I had to do a weird eval append thing to SN in my case, to be able to save these fields, Temperature and FrequencyPlanQSPR in my case, after issuing the xyseries command to be able to use them later in a table command.
|eval SN = MachineName+":"+SN+":"+Temperature+":"+FrequencyPlanQSPR
...
|xyseries SN CoreName Result
. . .
|eval flds = split(SN,":")
|eval Temperature = mvindex(flds,2)
|eval FrequencyPlanQSPR = mvindex(flds,3)
|table SN MachineName Temperature FrequencyPlanQSPR *

Is this a good way to handle this situation? Is there a better way to do it?

Thanks Tom

0 Karma
1 Solution

somesoni2
Revered Legend

That is the correct way. xyseries supports only 1 row-grouping field so you would need to concatenate-xyseries-split those multiple fields. However, if there is no transformation of other fields takes place between stats and xyseries, you can just merge those two in single chart command. So, another variation would be

your base search 
|eval SN = MachineName+":"+SN+":"+Temperature+":"+FrequencyPlanQSPR
| chart values(TestResult) over SN by CoreName
| rex field=SN "(?<MachineName>.+):(?<SN>.+):(?<Temperature>.+):(?<FrequencyPlanQSPR>.+)"
|table SN MachineName Temperature FrequencyPlanQSPR *

View solution in original post

somesoni2
Revered Legend

That is the correct way. xyseries supports only 1 row-grouping field so you would need to concatenate-xyseries-split those multiple fields. However, if there is no transformation of other fields takes place between stats and xyseries, you can just merge those two in single chart command. So, another variation would be

your base search 
|eval SN = MachineName+":"+SN+":"+Temperature+":"+FrequencyPlanQSPR
| chart values(TestResult) over SN by CoreName
| rex field=SN "(?<MachineName>.+):(?<SN>.+):(?<Temperature>.+):(?<FrequencyPlanQSPR>.+)"
|table SN MachineName Temperature FrequencyPlanQSPR *
Get Updates on the Splunk Community!

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

A Guide To Cloud Migration Success

As enterprises’ rapid expansion to the cloud continues, IT leaders are continuously looking for ways to focus ...

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...