By default, OpenSearch retains all data indefinitely. If you need to remove old
data—whether to free up space or to prevent Business Performance Center from accessing outdated information—you can
use the REST API to perform the cleanup.
About this task
When cleaning up indices, avoid deleting the entire index. Instead, purge its contents. Purging
refers to deleting the data within an index while retaining the index itself.
Procedure
-
Select indices to clean up.
Note: Indices with active in their names, for example, those containing summaries for
in-progress operations, will regenerate as soon as new events are added to the active
summary.
- Login to OpenShift:
- Define the necessary environment variables for accessing OpenSearch:
oc project production # namespace where BAI is deployed
export OPENSEARCH_URL=$(oc get route opensearch-route -o jsonpath='{.status.ingress[0].host}')
export OPENSEARCH_USERNAME="elastic"
export OPENSEARCH_PASSWORD=$(oc extract secret/opensearch-ibm-elasticsearch-cred-secret --to=- --keys=elastic 2>/dev/null)
- Purge the index content by running the following curl command. It will delete all
documents from the specified index ${INDEX}. Iterate over all relevant indices as needed:
curl -X POST -u "$OPENSEARCH_USERNAME:$OPENSEARCH_PASSWORD" "https://$OPENSEARCH_URL/${INDEX}/_delete_by_query?pretty" -H 'Content-Type: application/json' --insecure -d'
{
"query": { "match_all": {} }
}
'
- Purge the Business Performance Center alerts by
running the following curl command:
INDEX='icp4ba-bai-store-alert*'
curl -X POST -u"$OPENSEARCH_USERNAME:$OPENSEARCH_PASSWORD""https://$OPENSEARCH_URL/${INDEX}/_delete_by_query?pretty"-H'Content-Type: application/json'--insecure-d'
{
"query": { "match_all": {} }
}
'