Splunk Search

Get Source Count value

amoldesai
Explorer

Hi,

The following query below returns the output as shown below :

Query:

index="79390-np" sourcetype=np-cache-v2 source="*bp_detail*" |fields deviceId,bpRuleId | join deviceId [search index="79390-np" sourcetype=np-cache-v2 source="*bp_detail*"] | join bpRuleId [search index="79390-np" sourcetype=np-cache-v2 source="*bp_summary*" bpPrimaryTechnology="*"] | eval Month=strftime(_time,"%b %Y") | stats count as "totalExceptions",dc(source) as "sourcecount", dc(deviceId) as "uniquedevices" by Month

Output:

Month totalExceptions sourcecount uniquedevices
Feb 2016 181698 1 4197
Mar 2016 550648 1 4242

Source data for Feb: bp_detail1.gz
Source data or March : bp_detail2.gz, bp_detail3.gz and bp_detail4.gz

In the query above "dc(source) as sourcecount" returns the source count as "1" . I am expecting to some how get the original source count as "3" for March
since there are three source files meeting the criteria(source="*bp_detail*" ) for month of March. I need this count to find an average month wise.Please let me know.

Thanks.

Tags (1)
0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Remove the final |stats and look at the data you're feeding into it. I'm guessing there's only one source value for March, probably because of all those joins. Seeing through what those do for your data is impossible from over here.

For a few alternatives check out https://answers.splunk.com/answers/129424/how-to-compare-fields-over-multiple-sourcetypes-without-jo...

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

I don't see a point in trying to fix a bunch of joins without knowing the data and requirements for the result - it'll just end in tears.

For example, what original source count are you looking for? You have three searches, so there are three original source counts to choose from?

0 Karma

amoldesai
Explorer

Thanks for looking into it. I am looking to get the source count for bp_detail. It has three source files for March and one for Feb. I have mentioned more about it in my first mail.

Thanks

0 Karma

amoldesai
Explorer

I do know that after all the joins there is one source value for March. But how do I get the original source count . Is there a way to save the source count in a variable before those joins so that I can refer it later for average calculation.Please let me know.

Thanks

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

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...