This document provides a comprehensive guide to set up, run, and deploy the ChaosPilot application for autonomous log analysis and incident response.
- Prerequisites
- GCP Setup
- Local Development Setup
- Running the Application
- Testing with Simulated Logs
- Production Deployment
- Troubleshooting
- Google Cloud CLI - Install Guide
- Python 3.8+ with virtual environment support
- Node.js 16+ and npm
- Git
google-adk==1.3.0
toolbox==1.11.0
google-cloud-logging==3.12.1- MCP Toolbox for Databases (platform-specific)
# Install and initialize gcloud CLI
gcloud init
# Set your project (create new or use existing)
gcloud projects create chaos-pilot --set-as-default
# OR use existing project
gcloud config set project YOUR_PROJECT_IDCritical: Billing must be enabled for API activation.
# Check if billing is enabled
gcloud beta billing projects describe YOUR_PROJECT_ID
# If billing is not enabled, link a billing account
gcloud beta billing accounts list
gcloud beta billing projects link YOUR_PROJECT_ID \
--billing-account=YOUR_BILLING_ACCOUNT_IDOption A: Use Automated Scripts
Windows:
# Update PROJECT_ID in the script first, then run:
scripts/assign_iam_roles.batLinux/macOS:
chmod +x scripts/assign_iam_roles.sh
./scripts/assign_iam_roles.shOption B: Manual Setup
# Create service account
gcloud iam service-accounts create cloud-run-svc \
--display-name="Cloud Run Logging Service Account"
# Assign required roles
SERVICE_ACCOUNT="cloud-run-svc@YOUR_PROJECT_ID.iam.gserviceaccount.com"
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT" \
--role="roles/run.developer"
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT" \
--role="roles/logging.logWriter"
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT" \
--role="roles/bigquery.dataEditor"
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT" \
--role="roles/secretmanager.secretAccessor"
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT" \
--role="roles/iam.serviceAccountUser"git clone https://github.com/pmutua/ChaosPilot
cd ChaosPilot# Create virtual environment
python -m venv .venv
# Activate virtual environment
# Windows CMD:
.venv\Scripts\activate.bat
# Windows PowerShell:
.venv\Scripts\Activate.ps1
# Linux/macOS:
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txtWindows: Use the provided mcp-toolbox/toolbox.exe
Linux/macOS: Download the appropriate binary from MCP Toolbox
cd web
npm install
cd ..Windows:
start_chaospilot.batLinux/macOS:
chmod +x start_chaospilot.sh
./start_chaospilot.sh-
Run All Services for Local Dev:
- Use
scripts/run-all.bat(Windows) orscripts/run-all.sh(Linux/macOS) to start MCP Toolbox, ADK API server, and the frontend in one step.
- Use
-
Setup Toolbox Service Account:
- Use
scripts/setup-toolbox-service-account.bat(Windows) orscripts/setup-toolbox-service-account.sh(Linux/macOS) if you need a dedicated service account for MCP Toolbox.
- Use
cd mcp-toolbox
# Windows
toolbox
# Linux/macOS
./toolbox --tools-file="tools.yaml"cd agent_manager
adk api_server --allow_origins="*"cd web
npm start# In the root directory
adk webThen:
- Open http://localhost:8000 in your browser
- Select "agent_manager" from the dropdown
- Start MCP Toolbox in a separate terminal
- Chat with your agent
# Make sure MCP Toolbox is running first
adk run agent_manager# Inject simulated error and warning logs
python scripts/inject_logs_gcp.py- Go to Google Cloud Console → Logging → Logs Explorer
- Filter by:
severity = ("ERROR" OR "WARNING") - Verify logs are visible
- Go to Log Router: https://console.cloud.google.com/logs/routing
- Click "Create Sink"
- Configure:
- Sink Name:
warnings-errors-sink - Sink Destination:
BigQuery dataset - Inclusion Filter:
severity = ("ERROR" OR "WARNING")
- Sink Name:
- Click "Create Sink"
- Go to BigQuery in GCP Console
- Check your dataset for the exported logs
- Wait a few minutes for logs to appear
Before any deployment can work, you MUST enable these Google Cloud services in your project:
# Set your project ID
export PROJECT_ID="your-gcp-project-id"
# Enable ALL required services (DO THIS FIRST!)
gcloud services enable run.googleapis.com \
cloudbuild.googleapis.com \
artifactregistry.googleapis.com \
iam.googleapis.com \
secretmanager.googleapis.com \
cloudresourcemanager.googleapis.com \
containerregistry.googleapis.comWhy this is critical:
- ❌ Cloud Run deployment will FAIL if services aren't enabled
- ❌ Build processes will FAIL without Cloud Build
- ❌ Container registry access will FAIL without Artifact Registry
- ❌ Service account operations will FAIL without IAM
- ✅ Enabling services can take a few minutes
- ✅ You only need to do this once per project
export GOOGLE_CLOUD_PROJECT="your-gcp-project-id"
export GOOGLE_CLOUD_LOCATION="us-central1"
export AGENT_PATH="./agent_manager"
export SERVICE_NAME="chaospilot-agent-service"
export APP_NAME="chaospilot-agent-app"
export GOOGLE_GENAI_USE_VERTEXAI=False# Authenticate with Google Cloud
gcloud auth login
# Set the active project
gcloud config set project $GOOGLE_CLOUD_PROJECT
# Verify services are enabled
gcloud services list --enabled --filter="name:run.googleapis.com OR name:cloudbuild.googleapis.com"# Deploy with ADK CLI (recommended)
adk deploy cloud_run \
--project=$GOOGLE_CLOUD_PROJECT \
--region=$GOOGLE_CLOUD_LOCATION \
--service_name=$SERVICE_NAME \
--app_name=$APP_NAME \
--with_ui \
$AGENT_PATHWhen prompted: Enter y to allow unauthenticated invocations for public access.
After successful deployment, you'll get a service URL like:
Service URL: https://chaospilot-agent-service-xxxxxx-uc.a.run.app
Test the deployment:
- Visit the URL in your browser to access the ADK dev UI
- Test agent functionality through the web interface
# Create dedicated service account for toolbox
gcloud iam service-accounts create toolbox-identity \
--display-name="MCP Toolbox Service Account"
# Assign required roles
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member serviceAccount:toolbox-identity@$PROJECT_ID.iam.gserviceaccount.com \
--role roles/secretmanager.secretAccessor
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member serviceAccount:toolbox-identity@$PROJECT_ID.iam.gserviceaccount.com \
--role roles/cloudsql.client# Upload tools.yaml as a secret
cd mcp-toolbox
gcloud secrets create tools --data-file=tools.yaml
# You already deployed and juts updating
gcloud secrets versions add tools --data-file=tools.yaml
# Set toolbox image
export IMAGE=us-central1-docker.pkg.dev/database-toolbox/toolbox/toolbox:latestgcloud run deploy toolbox \
--image $IMAGE \
--service-account toolbox-identity \
--region us-central1 \
--set-secrets "/app/tools.yaml=tools:latest" \
--args="--tools_file=/app/tools.yaml","--address=0.0.0.0","--port=8080" \
--allow-unauthenticated
gcloud run deploy toolbox \
--image $IMAGE \
--service-account toolbox-identity \
--region us-central1 \
--set-secrets "/app/tools.yaml=tools:latest" \
--args="--tools_file=/app/tools.yaml","--address=0.0.0.0","--port=8080" \
--allow-unauthenticatedAfter deployment, you'll get a service URL like:
Service URL: https://toolbox-xxxxxx-uc.a.run.app
Test the toolbox:
- Visit
https://toolbox-xxxxxx-uc.a.run.app/api/toolsetto see available tools - The page should display the tools configuration
In your agent_manager/agent.py, update the toolbox URL to point to the Cloud Run service:
# Replace localhost URL with Cloud Run URLFIX this
toolbox = ToolboxTool("https://toolbox-xxxxxx-uc.a.run.app")If you updated the agent configuration, redeploy:
adk deploy cloud_run \
--project=$GOOGLE_CLOUD_PROJECT \
--region=$GOOGLE_CLOUD_LOCATION \
--service_name=$SERVICE_NAME \
--app_name=$APP_NAME \
--with_ui \
$AGENT_PATHAfter successful deployment, you'll have:
| Service | URL Pattern | Purpose |
|---|---|---|
| Agent Manager | https://chaospilot-agent-service-xxxxxx-uc.a.run.app |
Main agent API and UI |
| MCP Toolbox | https://toolbox-xxxxxx-uc.a.run.app |
Database and tool services |
-
"Service not enabled" errors:
# Re-enable services gcloud services enable run.googleapis.com cloudbuild.googleapis.com
-
Authentication errors:
# Re-authenticate gcloud auth login gcloud auth application-default login -
Permission errors:
# Check if you have the Cloud Run Admin role gcloud projects get-iam-policy $PROJECT_ID --flatten="bindings[].members" --format="table(bindings.role)" --filter="bindings.members:$(gcloud config get-value account)"
-
Build failures:
- Check Cloud Build logs in the Google Cloud Console
- Verify your
requirements.txtorpyproject.tomlis correct - Ensure all dependencies are available
- Cloud Run Console: Monitor service health and logs
- Cloud Build: Check build logs for deployment issues
- IAM & Admin: Verify service account permissions
- Cloud Run: Pay only for actual usage (scales to zero)
- Cloud Build: Free tier includes 120 build-minutes/day
- Secret Manager: First 6,000 operations/month are free
- IAM: No additional cost
- Use service accounts (already configured above)
- Store secrets in Secret Manager (already done for tools.yaml)
- Consider removing
--allow-unauthenticatedfor production - Set up proper IAM roles for your team members
- Enable audit logging for security monitoring
Error: FAILED_PRECONDITION or permission denied
Solution:
- Ensure billing is enabled:
gcloud beta billing projects describe YOUR_PROJECT_ID - Link billing account if needed
- Verify you have
roles/serviceusage.serviceUsageAdminrole
Error: Frontend can't connect to ADK API
Solution:
- Use
adk api_server app --allow_origins="*" - Ensure frontend is running on port 4200
- Check that ADK server is accessible
Error: Service account does not exist
Solution:
- Run the IAM role assignment scripts again
- Verify service account name matches exactly
- Check project ID is correct
Error: Agent not available in dropdown
Solution:
- Ensure you're running
adk webfrom the parent directory ofagent_manager - Check that
agent_managerfolder contains valid agent code - Verify all dependencies are installed
Error: Toolbox not connecting
Solution:
- Ensure toolbox is running before starting ADK
- Check
tools.yamlconfiguration - Verify network connectivity
# Check enabled services
gcloud services list --enabled
# Verify service account
gcloud iam service-accounts describe cloud-run-svc@YOUR_PROJECT_ID.iam.gserviceaccount.com
# Test ADK API
curl -X POST http://localhost:8000/apps/agent_manager/users/test/sessions/test \
-H "Content-Type: application/json" \
-d '{"state": {"test": true}}'
# Check logs
gcloud logging read "resource.type=cloud_run_revision" --limit=10# Start everything (Windows)
start_chaospilot.bat
# Start everything (Linux/macOS)
./start_chaospilot.sh
# Manual startup
cd mcp-toolbox && toolbox & # Start toolbox
cd agent_manager && adk api_server app --allow_origins="*" & # Start ADK
cd web && npm start # Start frontend
# Test integration
python test_adk_integration.py- Frontend: http://localhost:4200
- ADK API: http://localhost:8000
- Dev UI: http://localhost:8000 (when using
adk web)
- ✅ Always use
--allow_origins="*"for ADK API server - ✅ Start MCP Toolbox before ADK server
- ✅ Ensure billing is enabled for GCP services
- ✅ Use the correct service account for deployments