Splunk Search

How can I use results of a stats table to output to another pipe or timechart?

spark2310
Explorer

index=source earliest=-2h sourcetype=e | bucket _time span=1h |stats count by code _time| delta count as difference | eval percdif=round(abs(difference/count)*100,0)|table code, count, difference, percdif|sort -percdif -count|where count>1100|fields code|head 10

I am using this query. output basically will return error codes sorted with high percentage difference (errors are increasing). I am using fields command to only output top 10 errors in table

since this query will show as stats table, how can I use this output to further pipe or do a timechart?

0 Karma

somesoni2
SplunkTrust
SplunkTrust

If your timechart query's timerange is different from last 2 hr, then try like this

index=source [search index=source earliest=-2h sourcetype=e | bucket _time span=1h |stats count by code _time| delta count as difference | eval percdif=round(abs(difference/count)*100,0)|table code, count, difference, percdif|sort -percdif -count|where count>1100|fields code|head 10] 
| timechart count by code

spark2310
Explorer

It did not work, returns 0 results

0 Karma

somesoni2
SplunkTrust
SplunkTrust

How about this

index=source sourcetype=e  [search index=source earliest=-2h sourcetype=e | bucket _time span=1h |stats count by code _time| delta count as difference | eval percdif=round(abs(difference/count)*100,0)|table code, count, difference, percdif|sort -percdif -count|where count>1100|fields code|head 10] 
 | timechart count by code

spark2310
Explorer

does this work if I pass more than one field (code and percdif) to timechart as well?

0 Karma

somesoni2
SplunkTrust
SplunkTrust

It'll. As long as that field is present in main search.

0 Karma

spark2310
Explorer

Thanks working now

0 Karma

somesoni2
SplunkTrust
SplunkTrust

What's your final expected output (that you want to generate for these top 10 error codes)?

0 Karma

spark2310
Explorer

Final output should be a timechart of the top 10 error codes (of query I posted above)

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