For better tracking and debugging Milvus, the script `export-milvus-log.sh` is provided for exporting all Milvus logs at once. For those pods that have been restarted, this script can export the logs of the running pods and the logs of the previously pods.
| n | Specify the namespace that milvus is installed in | default |
| p | Specify the log storage path | ./milvus-log |
## Usage
1. Milvus instance name is required to be specified
```shell
./export-milvus-log.sh -i my-release
```
> This command will generate a directory named milvus-log in the current directory.
> For a pod that have not been restarted, the command will generate a log named ${podname}.log for the pod and store it in `milvus-log`.
> For a pod that has been restarted, this command will generate a log named ${podname}.log and a log ${podname}-pre.log for the pod.
2. If your milvus is not installed in the k8s default namespace, please specify namespace with `-n`. You can also customize the log storage path with `-p`.
#-n namespace: The namespace that Milvus is installed in.
#-i milvus_instance: The name of milvus instance.
#-p log_path: Log storage path.
while getopts"n:i:p:" opt_name
do
case$opt_namein
n)namespace=$OPTARG
;;
i)instance_name=$OPTARG
;;
p)log_path=$OPTARG
;;
*)echo"Unkonwen parameters"
;;
esac
done
if[!$instance_name];
then
echo"Missing argument instance_name, please add it. For example:'./export-milvus-log.sh -i milvus-instance-name'"
exit 1
fi
pods=$(kubectl get pod -n$namespace-l app.kubernetes.io/instance=$instance_name,app.kubernetes.io/name=milvus --output=jsonpath={.items..metadata.name})
if[${#pods}== 0 ];
then
echo"There is no Milvus instance $instance_name in the namespace $namespace"
exit 1
fi
if[!-d$log_path];
then
mkdir-p$log_path
fi
echo"The log files will be stored $(readlink-f$log_path)"
for pod in$pods;
do
# Check if the pod has been restarted
if[$(kubectl get pod $pod-n$namespace--output=jsonpath={.status.containerStatuses[0].restartCount})== 0 ];