Skip to content

google/premium-vs-standard-network-latency

Shell script for uploading network latency custom metrics to Cloud Operations Suite

screenshot screenshot

Disclaimer

  1. Use at your own risk, no warranties are provided. Refer to the License Summary section.
  2. This solution will not be supported by Google Cloud.
  3. Proper testing should be done before running this tool in production.

License Summary

This sample code is made available under Apache 2 license. See the LICENSE file.

GCP Costs

  1. Google Cloud Observability Pricing
    (Free for the first 150 MiB per billing account https://cloud.google.com/stackdriver/pricing#google-cloud-observability-pricing, https://cloud.google.com/stackdriver/pricing#monitoring-costs)

  2. Backend e2-micro instance(s) cost. *1 e2-micro is eligible under free usage limit.
    (https://cloud.google.com/compute/vm-instance-pricing#e2_sharedcore_machine_type)

Prerequisites

  • Either Debian or Mac env required.
  1. Setup GCP SDK - https://cloud.google.com/sdk

  2. Initialize the SDK for the target account

    gcloud init
    gcloud auth application-default login
    https://cloud.google.com/docs/authentication/gcloud#gcloud-credentials

  3. Replace ISP and Project ID in prereq.sh and run.

    bash prereq.sh

    This will set env variables.

  4. *Optional: Disable Restrict external IP addresses to specific VMs constraint if it is defined in the Organization Policy if you want to test the script on GCE.

    gcloud resource-manager org-policies set-policy disable_vmExternalIpAccess.json --project=$PROJECT_ID

  5. Modify backendRegion.csv to list the regions/zones you wish to measure latency.

  6. Requires preconfigured VPC Network and Subnet for each of the Regions defined in the backendRegion.csv.

  7. Requires the Cloud Monitoring API to be enabled.

  8. Requires the following IAM roles/permissions.

    At the project level:

    1. Compute Admin
    2. Compute Network Admin
    3. Logging Admin
    4. Monitoring Admin
    5. Monitoring Editor
    6. Monitoring Viewer

    At the organization level:

    1. Compute Organization Firewall Policy Admin
    2. *Optional: Organizational Policy Admin
  9. Install jq

    Example
    sudo apt-get install jq
    or
    brew install jq

  10. Install dig

    Example
    sudo apt-get install dnsutils

  11. Mac Only

Setup Latency Collection Schedule

  1. Replace Backend Region and Zone in backendRegion.csv.

  2. Run setup.sh to create backend instances and setup crontab schedules.

    bash setup.sh

    This will setup 2 e2-micro instances per region defined in backendRegion.csv, one for premium and standard network each. It'll then setup crontab schedule to execute every minute that'll collect latency custom metrics to the backend instances. It'll also find out the current machine's public ip address and create a firewall rule that allows icmp to ingress into backend instances. Note that it'll only create backend instances when it can't find any.

Clean up instructions

  1. Run deleteBackend.sh to delete backend instances and ingresss firewall rules.

    bash deleteBackend.sh

    This will delete premium and standard network backend e2-micro instances in the regions defined in backendRegion.csv and also delete ingress firewall rules.

  2. Run deleteMetrics.sh to delete the custom metrics.

    bash deleteMetrics.sh backendRegion.csv

    Note that all the accumulated latency custom metrics will be deleted, proceed with caution.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages