This document describes monitoring of access to a collection of URLs from a
fleet of HTTP probes deployed in multiple geographic locations. Connection
latency, including DNS lookup, TLS handshake, connection establishment, and data
transfer are recorded. For background on the HTTP probe see the post
[https://medium.com/google-cloud/identification-of-sources-of-mobile-client-connection-failure-fec9dad8dd13 Identification of sources of mobile client connection failure]. Kubernetes clusters will be
deployed to multiple zones, each with multiple probes. Each instance of a probe
will send requests to a single URL.
Enable the Stackdriver and Kubernetes Engine APIs in the Cloud Console. Edit the included config.yaml file for the id of your project, target URLs and zones to deploy the probes to.
Create a service account in the console and download the key json file into the directory that you run these commands from. Assign the service account role Project > Owner when you create it.
export GOOGLE_APPLICATION_CREDENTIALS=???.json
Define the Stackdriver custom metric:
docker build -f Dockerfile-define-metrics -t define_metrics .
docker run -it \
--env GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS \
define_metrics
Build and deploy the probe in a Docker container:
docker build -f Dockerfile-httpprobe -t httpprobe .
PROJECT_ID=[Your project]
ZONE=us-east1-b
TARGET_URL=[Your URL]
TARGET_URL_LABEL=[Your label]
docker run -it --env PROJECT_ID=$PROJECT_ID \
--env GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS \
--env ZONE=$ZONE \
--env TARGET_URL=$TARGET_URL \
--env TARGET_URL_LABEL=$TARGET_URL_LABEL \
httpprobe
Uploading to the Google Container Repo
gcloud auth configure-docker
TAG=v1
docker tag httpprobe gcr.io/$PROJECT_ID/httpprobe:$TAG
docker push gcr.io/$PROJECT_ID/httpprobe:$TAG
Start up a GKE cluster in each zone:
gcloud components install kubectl
gcloud config set project $PROJECT_ID
gcloud config set compute/zone $ZONE
CLUSTER_NAME=probes-$ZONE
gcloud container clusters create $CLUSTER_NAME --zone $ZONE --num-nodes 1
gcloud container clusters get-credentials $CLUSTER_NAME --zone $ZONE
Deploy a probe for each URL to each cluster
TARGET_URL=[Your URL]
TARGET_URL_LABEL=[Your label]
HTTP_PROBE_WORKLOAD=httpprobe-$ZONE-$TARGET_URL_LABEL
kubectl run $HTTP_PROBE_WORKLOAD --image gcr.io/$PROJECT_ID/httpprobe:$TAG \
--env="PROJECT_ID=$PROJECT_ID" \
--env GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS \
--env ZONE=$ZONE \
--env TARGET_URL=$TARGET_URL \
--env TARGET_URL_LABEL=$TARGET_URL_LABEL \
--limits="cpu=50m,memory=128Mi"
Apache 2.0 Copyright 2018 Google. All rights reserved.