Splunk Search
Highlighted

Getting counts of each search result over time

Explorer

I am trying to determine a way to search for user logins over time to get an idea of application usage.

If I have a set number of user ids, I want to get a count of their logins based on a search string in our logs.

So my search is like this:

"Looking for user based on login/user_id=" "abc123" OR "zxy987"

So this would give me all the logs where each of these users had attempted to login and use the application, it could be multiple times per day and there could be multiple entries per day per user of this search string.

But I would like to chart this on a dashboard with time on the x-axis and individual 'string search match" count aka login count on the y axis.

How would I accomplish this in splunk? Would I need to change my search?

Tags (3)
0 Karma
Highlighted

Re: Getting counts of each search result over time

SplunkTrust
SplunkTrust

We probably need to look at your raw data to give you accurate suggestion. Here is my attempt without that (assuming user is appear in raw log after string /user_id=. Also recommend adding one or more metadata fields index/sourcetype/host/source in your query for better performance)

index=foo sourcetype=bar "Looking for user based on login/user_id=" "abc123" OR "zxy987"
| rex "login/user_id=(?<user_id>\S+)" 
| timechart count by user_id

View solution in original post

Highlighted

Re: Getting counts of each search result over time

Explorer

Thanks for your reply. This is great and works well.
I can now see a table of all the counts per day for each user id.

I have a final question, if I wanted to modify the query to show only the days where a user had logged in and not care about the actual count per day, but only be interested if there was a match per day.

The heatmap looks like a good chart for this, where I can have a color where the user logged in and where a user didn't. Then at the bottom of a table it would be good to have a count of the number of days the user logged in (that is, if they log in 3 times in 1 days just count that as 1).

I hope that makes sense and thanks for you help.

0 Karma
Speak Up for Splunk Careers!

We want to better understand the impact Splunk experience and expertise has has on individuals' careers, and help highlight the growing demand for Splunk skills.