Splunk Search

How to display only the result corresponding to the current time?

jip31
Motivator

hello

From the search below, I need to display only the result corresponding to the current time

It means that if it's 17h15, i need to display only the count value corresponding to 17h15 in my search

 

 

`tutu` sourcetype="session"  
| bin _time span=15m 
| stats dc(s) as count by _time

 

 

 The time format is 2022-04-27 17:15:00

could you help please?

Labels (1)
Tags (1)
0 Karma
1 Solution

smurf
Communicator

Hi,

You have to take current time and deduct 15 minutes from it, after that you can compare _time from the event with your variable.


`tutu` sourcetype="session" 
| bin _time span=15m
| stats dc(s) as count by _time
| eval current_time = relative_time(now(), "-15m")
| where _time >= current_time

View solution in original post

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Honestly, I don't understand the point of this exercise.

It's best to filter the data as early as possible so you should rather limit the input data with earliest/latest or timepicker. There's no point of calculating stats over other periods if you're gonna discard those results immediately.

Unless you have some need that I don't understand.

0 Karma

smurf
Communicator

Hi,

You have to take current time and deduct 15 minutes from it, after that you can compare _time from the event with your variable.


`tutu` sourcetype="session" 
| bin _time span=15m
| stats dc(s) as count by _time
| eval current_time = relative_time(now(), "-15m")
| where _time >= current_time
0 Karma
Get Updates on the Splunk Community!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...