Skip to content

Commit

Permalink
Merge pull request #274 from levoai/extract-satellite-logs
Browse files Browse the repository at this point in the history
Adding script to extract satellite logs
  • Loading branch information
gannaraputeja authored Oct 11, 2024
2 parents f3d803e + 1439ccd commit 341a0c1
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/install-satellite/install-satellite.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The Satellite uses an organization ID to authenticate incoming requests.


## 4. Follow instructions for your platform
- [Install on Kubernetes](satellite-kubernetes.md)
- [Install on Kubernetes](satellite-kubernetes.mdx)
- [Install on Linux host via Docker Compose](satellite-docker.mdx)
- [Install in AWS EC2 using Levo Satellite AMI](satellite-ami-aws-ec2.mdx)
- [Install in AWS EKS](satellite-aws-eks.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/install-satellite/satellite-aws-eks-fargate.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ The `--role` argument sets the correct role and policies so that seemless access


### 4. Install the satellite
Please follow the instructions in the [Install on Kubernetes](satellite-kubernetes.md) section to install the Satellite.
Please follow the instructions in the [Install on Kubernetes](satellite-kubernetes.mdx) section to install the Satellite.

Please ensure that you note down the address of the collector.

2 changes: 1 addition & 1 deletion docs/install-satellite/satellite-aws-eks.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ eksctl create addon --name aws-ebs-csi-driver --cluster ${CLUSTER_NAME} --region

### 5. Install the satellite

Please follow the instructions in the [Install on Kubernetes](satellite-kubernetes.md) section to install the Satellite.
Please follow the instructions in the [Install on Kubernetes](satellite-kubernetes.mdx) section to install the Satellite.

Please ensure that you note down the address of the collector.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ description: Install Levo.ai Satellite on Kubernetes. Follow our detailed guide

# Satellite on Kubernetes

import BrowserOnly from '@docusaurus/BrowserOnly';

export function DownloadGetLogsScript() {
return (
<BrowserOnly fallback={<div>Loading...</div>}>
{() => (
<a href={window.location.protocol + '//' + window.location.host + '/artifacts/satellite/get_levoai_satellite_logs.sh'} download> download</a>
)}
</BrowserOnly>
);
}

## Setup

### Prerequisites
Expand Down Expand Up @@ -336,5 +348,13 @@ kubectl -n levoai logs <levoai-tagger-pod-id> | grep "ConnectionRefusedError: [E

If there are exception messages, Tagger is unable to connect to dependent services. It generally establishes connection after 3/4 retries. Please contact [email protected] for further assistance.

<br></br>
### Share Satellite logs with Levo Support

Please <DownloadGetLogsScript/> script and execute following commands to collect logs from all Satellite components. This will create an archive as `/tmp/levoai_satellite_logs_%date-time%.tar.gz`.

```bash
chmod +x get_levoai_satellite_logs.sh
./get_levoai_satellite_logs.sh
```

<br></br>
2 changes: 1 addition & 1 deletion docs/quickstart/quickstart-kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ helm upgrade --install -n levoai --create-namespace \

:::info

Please refer to [install satellite in kubernetes](/../../install-satellite/satellite-kubernetes) for detailed instructions.
Please refer to [install satellite in kubernetes](/install-satellite/satellite-kubernetes.mdx) for detailed instructions.

:::

Expand Down
52 changes: 52 additions & 0 deletions static/artifacts/satellite/get_levoai_satellite_logs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

# Check if kubectl is installed
if ! command -v kubectl &> /dev/null; then
echo "Error: kubectl is not installed or not found in your PATH. Please install kubectl and try again."
exit 1
fi

# Validate if there is an active Kubernetes context
CURRENT_CONTEXT=$(kubectl config current-context 2>/dev/null)

if [ -z "$CURRENT_CONTEXT" ]; then
echo "Warning: No active Kubernetes context found. Please configure your kubeconfig and try again."
exit 1
fi

echo "Active Kubernetes context: $CURRENT_CONTEXT"

# Set the namespace (default to "levoai" if not provided as an argument)
NAMESPACE=${1:-levoai}

echo "Checking for pods in $NAMESPACE namespace.."

# Check if the namespace exists and has pods
PODS=$(kubectl get pods -n "$NAMESPACE" --no-headers -o custom-columns=":metadata.name")

if [ -z "$PODS" ]; then
echo "Warning: No pods found in namespace '$NAMESPACE' in the current context."
exit 1
fi

# Create a temporary directory to store logs
TEMP_DIR=$(mktemp -d)
echo "Temporary directory created: $TEMP_DIR"

# Loop through each pod and save its logs into separate files
for POD in $PODS; do
LOG_FILE="$TEMP_DIR/${POD}.log"
echo "Collecting logs for pod: $POD"
kubectl logs "$POD" -n "$NAMESPACE" > "$LOG_FILE" 2>&1
done

# Create archive of current directory
TAR_FILE="/tmp/levoai_satellite_logs_$(date +%Y_%m_%d_%H_%M_%S).tar.gz"
tar -czf "$TAR_FILE" -C "$TEMP_DIR" .

echo "Logs have been collected and archived at $TAR_FILE"

# Clean up temporary directory
rm -rf "$TEMP_DIR"


0 comments on commit 341a0c1

Please sign in to comment.