Splunk Search

How do I timechart the percentage of a total?

jrnastase
Explorer

Hello all,

Currently I have acquired a timechart in the format:

Field_A / Field_B / Field_C / Field_D / Total
//// 10 ///////// 20 ///////// 15 ////////// 5 //////// 50
etc. using the | addtotals command.

I would like to somehow change each column to represent a percentage of the total to wind up with something like:
Field_A / Field_B / Field_C / Field_D
//// 0.2 //////// 0.4 //////// 0.3 ///////// 0.1

Thanks very much. Any help would be greatly appreciated!

Tags (1)
0 Karma

adonio
Ultra Champion

hello there,

there are many ways to achieve, if you keep naming convention, maybe try the foreach command. here is one example with eval to create desired values. run this search anywhere:

| gentimes start="10/15/2018:00:00:00" end="10/15/2018:10:00:00" increment=15min
| eval _time = starttime 
| eval field_a = random()%100
| eval field_b = random()%100
| eval field_c = random()%100
| eval field_d = random()%100
| eval total = field_a + field_b + field_c + field_d
| table _time field* total
| rename COMMENT as "the above creates data, below is the solution"
| eval field_a_perc = round(field_a/total*100, 2)
| eval field_b_perc = round(field_b/total*100, 2)
| eval field_c_perc = round(field_c/total*100, 2)
| eval field_d_perc = round(field_d/total*100, 2)
| timechart span=15m max(field_a_perc) as field_a_perc max(field_b_perc) as field_b_perc max(field_c_perc) as field_c_perc max(field_d_perc) as field_d_perc

screenshot:

alt text

hope it helps

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...