Knowledge Management

how to move the source and sourcetype to other index

chrismok
Path Finder

As the title. I want to rename the sourcetype from A to B, and also move them to other index. Is that possible to do it?

I tried to use this command

sourcetype=old_log
| EVAL sourcetype=new_log
| COLLECT index=new_index

But I found that the source will be changed like this "C:\\Program Files\\Splunk\\var\\spool\\splunk\\76dea59b6fcaa8e5_events.stash_new" and sourcetype will be changed to "stash".

0 Karma

jrodman
Splunk Employee
Splunk Employee

There is no feature to move events from one index to another.

You can try to use the summary indexing feature (one component is provided as the collect command) to cause new events to be created with the same text in them in a different index, but this is not at all the same as moving the events. You're seeing some of the differences.

Without altering events, you can use the 'rename=X' feature in the configuration of a sourcetype to alias all the events of that sourcetype to another sourcetype. This is typically useful as a cleanup action when the sourcetype you have your data under was an accident or is no longer wanted forevermore. It does not address your moving events goal.

The only way to really achieve "moving" events with full fidelity is quite laborious, and involves exporting the events to csv, and then importing them to a new bucket that you place in your new index, followed by hiding the original events with the |delete command. For most scenarios, reindexing the data to the desired index is more efficient on user time.

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!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Enhance Security Operations with Automated Threat Analysis in the Splunk EcosystemAre you leveraging ...

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...