Splunk Search

stats count sum

kokanne
Communicator

Why does the following query not display the number of logins and logouts

(index="ggg-sec") EventCode=4624 OR EventCode=4634 
    [| inputlookup dfggfdf.csv] 
| stats count sum(EventCode = "4624") as LogIns, sum(EventCode = "4634") as LogOuts by user 
| fields - count 

Thanks

0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

Hi @kokanne,

Can you please try it by replacing stats with this?

| stats count sum(eval(EventCode = "4624")) as LogIns, sum(eval(EventCode = "4634")) as LogOuts by user 

Like:

 (index="wineventlog-sec") EventCode=4624 OR EventCode=4634 
     [| inputlookup sv_externe_leveranciers.csv] 
| stats count sum(eval(EventCode = "4624")) as LogIns, sum(eval(EventCode = "4634")) as LogOuts by user 

Thanks

View solution in original post

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Hi @kokanne,

Can you please try it by replacing stats with this?

| stats count sum(eval(EventCode = "4624")) as LogIns, sum(eval(EventCode = "4634")) as LogOuts by user 

Like:

 (index="wineventlog-sec") EventCode=4624 OR EventCode=4634 
     [| inputlookup sv_externe_leveranciers.csv] 
| stats count sum(eval(EventCode = "4624")) as LogIns, sum(eval(EventCode = "4634")) as LogOuts by user 

Thanks

0 Karma

kokanne
Communicator

do you know how to speed it up? @kamlesh_vaghela

it takes 34 minutes to run this query for last 24 hours, i need this to run every month for a monthly report

0 Karma

amitm05
Builder

You need to accelerate your report.
Mind that setting the schedule and time window for your acceleration should be according to your need.
E.g. If you want this report monthly for the last month.

I think you can probably set the acceleration schedule for last midnight of the day when you want this report. And set the time window of your search also to last month.

Please upvote if this helps you 🙂

0 Karma

deepashri_123
Motivator

is there any reason for using lookup?

0 Karma

kokanne
Communicator

for the user names

0 Karma

kokanne
Communicator

Thanks, does exactly waht i want

0 Karma

deepashri_123
Motivator

Hey kokanne,

Try this:
(index="wineventlog-sec") EventCode=4624 OR EventCode=4634
[| inputlookup sv_externe_leveranciers.csv]
|eval Condition=case(EventCode == 4624,"Logins",EventCode == 4634,"LogOuts") |stats count by Condition,user
Let me know if this helps!!

0 Karma

kokanne
Communicator

Error in 'eval' command: The arguments to the 'case' function are invalid.

0 Karma

deepashri_123
Motivator

I have edited, can you try now!!

0 Karma

kokanne
Communicator

It works, but I would like instead of a column called "Condition", that the column is called either log in or log out, is that possible, and then also user and the count

0 Karma
Get Updates on the Splunk Community!

Index This | Divide 100 by half. What do you get?

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

Stay Connected: Your Guide to December Tech Talks, Office Hours, and Webinars!

❄️ Celebrate the season with our December lineup of Community Office Hours, Tech Talks, and Webinars! ...

Splunk and Fraud

Watch Now!Watch an insightful webinar where we delve into the innovative approaches to solving fraud using the ...