Created
May 11, 2021 07:54
-
-
Save luigidifraia/6956cb758f6b2e9b4728f56b5695a773 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# From: https://druid.apache.org/docs/latest/tutorials/tutorial-delete-data.html | |
# We assume here that TLS is enabled for Druid's router. If not, use port `8888` and `http` as protocol | |
DRUID_PORT=9088 | |
DRUID_ROUTER=https://localhost:${DRUID_PORT} | |
NAMESPACE=druid | |
# If the Druid endpoint contains 'localhost', assume a port-forward is needed | |
if [[ ${DRUID_ROUTER} == *"localhost"* ]]; then | |
# If there isn't a port-forward for Druid available, create one | |
ps aux | grep "kubectl port-forward svc/storage-druid-query" | grep -v grep | |
if [ $? -ne 0 ]; then | |
kubectl port-forward svc/storage-druid-query ${DRUID_PORT} -n ${NAMESPACE} & | |
sleep 3 | |
fi | |
fi | |
DATASOURCES=$(curl --silent -k ${DRUID_ROUTER}/druid/coordinator/v1/metadata/datasources) | |
for d in $(echo "${DATASOURCES}" | jq -r '.[]'); do | |
curl -X 'POST' -H 'Content-Type:application/json' -d '{ "interval" : "2021-01-01/2021-09-01" }' ${DRUID_ROUTER}/druid/coordinator/v1/datasources/${d}/markUnused | |
curl -X 'POST' -H 'Content-Type:application/json' -d "$(echo "{ \"type\": \"kill\", \"dataSource\": \"${d}\", \"interval\" : \"2021-01-01/2021-09-01\" }")" ${DRUID_ROUTER}/druid/indexer/v1/task | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment