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!

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...

Spotting Financial Fraud in the Haystack: A Guide to Behavioral Analytics with Splunk

In today's digital financial ecosystem, security teams face an unprecedented challenge. The sheer volume of ...

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability As businesses scale ...