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
Get Updates on the Splunk Community!

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!

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

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...