Splunk Support offers many KB articles on how to address the issue of standalone buckets. Large environments or long outages have the potential of producing hundreds or thousands of standalone buckets on multiple indexers. Renaming these can take hours or days depending on the situation. This article offers a method for automating this process. The steps below may need adjustment for your particular environment.
When indexers are unable to reach the cluster manager for any reason but are still able to accept data from forwarders, by the time they are able to rejoin the cluster, they may contain standalone buckets. This will occur if their buckets naturally rolled from hot to warm or if they themselves were restarted but were unable to connect to the cluster manager when they came back up. The indexers need to save this data, so they roll their buckets to warm without using the clustered bucket naming convention.
Once the communication issue is resolved, indexers with standalone buckets may continually or periodically show in "Pending" or "Batch Adding" status on the Cluster Manager's UI.
As standalone buckets are the symptom of an issue where indexers are unable to communicate with the Cluster Manager, standalone buckets will resurface if the underlying cause has not been resolved.
sed command provided doesn't work properly (try removing -e switch per this article (which says in Oracle Linux it is a separator between editing commands. As only one editing command is used here, perhaps the -e is not needed for that distro.).bucketManifest file lists all buckets in the db (hot/warm) and colddb (cold) paths for a specific index, but is located only in the index's hot/warm path. The CM uses this file to find buckets on an indexer. It does not look at the actual bucket directories on disk. Deleting .bucketManifest forces the indexer to regenerate this file when Splunk starts. If this step is skipped, the buckets will still be listed as standalone in .bucketManifest and the CM will not know they have been renamed.setSplunkEnv file before running this just to be safe, and be aware the variables will not persist past the current user session):source /opt/splunk/bin/setSplunkEnv
$SPLUNK_HOME or $SPLUNK_DB) with the file path it represents in your environment (for example, /opt/splunk or /opt/splunk/var/lib/splunk, respectively)First, here are instructions to rename standalone buckets in bulk using regex and CLI commands. Customize them as best fits your environment and preferences. Best practice is to perform manually for at least one indexer to tweak the commands as needed for your environment and to ensure you are comfortable with the process. Then, if appropriate, create a shell script to further simplify the process.
$SPLUNK_HOME/bin/splunk enable maintenance-mode
$SPLUNK_DB (often located at /opt/splunk/var/lib/splunk), check for standalone buckets:cd $SPLUNK_DB
ls -d */*/* | egrep "_[0-9]{1,4}$" | egrep -v 'hot_'
$SPLUNK_HOME/bin/splunk stop
/tmp/list is an example path and file name. Choose a file path this user account can access):ls -d */*/* | egrep "_[0-9]{1,4}$" | egrep -v 'hot_' > /tmp/list
Alternatively, if you have too many files for the shell to process:
ls -d */db/* | egrep "_[0-9]{1,4}$" | egrep -v 'hot_' > /tmp/list
ls -d */colddb/* | egrep "_[0-9]{1,4}$" | egrep -v 'hot_' > /tmp/list
find . -mindepth 3 -maxdepth 3 -regextype posix-egrep -regex ".*_[0-9]{1,4}$" ! -name "*hot_*"
cat $SPLUNK_HOME/etc/instance.cfg | grep -P '(\w+-\w+-\w+-\w+-\w+)$' -o > guid ; GUID=$(cat guid) ; echo $GUID
for i in `cat /tmp/list`; do echo "${i} -> ${i}_${GUID}" ; mv ${i} ${i}_${GUID}; done
ls command again to confirm they were renamed successfully. The result should come up empty (again, use one of the alternatives noted above if needed).ls -d */*/* | egrep "_[0-9]{1,4}$" | egrep -v 'hot_'
.bucketManifest from each index:sed -e 's/\/.*//' /tmp/list | sort | uniq > /tmp/list2
find `cat /tmp/list2` -name .bucketManifest > /tmp/bms
rm `cat /tmp/bms`
./splunk start
./splunk disable maintenance-mode
On affected indexers, remove the temp files created for this process.In case you need practice working with scripts before following the steps below, this blog post describes the process of creating a script to rename multiple files or directories. Best practice would involve testing this process in a lower environment before performing it in production. If that is not an option, or if you are not comfortable working with scripts, the CLI commands above are still an excellent way to simplify renaming of standalone buckets. A script just makes it that much faster.
A properly developed script would likely prompt the user for a location to search, would not rely on temporary files that need cleaning up, would provide an output of all affected buckets as well as the guid which will be attached to each bucket name, and include prompts to continue or cancel the action. Probably a host of other things like validation checks, etc. The example script below does none of this, merely automates the manually run commands above. Like those steps, it leaves behind temporary files that need to be cleaned up. It doesn't offer user prompts to ensure the script is correct, and must be edited manually to ensure it is searching the correct paths for standalone buckets. In short: use it at your own risk, and always when possible, test in a non-production environment.
$SPLUNK_HOME/bin/splunk enable maintenance-mode
ls -d $SPLUNK_DB/*/*/* | egrep "_[0-9]{1,4}$" | egrep -v 'hot_'
vi renamebuckets.sh
EXAMPLE script:
#! /bin/sh
cat $SPLUNK_HOME/etc/instance.cfg | grep -P '(\w+-\w+-\w+-\w+-\w+)$' -o > guid ; GUID=$(cat guid)
ls -d $SPLUNK_DB/*/colddb/?b_* | egrep "_[0-9]{1,4}$" | egrep -v > /tmp/standalone_list
ls -d $SPLUNK_DB/*/db/?b_* | egrep "_[0-9]{1,4}$" | egrep -v >> /tmp/standalone_list
for i in 'cat /tmp/standalone_list'; do echo "${i} -> ${i}_${GUID}" ; mv ${i} ${i}_${GUID}; done
sed -e 's/\/.*//' /tmp/standalone_list | sort | uniq > /tmp/standalone_unique
find `cat /tmp/standalone_unique` -name .bucketManifest > /tmp/bucketManifests
rm -f `cat /tmp/bucketManifests`
sudo chmod a+x renamebuckets.sh
$SPLUNK_HOME/bin/splunk stop
./renamebuckets.sh
cd $SPLUNK_DB
ls -d */*/* | egrep "_[0-9]{1,4}$" | egrep -v 'hot_'
$SPLUNK_HOME/bin/splunk start
./splunk disable maintenance-mode
Monitor the CM for stability and fix-up tasks. When fix-ups are complete, delete excess buckets as these take up unnecessary drive space.
An excellent Splunk KB Article regarding identifying and manually renaming standalone buckets: Indexer fails to re-join cluster with error "bucket already added as clustered, peer attempted to add again as standalone"
Articles relating to the sed command:
sort and | uniq operators | Revision | Publish Date | Comments |
|---|---|---|
1.0 |
29-Sep-2026
|
Initial Release |