Files
dropshell-templates/simple-logs/install.sh
Your Name f114773d78
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 40s
swtich from ELK to Loki!
2025-09-20 12:01:25 +12:00

62 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
source "${AGENT_PATH}/common.sh"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
_check_required_env_vars "CONTAINER_NAME"
# Check Docker
_check_docker_installed || _die "Docker test failed"
docker compose version >/dev/null 2>&1 || _die "Docker Compose V2 is required"
# Stop any existing containers
bash ./stop.sh 2>/dev/null || true
# Create config directory
mkdir -p "${CONFIG_PATH}/dashboards"
# Copy configuration files
cp "$SCRIPT_DIR/config/"*.yaml "$SCRIPT_DIR/config/"*.yml "${CONFIG_PATH}/" 2>/dev/null || true
cp "$SCRIPT_DIR/config/dashboards/"*.json "${CONFIG_PATH}/dashboards/" 2>/dev/null || true
# Start the stack
echo "Starting Simple Logs stack..."
docker compose up -d || _die "Failed to start"
# Wait for Grafana to be ready
echo -n "Waiting for Grafana to start..."
MAX_WAIT=60
WAITED=0
while [ $WAITED -lt $MAX_WAIT ]; do
if curl -s "http://localhost:${WEB_PORT:-3000}/api/health" 2>/dev/null | grep -q "ok"; then
echo " Ready!"
break
fi
echo -n "."
sleep 2
WAITED=$((WAITED + 2))
done
echo ""
echo "========================================="
echo "Simple Logs Installed!"
echo "========================================="
echo ""
echo "Access at: http://$(hostname -I | awk '{print $1}'):${WEB_PORT:-3000}"
echo ""
if [ -n "${AUTH_USERNAME}" ]; then
echo "Login: ${AUTH_USERNAME} / ${AUTH_PASSWORD}"
else
echo "Login: admin / admin"
echo "(You'll be asked to change password on first login)"
fi
echo ""
echo "TO VIEW LOGS:"
echo "1. Click 'Dashboards' icon (4 squares) on left"
echo "2. Click 'Simple Logs'"
echo "3. Your logs appear immediately!"
echo ""
echo "TO FILTER:"
echo "- Click any label to filter by it"
echo "- Use the search box for text search"
echo "- Time range selector is in top-right"
echo "========================================="