Collecting logs and metrics
Steps to collect logs and metrics for the Data Cataloging.
Procedure
-
Run the following
oc
login command.oc login --token=<OCP_TOKEN> --server=<OCP_SERVER>
For more information about CLI login, see CLI login.
- Export
OCP_TOKEN
,PROJECT_NAME
, andTIMESTAMP
environment variables.export OCP_TOKEN=$(oc whoami --show-token) # or the actual token if not logged in export PROJECT_NAME=ibm-data-cataloging export TIMESTAMP=$(date +"%Y%m%d%H%M%S")
- Run the following command to create a secret with a token to use in the script that
collects resources.
oc -n $PROJECT_NAME create secret generic dcs-must-gather --from-literal=token=$OCP_TOKEN
- Create dcs-must-gather-pod.yaml file.
cat >> dcs-must-gather-pod.yaml << EOF apiVersion: v1 kind: Pod metadata: name: dcs-must-gather labels: app: isd component: discover role: must-gather spec: containers: - name: must-gather env: - name: WORKDIR value: /tmp - name: OCP_TOKEN valueFrom: secretKeyRef: name: dcs-must-gather key: token image: cp.icr.io/cp/ibm-spectrum-discover/must-gather:2.1.3 imagePullPolicy: Always resources: requests: cpu: 50m memory: 128Mi ephemeral-storage: 2Gi limits: cpu: 2 memory: 8Gi ephemeral-storage: 5Gi command: - '/bin/bash' - '-c' - '/opt/must-gather/must-gather.sh; while true; do sleep 60; done' EOF
- Run the following command to create a must gather pod.
oc -n $PROJECT_NAME create -f dcs-must-gather-pod.yaml
- Monitor the logs until it reports that the
tar
file has been created.oc -n $PROJECT_NAME logs -f dcs-must-gather
Example output:2023-09-12 04:12:12 - INFO - Archiving completed: dcs-must-gather.tar.xz
- Copy the
tar
file.oc -n $PROJECT_NAME cp dcs-must-gather:/tmp/dcs-must-gather.tar.xz dcs-must-gather-$TIMESTAMP.tar.xz
- Remove the must gather resources.
oc -n $PROJECT_NAME delete pod dcs-must-gather oc -n $PROJECT_NAME delete secret dcs-must-gather