Trick-or-Metric | GSP1025
Solution for Trick-or-Metric | GSP1025. 1 lab: GSP1025. Fast copy-paste commands for Google Cloud.
GSP1025 — Migrate Existing Prometheus Monitoring Workloads to Google Cloud
Estimated time: 15 minutes
# 🚀 Migrate Existing Prometheus Monitoring Workloads to Google Cloud (GSP1025) > ⚠️ **Disclaimer:** This is an independent, community-made walkthrough created for educational purposes, hands-on practice, and Google Cloud certification preparation. This guide is designed to help learners understand Google Cloud services and complete practical exercises. Always attempt the lab yourself first and follow Google Cloud Skills Boost / Qwiklabs Terms of Service. This walkthrough is not affiliated with
set +H
clear
CYAN='\e[1;36m'
GREEN='\e[1;32m'
YELLOW='\e[1;33m'
BOLD='\e[1m'
RESET='\e[0m'
echo -e "${CYAN}${BOLD}"
echo " ____ _ _ _ __ ___ "
echo " / __ \ | | (_) | / _| / _ \ "
echo "| | | |_ __| |__ _| |_ ___ | |_ | | | |_ __ ___ "
echo "| | | | '__| '_ \| | __| / _ \ | _| | | | | '_ \/ __|"
echo "| |__| | | | |_) | | |_ | (_) || | | |_| | |_) \__ \\"
echo " \____/|_| |_.__/|_|\__| \___/ |_| \___/| .__/|___/"
echo " | | "
echo " |_| "
echo -e "${RESET}"
echo -e "\e[1;35m╔════════════════════════════════════════════════════════════╗\e[0m"
echo -e "\e[1;35m║ Command 1 of 1: Self-Deployed Prometheus Automation ║\e[0m"
echo -e "\e[1;35m╚════════════════════════════════════════════════════════════╝\e[0m"
export PROJECT_ID=$(gcloud config get-value project 2>/dev/null)
echo -e "\n\e[1;34m[+] Auto-fetching Project Zone...\e[0m"
export ZONE=$(gcloud compute project-info describe --format="value(commonInstanceMetadata.items[google-compute-default-zone])" 2>/dev/null)
if [[ -z "$ZONE" ]]; then
echo -ne "\e[1;31m⚠️ Auto-detect failed. \e[1;33mPlease enter your lab Zone (e.g., us-central1-a): \e[0m"
read ZONE
fi
echo -e "✅ Project ID: \e[1;32m$PROJECT_ID\e[0m"
echo -e "✅ Zone: \e[1;32m$ZONE\e[0m"
echo -e "\n\e[1;34m[+] Task 1: Provisioning GKE Cluster (This takes ~3-5 minutes)...\e[0m"
gcloud container clusters create gmp-cluster --num-nodes=3 --zone=$ZONE --quiet
gcloud container clusters get-credentials gmp-cluster --zone=$ZONE --quiet
echo -e "\n\e[1;34m[+] Creating Namespace 'gmp-test'...\e[0m"
kubectl create ns gmp-test --dry-run=client -o yaml | kubectl apply -f - >/dev/null 2>&1
echo -e "\n\e[1;34m[+] Task 2: Deploying Example Application...\e[0m"
kubectl -n gmp-test apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/prometheus-engine/v0.4.3-gke.0/examples/example-app.yaml
echo -e "\n\e[1;34m[+] Task 3: Deploying Prometheus...\e[0m"
kubectl -n gmp-test apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/prometheus-engine/v0.4.3-gke.0/examples/prometheus.yaml
echo -e "\n\e[1;34m[+] Task 4: Configuring and Deploying Frontend Metrics API...\e[0m"
curl -s https://raw.githubusercontent.com/GoogleCloudPlatform/prometheus-engine/v0.4.3-gke.0/examples/frontend.yaml | sed "s/\$PROJECT_ID/$PROJECT_ID/" | kubectl apply -n gmp-test -f -
echo -e "\n\e[1;34m[+] Task 5: Deploying Grafana...\e[0m"
kubectl -n gmp-test apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/prometheus-engine/v0.4.3-gke.0/examples/grafana.yaml
echo -e "\n\e[1;33m[+] Waiting for all pods to reach 'Running' state (Takes ~2 minutes)...\e[0m"
kubectl wait --for=condition=ready pod --all -n gmp-test --timeout=300s
echo -e "\n\e[1;32m🎉 AUTOMATION COMPLETED SUCCESSFULLY 🎉\e[0m"
echo -e "\e[1;37mNote: The grader only checks cluster deployments. You do NOT need to port-forward or use the Grafana UI.\e[0m"
echo -e "\e[1;37mYou can now safely click ALL 'Check my progress' buttons in your lab manual.\e[0m"