Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Using Prometheus with Kubernetes

This lab guides the student through basic Prometheus Queries (PromQL) and demonstrates how the Kubernetes architecture may be interrogated. The lab also introduces a simple means of stressing a cluster and demonstrates how those techniques affect the metrics being stored in the time series database.

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Beginner
Duration
Clock icon 1h 0m
Published
Clock icon Apr 05, 2019

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Check that your lab environment is ready.

    Log in to the master node:

    ssh cloud_user@[Public IP here]
    

    List the home directory contents:

    ls -l 
    

    Verify that stress-test.yaml is present.

  2. Challenge

    Access Prometheus from your browser.

    Access Prometheus from your browser:

    http://[Master Node public ip address]:9090
    

    You may also access the sAdvisor dashboard at the following address:

    http://[Worker Node Public IP Address]:8080
    
  3. Challenge

    Use the provided PromQL queries to interrogate your cluster.

    The following are the suggested PromQL queries you may perform.

    To measure CPU utilization:

    node_cpu_seconds_total
    
    irate(node_cpu_seconds_total{job="node"}[5m])
    
    avg(irate(node_cpu_seconds_total{job="node"}[5m])) by (instance)
    
    avg(irate(node_cpu_seconds_total{job="node",mode="idle"}[5m])) by (instance) * 100
    
    100 - avg(irate(node_cpu_seconds_total{job="node",mode="idle"}[5m])) by (instance) * 100
    

    To measure memory, use:

    (node_memory_MemTotal_bytes - (node_memory_MemFree_bytes + node_memory_Cached_bytes + node_memory_Buffers_bytes)) / node_memory_MemTotal_bytes * 100
    
  4. Challenge

    Deploy the stress test and vary its replicas to examine changes.

    In the terminal emulator session that is established to the Master Node:

    Deploy the Stress-Test Deployment:

    kubectl create -f stress-test.yaml
    

    Interrogate the number of replicas deployed:

    kubectl get deployments
    

    Interrogate the pods running:

    kubectl get pods
    
  5. Challenge

    Refresh your Prometheus graphs and scale the deployment up and down to vary metrics.

    Use refresh on your browser to see the time series metrics change over time.

    Use the following command to increase and decrease the number of replicas running in the stress-test deployment.

    kubectl scale deployment.v1.apps/stress-test --replicas=[from 1 to 50 here]
    

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans