media-lens-gcp-debug
Debug and diagnose media-lens production issues on Google Cloud Platform
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Menu
Debug and diagnose media-lens production issues on Google Cloud Platform
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Baseado na classificação ocupacional SOC
Use when the user mentions "gavel", "gavel-ai", or asks for help running, configuring, or interpreting AI evaluations with the gavel-ai framework. Covers eval setup, golden dataset preparation, scenario formatting, CLI execution, judge selection, debugging, and results interpretation. Does NOT trigger on general requests to "evaluate" code, bugs, or written documents that are unrelated to the gavel-ai eval system.
Debug and diagnose media-lens production issues on Google Cloud Platform
| name | media-lens-gcp-debug |
| type | diagnostic |
| description | Debug and diagnose media-lens production issues on Google Cloud Platform |
| domain | Media Lens Infrastructure |
| triggers | ["debug gcp","gcp debug","check gcp status","media lens isn't running","investigate production","what went wrong with gcp"] |
Media Lens runs on a scheduled GCP Managed Instance Group (MIG) (media-lens-mig, region us-west1):
gs://media-lens-storage/Follow these steps in order. Do not skip ahead. Do not start the VM. Report findings to the user before suggesting any action.
GCS is the source of truth. This requires no VM access.
# List date directories for the current month
gsutil ls gs://media-lens-storage/jobs/YYYY/MM/
# Check if a specific date exists
gsutil ls gs://media-lens-storage/jobs/YYYY/MM/DD/
Decision:
Check that all expected artifacts are present and non-empty.
# List all files for that job run
gsutil ls -l gs://media-lens-storage/jobs/YYYY/MM/DD/HHmmss/
# Expected files per site (bbc, cnn, foxnews):
# www.SITE.com.html (raw scraped HTML)
# www.SITE.com-clean.html (cleaned HTML)
# www.SITE.com-clean-extracted.json (extracted headlines)
# www.SITE.com-clean-article-0..4.json (article content)
#
# Also expected:
# daily_news.txt (daily summary — written at end of interpret step)
# Spot-check a file has content (size > 0)
gsutil cat gs://media-lens-storage/jobs/YYYY/MM/DD/HHmmss/daily_news.txt | head -20
Decision:
If data is in GCS but not live on the site, the deploy step failed. Check Cloud Logging — no VM access needed.
# View recent logs from the media-lens container on GCP Logging
gcloud logging read \
'resource.type="gce_instance" AND jsonPayload.message=~"deploy|upload|sftp|SFTP"' \
--project=medialens \
--limit=50 \
--format="table(timestamp, jsonPayload.message)"
# Broaden to all recent container output
gcloud logging read \
'resource.type="gce_instance"' \
--project=medialens \
--freshness=2d \
--limit=100 \
--format="table(timestamp, jsonPayload.message)"
Decision:
# Look for errors on a specific date (adjust date)
gcloud logging read \
'resource.type="gce_instance" AND severity>=ERROR' \
--project=medialens \
--freshness=2d \
--limit=50 \
--format="table(timestamp, severity, jsonPayload.message)"
# Check for step progression (harvest → extract → interpret → format → deploy)
gcloud logging read \
'resource.type="gce_instance" AND jsonPayload.message=~"Starting.*step|Completed|Failed|ERROR"' \
--project=medialens \
--freshness=2d \
--limit=100 \
--format="table(timestamp, jsonPayload.message)"
# List all scheduler jobs and their state
gcloud scheduler jobs list --location=us-central1 --project=medialens
# Check last execution time and status for start job
gcloud scheduler jobs describe start-media-lens-vm \
--location=us-central1 \
--project=medialens \
--format="yaml(schedule, state, lastAttemptTime, status, httpTarget.uri)"
Decision:
Before taking any action, summarize what was found:
DIAGNOSIS REPORT
================
Date(s) checked: YYYY-MM-DD
GCS status:
- Job directory: [present / missing]
- Files: [list present/missing files]
- daily_news.txt: [present and has data / missing / empty]
Deploy status:
- [Files found but not deployed / Not reached / N/A]
- Deploy logs: [any errors found]
Root cause:
- [e.g. "Job directory missing — job did not run on this date"]
- [e.g. "All files present but deploy step logged SFTP connection refused"]
- [e.g. "Cloud Scheduler job start-media-lens-vm is PAUSED"]
Suggested next steps (awaiting your approval):
1. [e.g. "Enable the Cloud Scheduler job"]
2. [e.g. "Scale MIG to 1 to inspect container logs and verify cron is running"]
3. [e.g. "Manually trigger a pipeline run to catch up on missed dates"]
Do not take any action until the user reviews this report and approves.
⚠️ The MIG is normally at targetSize=0 (no instances). Do not scale it up without explicit user approval.
If investigation requires instance access (e.g., logs not in Cloud Logging, need to inspect cron config):
# 1. Check current MIG state first
gcloud compute instance-groups managed describe media-lens-mig \
--region=us-west1 --project=medialens --format="get(targetSize,status.isStable)"
# 2. If targetSize=0 — present to user:
# "The MIG has no running instances. Scaling to 1 will start a new VM and incur
# Compute Engine charges until we scale back to 0. Shall I scale up for diagnostics?"
# 3. Only after approval:
gcloud compute instance-groups managed resize media-lens-mig \
--size=1 --region=us-west1 --project=medialens
# 4. Get instance name (wait ~2 min for it to appear):
gcloud compute instance-groups managed list-instances media-lens-mig \
--region=us-west1 --project=medialens
# 5. After diagnostics — confirm with user then scale back down:
gcloud compute instance-groups managed resize media-lens-mig \
--size=0 --region=us-west1 --project=medialens
# Replace XXXX with actual instance suffix from list-instances above
INSTANCE=media-lens-mig-XXXX
ZONE=us-west1-a # check actual zone from list-instances
# Container logs
gcloud compute ssh $INSTANCE --zone=$ZONE \
--command="docker logs media-lens --tail=100"
# Errors only
gcloud compute ssh $INSTANCE --zone=$ZONE \
--command="docker logs media-lens 2>&1 | grep -E 'ERROR|FAILED|Exception' | tail -30"
# Cron configuration
gcloud compute ssh $INSTANCE --zone=$ZONE \
--command="sudo crontab -l && sudo systemctl status cron"
# Cron job output log
gcloud compute ssh $INSTANCE --zone=$ZONE \
--command="sudo tail -100 /var/log/run-container-job.log"
# Startup script log
gcloud compute ssh $INSTANCE --zone=$ZONE \
--command="sudo tail -100 /var/log/startup-script.log"
# Disk space
gcloud compute ssh $INSTANCE --zone=$ZONE \
--command="df -h"
gs://media-lens-storage/jobs/YYYY/MM/DD/HHmmss/)| File | Written by step | Indicates |
|---|---|---|
www.SITE.com.html | harvest_scrape | Scrape succeeded |
www.SITE.com-clean.html | harvest_clean | Clean succeeded |
www.SITE.com-clean-extracted.json | extract | Extraction succeeded |
www.SITE.com-clean-article-N.json | extract | Article parsing succeeded |
daily_news.txt | interpret | Interpretation succeeded |
Missing files indicate which step failed.
gs://media-lens-storage/staging/)staging/
├── medialens.html ← index page
├── medialens-YYYY-WNN.html ← weekly report pages
└── articles/... ← article reader views
Before or during an investigation, consult these local project files for deeper context:
| File | Contents |
|---|---|
README.md | Architecture overview, data flow, pipeline stages, analysis approach |
readme-deployment.md | Step-by-step GCP setup, VM/disk/scheduler config, troubleshooting section |
startup-script.sh | Full startup automation — what runs on VM boot, Docker install, repo clone, cron setup. Logs to /var/log/startup-script.log on the VM |
Key things to know from these files:
startup-script.sh is stored in GCS (gs://media-lens-storage/startup-script.sh) and pulled by the instance template on each bootcron daemon, and builds/starts the container0 16 * * * /usr/local/bin/run-container-job.sh >> /var/log/run-container-job.log 2>&1) is set up by the startup script, not baked into the imagehttp://0.0.0.0:8080/run with the full pipeline steps| Resource | Value |
|---|---|
| Project ID | medialens |
| MIG | media-lens-mig |
| Region | us-west1 |
| Instance Template | media-lens-template-v2 |
| Container | media-lens |
| GCS Bucket | gs://media-lens-storage/ |
| Startup Script | gs://media-lens-storage/startup-script.sh |
| Scheduler Region | us-central1 |
| Start schedule | 0 15 * * * (15:00 UTC / 7 AM PT) |
| Stop schedule | 0 18 * * * (18:00 UTC / 10 AM PT) |