Splunk Search

eval streamstats result within timechart can't recognize field

keycoldstorage
Explorer

When I use streamstats to generate last values in the stream I can timechart the results appropriately (without error and with correct results) using timechart avg(last(Comp1))

But, if I want to round the results in the timechart command, the eval fails to locate the field properly: timechart eval(round(avg(last(Comp1)),1)) which results in Error in 'timechart' command: The eval expression has no fields: 'round(avg(last(Comp1)),1)'

What am I doing wrong?

Tags (2)
0 Karma

acdevlin
Communicator

Have you tried something like this?

timechart avg(last(Comp1)) AS myAvg | eval toPrint=round(myAvg,1)

On my end, it added an extra column to the timechart for "toPrint" and had each value rounded to 1 decimal place. However, the "myAvg" column will still be displayed in the chart, and I'm not sure if this is exactly what you're after. If you want to remove the "myAvg" column, you can just add

... | fields toPrint

to the end of the query.

Hope this helps.

0 Karma
Get Updates on the Splunk Community!

Prove Your Splunk Prowess at .conf25—No Prereqs Required!

Your Next Big Security Credential: No Prerequisites Needed We know you’ve got the skills, and now, earning the ...

Splunk Observability Cloud's AI Assistant in Action Series: Observability as Code

This is the sixth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Answers Content Calendar, July Edition I

Hello Community! Welcome to another month of Community Content Calendar series! For the month of July, we will ...