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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...