Splunk Search

Why is the collect command not working when used with map command?

TiagoTLD1
Communicator

If I do this search

 index=log NOT "*INFO*" earliest=-40d@d latest=-39d@d 
 | cluster t=0.3 field=raw showcount=t labelonly=false delims=" "
 | eval old_label=cluster_label 
 | eventstats sum(cluster_count) as total_events 
 | eval Freq_Baseline=cluster_count/total_events 
 | fields _time, raw, old_label, cluster_count, Freq_Baseline, total_events 
 | collect index=clusters

Everything gets collected in index=clusters

BUT if I include this in a map,

index=is_log | head 1 
| streamstats count as latest 
| eval latest = 40
| eval earliest=latest + 1
| eval earliest= tostring(-earliest) + "d@d"  
| eval latest= tostring(-latest) + "d@d" 
| map maxsearches=35 search="search index=is_log NOT "*INFO*" earliest=$earliest$ latest=$latest$ 
 | cluster t=0.3 field=raw showcount=t labelonly=false delims=" "
 | eval old_label=cluster_label 
 | eventstats sum(cluster_count) as total_events 
 | eval Freq_Baseline=cluster_count/total_events 
 | fields _time, raw, old_label, cluster_count, Freq_Baseline, total_events 
 | collect index=clusters"

Then nothing is collected in the index, although the same results show up on the screen

0 Karma
1 Solution

DalJeanis
Legend

The quotes in delims=" " may need to be escaped.

View solution in original post

0 Karma

DalJeanis
Legend

The quotes in delims=" " may need to be escaped.

0 Karma

TiagoTLD1
Communicator

Thank you 🙂

0 Karma

rvanteru
New Member

The above command was really helpful so what if want to move source of data to other index without changing values to stash.

0 Karma
Get Updates on the Splunk Community!

Exciting News: The AppDynamics Community Joins Splunk!

Hello Splunkers,   I’d like to introduce myself—I’m Ryan, the former AppDynamics Community Manager, and I’m ...

The All New Performance Insights for Splunk

Splunk gives you amazing tools to analyze system data and make business-critical decisions, react to issues, ...

Good Sourcetype Naming

When it comes to getting data in, one of the earliest decisions made is what to use as a sourcetype. Often, ...