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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...