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!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...