Splunk Search

Can anyone regex the time out in my search?

moiezuddin
Explorer

In the search below, can anyone regex the time out instead of bucket span?

I need to figure out a way to filter time and data per user. (Need to use regex instead of bucket)

The expression which is there in the search is extracts the USERID field. ( | rex "(?i) Realm][][][][][][(?P[^]]+" )

Just want regex the time out instead of bucket span

index=casm_prod sourcetype=smtrace "Center realm" | rex "(?i) Realm][][][][][][(?P[^]]+" |bucket span=5m _time|stats values(user) as USER count(user) as eventcount by _time |fields USER eventcount
Tags (2)
0 Karma
1 Solution

esix_splunk
Splunk Employee
Splunk Employee

Expanding on that a bit, Im not sure if the start of the event is actually the "["...

... | rex field=_raw "\[(?P<date>\d{1,2}\/\d{1,2}\/\d{4})\]\[(?P<time>\d{1,2}:\d{1,2}:\d{1,2}.\d{1,3})\]" | table date time

View solution in original post

0 Karma

esix_splunk
Splunk Employee
Splunk Employee

Expanding on that a bit, Im not sure if the start of the event is actually the "["...

... | rex field=_raw "\[(?P<date>\d{1,2}\/\d{1,2}\/\d{4})\]\[(?P<time>\d{1,2}:\d{1,2}:\d{1,2}.\d{1,3})\]" | table date time
0 Karma

moiezuddin
Explorer

Now i can able to be found many times userid's each minute.

Can we fiter this so it only shows once per minute.

0 Karma

esix_splunk
Splunk Employee
Splunk Employee
... | rex field=_raw "\[(?P<date>\d{1,2}\/\d{1,2}\/\d{4})\]\[(?P<time>\d{1,2}:\d{1,2}:\d{1,2}.\d{1,3})\]" | bin span=1m _time | stats count by USER

But you need to extract your 'USER' if it isnt already.

0 Karma

moiezuddin
Explorer

Yes your correct i extracted it , here is the query

index=casm_prod sourcetype=smtrace "Center realm"| rex "(?i) Realm\]\[\]\[\]\[\]\[\]\[\]\[(?P[^\]]+)"| rex field=_raw "[(?P\d{1,2}\/\d{1,2}\/\d{4})][(?P\d{1,2}:\d{1,2}:\d{1,2}.\d{1,3})]" | table date time user

Iam getting multiple events form one usersid
Without using bin span

can we get event per user per minute

0 Karma

esix_splunk
Splunk Employee
Splunk Employee
index=casm_prod sourcetype=smtrace "Center Realm" | rex field=_raw "\[(?P<date>\d{1,2}\/\d{1,2}\/\d{4})\]\[(?P<time>\d{1,2}:\d{1,2}:\d{1,2}.\d{1,3})\].*Center realm\](\[\]+){5}\[(?<user_id>[^\]]+)\]" | bin span=1m time | stats count by user_id

If you want to aggregate by time, you have to use stats or timechart for this. And since you say you want to aggregate over one minute, you have to user the bin span=1m. You can remove that, but it will group by all time in the events.

I also have to question if your time stamps are working correctly for these events...

0 Karma

moiezuddin
Explorer

Error in the query

Time stamps is working correctly for your 1st query which you given''

0 Karma

esix_splunk
Splunk Employee
Splunk Employee

Timestamp should be working from index time, not search time. So currently your event time doesnt match the actual event time?

You should fix this, otherwise Splunk looses it real value.

Read this : http://docs.splunk.com/Documentation/Splunk/6.2.2/Data/HowSplunkextractstimestamps

You shouldnt have to extract date or timestamps at search time, these should be done at index time and available in search. This negates the whole purpose of Splunk and time based event monitoring.

Whats the query error?

moiezuddin
Explorer

Thankyou very much for your quick response ..

its working fine now.

0 Karma

aholzel
Communicator

This regex will give you the date and time in different fields:

rex field=_raw "^\[(?<date>[^\]]+)\]\[(?<time>[^\]]+)"

Edit: the naming did not work... please remove the space between the "<" and "date" and between "<" and "time"

0 Karma

moiezuddin
Explorer

I need to figure out only userid which shows once per minute with regex,
Can you please provide me the complete query , i am unable to understand where to add in existing query.
Awaiting for your response

0 Karma

aholzel
Communicator

I don't really understand what you mean. Are you looking for a specific username that only shows once a minute? or do you get multiple events from users and only what to work with one event per user per minute?

0 Karma

moiezuddin
Explorer

i am getting multiple events form one usersid
I need one event per user per minute

0 Karma

esix_splunk
Splunk Employee
Splunk Employee

We need to know what your data looks like in order to extract your time.

0 Karma

moiezuddin
Explorer

SAMPLE DATA FROM THE ABOVE QUERY

4/28/15
2:05:00.000 PM

[04/28/2015][11:06:09.634][347216816][s5324172/r23][Center realm][][][][][][206416426][][][][][][centerusushwswp222lprd][** Status: Authorized. ][]
index = casm_prod
4/28/15
2:05:00.000 PM

[04/28/2015][11:06:09.634][347216816][s5324172/r23][Center realm][][][][][][206416426][][][][][][centerusushwswp222lprd][Send response attribute 147, data size is 0][]
index = casm_prod
4/28/15
2:05:00.000 PM

[04/28/2015][11:06:09.634][347216816][s5324172/r23][Center realm][][][][][][206416426][][][][][][centerusushwswp222lprd][Send response attribute 146, data size is 0][]
index = casm_prod
4/28/15
2:05:00.000 PM

[04/28/2015][11:06:09.634][347216816][s5324172/r23][Center realm][][][][][][206416426][][][][][][centerusushwswp222lprd][Send response attribute 224, data size is 16][sso_id=206416426]
index = casm_prod sso_id = 206416426
4/28/15
2:05:00.000 PM

[04/28/2015][11:06:09.634][347216816][s5324172/r23][Center realm][][][][][][206416426][][][][][][centerusushwswp222lprd][Send response attribute 224, data size is 16][smuser=206416426]

0 Karma
Get Updates on the Splunk Community!

Why You Can't Miss .conf25: Unleashing the Power of Agentic AI with Splunk & Cisco

The Defining Technology Movement of Our Lifetime The advent of agentic AI is arguably the defining technology ...

Deep Dive into Federated Analytics: Unlocking the Full Power of Your Security Data

In today’s complex digital landscape, security teams face increasing pressure to protect sprawling data across ...

Your summer travels continue with new course releases

Summer in the Northern hemisphere is in full swing, and is often a time to travel and explore. If your summer ...