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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

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

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...