Splunk Search

Need to compare the last hour values of the fields with current one hour

kartm2020
Communicator

Hi,
We are monitoring the transaction count. I need to verify the results of last one hour, if there is any decrease in the count the alert needs to be generated.
For example :
7 AM to 8 AM - transaction count with fields
8 AM to 9 AM - I need to verify the fields values with 7AM to 8AM field values. If the count get decreased alerts needs to notified.
How to write the search for this scenario.?
Please suggest

Tags (1)
0 Karma

kartm2020
Communicator

Great. Thank you. How can i compare the fields values with 1hour_before with latest fields values

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi kartm,
did you explored the timewrap command? ( https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/Timewrap )

your_search
| timechart count span=1h 
| timewrap 1hour

Bye.
Giuseppe

gcusello
SplunkTrust
SplunkTrust

Hi kartm,
if this answer satisfies your need, please, accept and/or upvote it.
Bye, see next time.
Giuseppe

0 Karma

kartm2020
Communicator

How can i compare the fields values with 1hour_before with latest fields values

0 Karma

gcusello
SplunkTrust
SplunkTrust

try something like this:
you must adapt your search creating something like this

index=_internal earliest=-3h@h latest=-h@h
| timechart count
| timewrap 1h

Bye.
Giuseppe

0 Karma

kartm2020
Communicator

Hi Giuseppe,
It is giving the expected result. But i need the difference the two fields and results should be in the third field as a percentage.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Try this

index=_internal 
| timechart span=1h count
| delta count AS Delta
| eval deltaPerc=Delta/count*100

Bye.
Giuseppe

0 Karma
Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...