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!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...