Splunk Search

How to calculate the percentage for a trend?

jip31
Motivator

Hello

in the request below, i try to calculate a trend between 2 report
but i try to do this :
- if the data of a report is the same in anothr report, the result is 100% but i want 0% in this case
- if the value of the first report is > to the value of the second report then i want to divise value 2 by value 1
- if the value of the second report is > to the value of the first report then i want to divise value 1 by value 2

Could you help me please??

index="windows-wmi" sourcetype="wmi:DiskRAMLoad"  Name="mfetp.exe" 

| head 10 

| stats avg(ReadOperationCount) as mfetp_ReadOperation_AVG, avg(ReadTransferCount) as mfetp_ReadTransfer_AVG, avg(WriteOperationCount) as mfetp_WriteOperation_AVG, avg(WriteTransferCount) as mfetp_WriteTransfer_AVG 

| appendcols 

[ search index="windows-wmi" sourcetype="wmi:DiskRAMLoad"  Name="mfetp.exe" 

| head 10 

| stats avg(ReadOperationCount) as mfetp_ReadOperation_AVG2, avg(ReadTransferCount) as mfetp_ReadTransfer_AVG2, avg(WriteOperationCount) as mfetp_WriteOperation_AVG2, avg(WriteTransferCount) as mfetp_WriteTransfer_AVG2 BY host]

| eval percReadOperation_AVG=round((mfetp_ReadOperation_AVG/mfetp_ReadOperation_AVG2)*100,2),

   percReadTransfer_AVG=round((mfetp_ReadTransfer_AVG/mfetp_ReadTransfer_AVG2)*100,2),

    percWriteOperation_AVG=round((mfetp_WriteOperation_AVG/mfetp_WriteOperation_AVG2)*100,2),

    percWriteTransfer_AVG=round((mfetp_WriteTransfer_AVG/mfetp_WriteTransfer_AVG2)*100,2) | table percReadOperation_AVG percReadTransfer_AVG percWriteOperation_AVG percWriteTransfer_AVG
0 Karma
1 Solution

somesoni2
Revered Legend

Give this a try

index="windows-wmi" sourcetype="wmi:DiskRAMLoad"  Name="mfetp.exe" 
 | head 10  
 | stats avg(ReadOperationCount) as mfetp_ReadOperation_AVG, avg(ReadTransferCount) as mfetp_ReadTransfer_AVG, avg(WriteOperationCount) as mfetp_WriteOperation_AVG, avg(WriteTransferCount) as mfetp_WriteTransfer_AVG 
 | appendcols  
 [ search index="windows-wmi" sourcetype="wmi:DiskRAMLoad"  Name="mfetp.exe" 
 | head 10  
 | stats avg(ReadOperationCount) as mfetp_ReadOperation_AVG2, avg(ReadTransferCount) as mfetp_ReadTransfer_AVG2, avg(WriteOperationCount) as mfetp_WriteOperation_AVG2, avg(WriteTransferCount) as mfetp_WriteTransfer_AVG2 BY host]
 | foreach mfetp_*_AVG [| eval perc<<MATCHSTR>>_AVG=case('<<FIELD>>'=='<<FIELD>>2',0, '<<FIELD>>'>'<<FIELD>>2', round(('<<FIELD>>'/'<<FIELD>>2')*100,2), true(), round(('<<FIELD>>2'/'<<FIELD>>')*100,2))]
| table percReadOperation_AVG percReadTransfer_AVG percWriteOperation_AVG percWriteTransfer_AVG

View solution in original post

0 Karma

somesoni2
Revered Legend

Give this a try

index="windows-wmi" sourcetype="wmi:DiskRAMLoad"  Name="mfetp.exe" 
 | head 10  
 | stats avg(ReadOperationCount) as mfetp_ReadOperation_AVG, avg(ReadTransferCount) as mfetp_ReadTransfer_AVG, avg(WriteOperationCount) as mfetp_WriteOperation_AVG, avg(WriteTransferCount) as mfetp_WriteTransfer_AVG 
 | appendcols  
 [ search index="windows-wmi" sourcetype="wmi:DiskRAMLoad"  Name="mfetp.exe" 
 | head 10  
 | stats avg(ReadOperationCount) as mfetp_ReadOperation_AVG2, avg(ReadTransferCount) as mfetp_ReadTransfer_AVG2, avg(WriteOperationCount) as mfetp_WriteOperation_AVG2, avg(WriteTransferCount) as mfetp_WriteTransfer_AVG2 BY host]
 | foreach mfetp_*_AVG [| eval perc<<MATCHSTR>>_AVG=case('<<FIELD>>'=='<<FIELD>>2',0, '<<FIELD>>'>'<<FIELD>>2', round(('<<FIELD>>'/'<<FIELD>>2')*100,2), true(), round(('<<FIELD>>2'/'<<FIELD>>')*100,2))]
| table percReadOperation_AVG percReadTransfer_AVG percWriteOperation_AVG percWriteTransfer_AVG
0 Karma

jip31
Motivator

hello
i just want another thing please
in the result of the percentage, i want to display for example + OR -
+ when result of value 2 > result of value 1
- when result of value 1 > result of value 2

Could you do this please??

0 Karma

jip31
Motivator

OH WONDEFUL! thanks a lot

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...