Splunk Search

sum total unique users in time chart with appendcols

kmccowen
Path Finder

I need to sum the PMBI users and ADF Users to get total user count. Any suggestions?

index=gateway host=sc58lgwap* ApplicationID=GATWY | timechart span=1d dc(RequestorUserID) as "PMBI_Users" | append [search index=ctap host=sc58* sourcetype=gateway userid="userId: *" | timechart span=1d dc(userid) as "ADF_Users"]

Tags (3)
0 Karma
1 Solution

somesoni2
Revered Legend

Try this

index=gateway host=sc58lgwap* ApplicationID=GATWY | timechart span=1d dc(RequestorUserID) as "PMBI_Users" | append [search index=ctap host=sc58* sourcetype=gateway userid="userId: *" | timechart span=1d dc(userid) as "ADF_Users"] | timechart span=1d values(*) as * | addtotals 

View solution in original post

0 Karma

woodcock
Esteemed Legend

Like this:

(index=gateway host=sc58lgwap* ApplicationID=GATWY) OR (index=ctap host=sc58* sourcetype=gateway userid="userId: *") | eval CombinedUser=coalesce(RequestorUserID, userid) | timechart span=1d dc(RequestorUserID) AS PMBI_Users dc(userid) AS ADF_Users dc(CombinedUser) AS Combined_Users

Note: YOU MUST NOT add together dc values to get a combined dc; the combined must be recalculated from the raw data.

0 Karma

somesoni2
Revered Legend

Try this

index=gateway host=sc58lgwap* ApplicationID=GATWY | timechart span=1d dc(RequestorUserID) as "PMBI_Users" | append [search index=ctap host=sc58* sourcetype=gateway userid="userId: *" | timechart span=1d dc(userid) as "ADF_Users"] | timechart span=1d values(*) as * | addtotals 
0 Karma

kmccowen
Path Finder

Awesome! What if I want to remove duplicate users if they were in both apps? Would I table and then dedup?

0 Karma

kmccowen
Path Finder

Meaning if my user id was logged in to both environments in a given day, the total unique users would be 1. Did you already answer this? I'm not finding it.

0 Karma

somesoni2
Revered Legend

@woodcock's answer will give you 3 fields, PMBI_Users ADF_Users and Combined_Users(includes removal of duplicates)

0 Karma

kmccowen
Path Finder

sounds good, thanks Woodcock!

0 Karma

woodcock
Esteemed Legend

The wrong answer was Accepted.

0 Karma

woodcock
Esteemed Legend

See my answer.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...