Splunk Search

How to write a search to compare and find the difference between monthly results over a period of time?

dhavamanis
Builder

We have the below splunk query to get the availability report. How to compare monthly availability results? Example: the month of October availability percentage is 99% and November is 95%. How to get the variation difference. can you please provide the query to show the variation of results between months or over the period.

index="idxweblog" c=cnbc | eval Count5xx=if(status like "5%",1,0) | stats sum(Count5xx) as Count5xx count(status) as Total | eval AvailablePercentage=(Total - Count5xx)*100/Total | table AvailablePercentage

1 Solution

lguinn2
Legend

You could try

index="idxweblog" c=cnbc 
| eval month = strftime(_time,"%m")
| eval Count5xx=if(status like "5%",1,0) 
| stats sum(Count5xx) as Count5xx count(status) as Total by month
| eval AvailablePercentage=(Total - Count5xx)*100/Total 
| delta AvailablePercentage as Difference

View solution in original post

lguinn2
Legend

You could try

index="idxweblog" c=cnbc 
| eval month = strftime(_time,"%m")
| eval Count5xx=if(status like "5%",1,0) 
| stats sum(Count5xx) as Count5xx count(status) as Total by month
| eval AvailablePercentage=(Total - Count5xx)*100/Total 
| delta AvailablePercentage as Difference

aholzer
Motivator

Have you looked at the "delta" command?

0 Karma

dhavamanis
Builder

can you provide some sample?

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...