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!

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...