Splunk Dev

Sum function on output of summary index

supriyagaw08
Explorer

I want to sum the output that is stored in summary index and display the output in dashboard which shows sum of all counts for one week.

Below is the code i am using but the output comes as the previous day output stored in summary index:

index=*1 search_name="Daily File Transfer Counts" | dedup BASE_FILE_ID |table Date USER_NM BASE_FILE_ID FILE_NM File_Count_By_Day
| bin _time as week span=7d
| stats sum(File_Count_By_Day) as oneweek by XMIT_AUTH_USER_NM,XMIT_BASE_FILE_ID,XMIT_BASE_FILE_NM
| eval week=strftime(_time,"%Y - %U")

My code in Daily File Transfer Counts is as below:

index=*1 sourcetype=s source="p" "File Catalog" "Completed"
| dedup FILE_ID
| eval Date=strftime(_time, "%b/%d/%Y ")
| stats count(FILE_ID) as "File_Count_By_Day" by Date,XMIT_AUTH_USER_NM,XMIT_BASE_FILE_ID,XMIT_BASE_FILE_NM

 

I am looking to count all the file that was transfers within a week for particular file(sum of File_Count_By_Day within a week)

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

index=*1 sourcetype=s source="p" "File Catalog" "Completed"
| dedup FILE_ID
| eval Date=strftime(_time, "%b/%d/%Y ")
| stats count(FILE_ID) as "File_Count_By_Day" by Date,XMIT_AUTH_USER_NM,XMIT_BASE_FILE_ID,XMIT_BASE_FILE_NM

These counts will always be 1!

index=*1 search_name="Daily File Transfer Counts" | dedup BASE_FILE_ID |table Date USER_NM BASE_FILE_ID FILE_NM File_Count_By_Day
| bin _time as week span=7d
| stats sum(File_Count_By_Day) as oneweek by XMIT_AUTH_USER_NM,XMIT_BASE_FILE_ID,XMIT_BASE_FILE_NM
| eval week=strftime(_time,"%Y - %U")

BASE_FILE_ID doesn't appear to be a field output by your summary query so you won't get any results? _time or week doesn't appear in your by list for your stats so doesn't affect the grouping

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

index=*1 sourcetype=s source="p" "File Catalog" "Completed"
| dedup FILE_ID
| eval Date=strftime(_time, "%b/%d/%Y ")
| stats count(FILE_ID) as "File_Count_By_Day" by Date,XMIT_AUTH_USER_NM,XMIT_BASE_FILE_ID,XMIT_BASE_FILE_NM

These counts will always be 1!

index=*1 search_name="Daily File Transfer Counts" | dedup BASE_FILE_ID |table Date USER_NM BASE_FILE_ID FILE_NM File_Count_By_Day
| bin _time as week span=7d
| stats sum(File_Count_By_Day) as oneweek by XMIT_AUTH_USER_NM,XMIT_BASE_FILE_ID,XMIT_BASE_FILE_NM
| eval week=strftime(_time,"%Y - %U")

BASE_FILE_ID doesn't appear to be a field output by your summary query so you won't get any results? _time or week doesn't appear in your by list for your stats so doesn't affect the grouping

0 Karma

supriyagaw08
Explorer

Thanks for your help  @ITWhisperer  i got why the count was always coming as 1.

0 Karma
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 ...