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
Get Updates on the Splunk Community!

Introducing the Splunk Developer Program!

Hey Splunk community! We are excited to announce that Splunk is launching the Splunk Developer Program in ...

Splunkbase Year in Review 2024

Reflecting on 2024, it’s clear that innovation and collaboration have defined the journey for Splunk ...

Developer Spotlight with Brett Adams

In our third Spotlight feature, we're excited to shine a light on Brett—a Splunk consultant, innovative ...