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
SplunkTrust
SplunkTrust

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
SplunkTrust
SplunkTrust

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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...