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!

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