Splunk Search

How to get the correct count records instead of counting the field name twice?

ksbuchanan
Explorer

Here is my search:

source="WinEventLog:Security" EventCode="4723" OR EventCode="529" | eval UserName=coalesce(User_Name,Account_Name) | stats count by UserName |sort -count |head 10

The problem is that the field "Account_Name" appears more than once in the record, so the count is effectively doubled. How can I get the correct count of the records instead of counting the field name twice?

0 Karma
1 Solution

ksbuchanan
Explorer

i found a solution. i am doing a distinct count on the record number, and that returns the correct number of records

host="rh-dc*" EventCode=4723
| stats dc(RecordNumber) by Account_Name
| sort -count

View solution in original post

Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...