Splunk Search

Is it possible to use multiple collects to send data to different indexes?

moses_meniscus
Explorer

Is it possible to use the collect function to send data to multiple different summary indexes?

For example, let's say my search produces the following results:

date         org         field1   field2    field3
03-15-22 Finance valueA1 ValueA2 ValueA3
03-15-22 Maintenance valueB1 ValueB2 ValueB3

I want to use collect to send the results for org:Finance to a specific summary index = FinanceSummary and similarly send the results for org:Maintenance to another summary index=MaintenanceSummary

The syntax I have for the collect function was:

|collect index=[the target summary index]


My question is there way I can do something like:

| where org=Finance
| collect index=FinanceSummary
| where org=Maintenance
| collect index=MaintenanceSummary

I was not sure if this was possible and was hoping to check before pollute my summary indexes with bad results. The documentation itself does not explicitly address this question unfortunately 
https://docs.splunk.com/Documentation/Splunk/8.2.5/SearchReference/Collect

Thanks in advance!

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

This won't work, not because of the multiple collects, which should work, but because the first where command will remove everything apart from org=Finance, so when the second where command removes everything apart from org=Maintenance, there will be no results left (since the org=Maintenance events were removed by the first where command).

View solution in original post

moses_meniscus
Explorer

Thanks for the reply! That makes perfect sense. Someone outside of this channel suggested I try a foreach loop. But thanks for confirming my original question!

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

This won't work, not because of the multiple collects, which should work, but because the first where command will remove everything apart from org=Finance, so when the second where command removes everything apart from org=Maintenance, there will be no results left (since the org=Maintenance events were removed by the first where command).

Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...