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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Unlocking Unified Insights: New Gigamon Federated Search App for Splunk

In today’s data-heavy environment, organizations are caught in a data distribution dilemma. As data volumes ...

GA: New Data Management App in Splunk Platform

Streamlining Data Management: Introducing a unified experience in Splunk Managing data at scale shouldn’t feel ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...