Splunk Search

Timechart with eval

cet
Engager

We are showing a timechart with bandwidth in kilobits per second. We would like to transform this data into kilobytes per second. So the value of bandwidth divided by 1024.

This is the query:

name="Bandwidth by Client"  (515502 OR 410407 OR 414565 OR 444422 OR 777777) | timechart median(measures.Bandwidth) by "dimensions.Client Name"

I tried various things, such as adding an eval before, and then piping it on to the timechart, and also adding an eval function around the median function. But nothing seems to work.

We are using Splunk 6.0.1

Thank you in advance
Gidon

Tags (2)
0 Karma
1 Solution

MuS
Legend

Hi cet,

assuming your kilobits field name is measures.Bandwidth you can do the following:

name="Bandwidth by Client" (515502 OR 410407 OR 414565 OR 444422 OR 777777) | eval measures.Bandwidth='measures.Bandwidth'/1024 | timechart median(measures.Bandwidth) by "dimensions.Client Name"

you can also rename the median in the timechart like this:

name="Bandwidth by Client" (515502 OR 410407 OR 414565 OR 444422 OR 777777) | eval measures.Bandwidth='measures.Bandwidth'/1024 | timechart median(measures.Bandwidth) AS median.KB.Bandwidth by "dimensions.Client Name"

watch out for the '' around the field name in eval, else eval will not ignore the dot in the name. Or rename your field to something without . in the name before the eval.

hope this helps ...

cheers, MuS

View solution in original post

MuS
Legend

Hi cet,

assuming your kilobits field name is measures.Bandwidth you can do the following:

name="Bandwidth by Client" (515502 OR 410407 OR 414565 OR 444422 OR 777777) | eval measures.Bandwidth='measures.Bandwidth'/1024 | timechart median(measures.Bandwidth) by "dimensions.Client Name"

you can also rename the median in the timechart like this:

name="Bandwidth by Client" (515502 OR 410407 OR 414565 OR 444422 OR 777777) | eval measures.Bandwidth='measures.Bandwidth'/1024 | timechart median(measures.Bandwidth) AS median.KB.Bandwidth by "dimensions.Client Name"

watch out for the '' around the field name in eval, else eval will not ignore the dot in the name. Or rename your field to something without . in the name before the eval.

hope this helps ...

cheers, MuS

MuS
Legend

you're welcome 🙂

0 Karma

cet
Engager

GREAT!!! Thanks a million!

0 Karma

MuS
Legend

facepalm stupid me, see my update to fix it 😉

0 Karma

cet
Engager

did you mean:

name="Bandwidth by Client" (515502 OR 410407 OR 414565 OR 444422 OR 777777)| eval measures.Bandwidth=measures.Bandwidth/1024

this does return events. I also checked that measurs.Bandwidth is a number, and yes splunk recognizes it as a number.

0 Karma

MuS
Legend

remove everything after the eval and see if you get anything

0 Karma

cet
Engager

Once I add the eval expression , my timechart stops working. The statistics tab shows 0 stats. What could be the problem?

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...