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!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...