Splunk Enterprise

Two stats commands in same search

user93
Communicator

Hi,

I want to count two different stats and join them in the same resulting table. Can you remind me how to do this? The string is to complex to duplicate, but I'll illustrate what is there.

 

 

 

index=server application=app page=x OR page=y OR page=z

|stats count as pageloads by page
|stats distinctcount(id) as usercount by page
|lookup excel.csv page AS pagetitle OUTPUTNEW author,creationdate,lastmodified

|table pageloads,usercount,pagetitle,author,creationdate,lastmodified

 

 

 

Labels (1)
0 Karma
1 Solution

Richfez
SplunkTrust
SplunkTrust

Yep, just put them in the same stats command.

 

|stats count as pageloads, distinctcount(id) as usercount by page

You can have all sorts of them piled in there, as long as they're all "by" the same field, which in your case they all were "by page" so that's fine.

View solution in original post

Richfez
SplunkTrust
SplunkTrust

Yep, just put them in the same stats command.

 

|stats count as pageloads, distinctcount(id) as usercount by page

You can have all sorts of them piled in there, as long as they're all "by" the same field, which in your case they all were "by page" so that's fine.

user93
Communicator

Thanks @Richfez - My mistake was duplication of the by clause. 

So 

Incorrect

 

|stats count as pageloads by page, distinctcount(id) as usercount by page

 

 Correct

|stats count as pageloads, distinctcount(id) as usercount by page

 

Tags (1)
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...