Splunk Search

How to find the No. of users using application?

Ajit
Engager
My log contains entries as shown below.

2023-03-03T14:14:12.718, Level=INFO, ProcessName=App-web, Thread=http-nio-80-exec-78, Code=c.m.Config, Message={"clientIp":"192.168.12.24","cost":1,"method":"GET","reqParam":{"userId":["25632"]},"resp":"{\"code\":1,\"data\":{\"list\":[{\"createDate\":1656942857926,\"groupId\":1000023,\"id\":1173,\"lastUpdate\":16569","user":"myemail@hotmail.com"}

I want to know how many users are using the application in last one hour.
Labels (1)
Tags (3)
0 Karma

Ajit
Engager

Thanks @yuanliu 

Below query worked for me.

| eval Message = replace(_raw, ".+,\s *Message=", "")
| spath input=Message
| stats dc(user) as unique_users
0 Karma

yuanliu
SplunkTrust
SplunkTrust

First, I think your log probably look like this instead:

2023-03-03T14:14:12.718, Level=INFO, ProcessName=App-web, Thread=http-nio-80-exec-78, Code=c.m.Config, Message={"clientIp":"192.168.12.24","cost":1,"method":"GET","reqParam":{"userId":["25632"]},"resp":"{\"code\":1,\"data\":{\"list\":[{\"createDate\":1656942857926,\"groupId\":1000023,\"id\":1173,\"lastUpdate\":16569\",\"user\":\"myemail@hotmail.com\"}]}}"}

Second, you need to explain which field/node in Message represents a "user" in your question.  If I have to speculate, it is either userId in reqParam or data.user in resp; I further speculate that neither field, especially userId, can have multiple values in a single transaction.  So, I'll use this field.

| eval Message = replace(_raw, ".+,\s *Message=", "")
| spath input=Message
| stats dc('reqParam.userId{}') as unique_users

 

Tags (2)
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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...