Splunk Search

How to plot values (without using max(), avg(), count()...)

vtrujillo
Explorer

Hello.

I would like to create a line chart but, I don't want to plot a max() or an avg()?

I just want to show the numbers that CPU_IDLE_USAGE (in this case) returns. For example:

_time              CPU_ID CPU_IDLE_USAGE 
8/23/10 11:25:00.000 PM 0 90 
8/23/10 11:20:00.000 PM 0 83 
8/23/10 11:15:00.000 PM 0 81 
8/23/10 11:10:00.000 PM 0 82 
8/23/10 11:05:00.000 PM 0 88 
8/23/10 11:00:00.000 PM 0 78 

I would like to plot the following values: 90, 83, 81, 82, 88... etc. How can I do that?

So far I'm using something like:

source=*slu* CPU_ID=0| timechart max(CPU_IDLE_USAGE)

I already tried:

source=*slu* CPU_ID=0| timechart CPU_IDLE_USAGE

but Splunks says the use of a function is mandatory.

What can I do?

Thanks.

Thank you again

Tags (1)
1 Solution

gkanapathy
Splunk Employee
Splunk Employee

Please see: http://answers.splunk.com/questions/5991/simple-question-i-think-charting-field-values-over-time

You can use the first() function:

 source=*slu* CPU_ID=0| timechart first(CPU_IDLE_USAGE) as CPU_IDLE_USAGE

The use of a function is mandatory because timechart must know how to resolve potential multiple values in an interval. If you are certain there are none, then the result is identical.

One of the purposes of stats/chart/timechart is to aggregate varying amounts of data over varying intervals. If you have no need to do this, you can also use table:

 source=*slu* CPU_ID=0| table _time CPU_IDLE_USAGE

View solution in original post

mikesela
New Member

I'd recommend doing something like this:

source=slu CPU_ID=0| table _time CPU_IDLE_USAGE

This creates a table with actual values in it. By adding a _time column, you can then click over to the Visualizations tab and it will know how to chart it. Note that this won't work for a large number of data points.

0 Karma

gkanapathy
Splunk Employee
Splunk Employee

Please see: http://answers.splunk.com/questions/5991/simple-question-i-think-charting-field-values-over-time

You can use the first() function:

 source=*slu* CPU_ID=0| timechart first(CPU_IDLE_USAGE) as CPU_IDLE_USAGE

The use of a function is mandatory because timechart must know how to resolve potential multiple values in an interval. If you are certain there are none, then the result is identical.

One of the purposes of stats/chart/timechart is to aggregate varying amounts of data over varying intervals. If you have no need to do this, you can also use table:

 source=*slu* CPU_ID=0| table _time CPU_IDLE_USAGE

vtrujillo
Explorer

Thank you very much!

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