Splunk Search

How do you compute the average number of emails contained in two different sources?

maryamchar
Explorer

I have two different sourcetypes with same index name. Both sources they have emails and it shows the number of those emails. I would like to aggregate both sources and find the average of emails from both sources, represent that on graph.

source="source1" source="source2" index=testing |stats avg(Emails) by companyName

I'm using Splunk Enterprise(Search and Reporting) -> making dashboards. Thank you in advance.

Tags (1)
0 Karma
1 Solution

kmaron
Motivator

You switch from saying sourcetype to saying source. These are two different things. Since the partial SPL you provided says source I'm going to run with that. You can always replace source with sourcetype and it will still work.

This would get you the average number of emails per company name and source

index=testing (source="source1" OR source="source2") 
| stats avg(Emails) as Average by companyName source

You can then choose your visualization to determine the type of graph you want.

View solution in original post

0 Karma

kmaron
Motivator

You switch from saying sourcetype to saying source. These are two different things. Since the partial SPL you provided says source I'm going to run with that. You can always replace source with sourcetype and it will still work.

This would get you the average number of emails per company name and source

index=testing (source="source1" OR source="source2") 
| stats avg(Emails) as Average by companyName source

You can then choose your visualization to determine the type of graph you want.

0 Karma

maryamchar
Explorer

sorry i meant source. The above gave me the result of an average of one source and not combined. I want the average of both sources combined for emails by company.

0 Karma

kmaron
Motivator

You just need to remove source.

  index=testing (source="source1" OR source="source2") 
  | stats avg(Emails) as Average by companyName
0 Karma

maryamchar
Explorer

Thank you!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...