Giter Club home page Giter Club logo

nd081-c4-azure-performance-project-starter's Introduction

Enhancing Applications

In this project, you will apply the skills you have acquired in the Azure Performance course to collect and display performance and health data about an application. This is only half the battle; the other half is making informed decisions about the data and automating remediation tasks. You will use a combination of cloud technologies, such as Azure Kubernetes Service, VM Scale Sets, Application Insights, Azure Log Analytics, and Azure Runbooks to showcase your skills in diagnosing and rectifying application and infrastructure problems.

In this project, you'll be tasked to do the following:

  • Setup Application Insights monitoring on a VMSS and implement monitoring in an application to collect telemetry data
  • Setup an auto-scaling for a VMSS
  • Setup an Azure Automation account and create a RunBook to automate the resolution of performance issues
  • Create alerts to trigger auto-scaling on an AKS cluster and trigger a RunBook to execute

Getting Started

Prerequisites

  1. Create a free Azure Account
  2. Create a free Azure DevOps account (Click Start Free under Azure Pipelines)
  3. VS Code or your preferred editor Install the VS Code extensions for Python (optional)
  4. Azure CLI

Dependencies

Required Python Libraries:

  • redis
  • opencensus-ext-azure
  • opencensus-ext-flask
  • flask

A requirements.txt has been provided if you want to first run the application in a local environment.

NOTE: The app.run() in main.py is set for your local environment. Use app.run(host='0.0.0.0', threaded=True, debug=True) when deploying to a VM Scale Set.

Local Environment Setup (Optional)

If you want to run the application on localhost, follow the next steps; otherwise, you can skip to Azure Environment Setup.

Install Redis

  1. Download and install redis-server for your operating system:
  1. Start redis-server

Create a Virtual Environment

  1. Create a virtual environment inside the azure-vote folder
  2. Activate the environment
  3. Install dependencies from requirements.txt
  4. Run main.py

NOTE: The app.run() in main.py is set for your local environment. Use app.run(host='0.0.0.0', threaded=True, debug=True) when deploying to a VM Scale Set.

Azure Environment Setup

Azure VM Scale Set

A bash script has been provided to automate the creation of the VMSS. You should not need to modify this script.

Note: You'll need Azure CLI installed before using this script.

  1. Log in to Azure using az login.
  2. Run ./setup-script.sh in your terminal.

The script will take a few minutes to create and configure all resources. Once the script is complete, you can go to Azure portal and look for the acdnd-c4-project resource group. Inside is the VMSS resource. You'll use the public IP address and port 50000 to connect to the VM. It's port 50000 because the inbound NAT rule of the load balancer defaults to port 50000.

The following command will connect you to your VM. Note: Replace [public-ip] with the public-ip address of your VMSS.

ssh -p 50000 udacityadmin@[public-ip]

Setup Azure Pipeline to Deploy to VM Scale Set

We'll use Azure Pipelines to deploy our application to an Azure VM Scale Set. Follow the step-by-step instructions here.

Project Instructions

Application Insights & Log Analytics

  1. Create a Log Analytics workspace resource
  2. Create an Application Insights resource and use the Log Analytics workspace created in step 1
  3. Enable Application Insights monitoring for the VM Scale Set
  4. Add the reference Application Insights to main.py and specify the instrumentation key
  5. Add custom event telemetry when 'Dogs' is clicked and when 'Cats' is clicked.
  6. Create a query to view the event telemetry in Log Analytics.
  7. Create a chart from query showing when 'Dogs' or 'Cats' is clicked.

Monitoring Containers

  1. Run az login to login, then run ./create-cluster.sh to create an AKS cluster and deploy a container to it.
  2. Once that is completed, go to Insights for the cluster.
  3. Observe the state of the cluster. Note the number of nodes and number of containers.
  4. Create an alert in Azure Monitor to trigger when the number of pods increases over a certain threshold.
  5. Create an autoscaler by using the following Azure CLI command—kubectl autoscale deployment azure-vote-front --cpu-percent=70 --min=1 --max=10
  6. Cause load on the system
  7. After approximately 10 minutes, stop the load.
  8. Observe the state of the cluster. Note the number of pods; it should have increased and should now be decreasing.

Autoscaling

  1. For the VM Scale Set, create an autoscaling rule based on metrics.
  2. Trigger the conditions for the rule, causing an autoscaling event.
  3. When complete, enable manual scale.

Runbook

  1. Create an Azure Automation Account
  2. Create a Runbook—either using a script or the UI—that will remedy a problem.
  3. Create an alert which uses a runbook to remedy a problem.
  4. Cause the problem to the flask app on the VM Scale Set.
  5. Verify the problem is remedied via the Runbook.

Submissions

  1. The main.py which will show the code for the Application Insights telemety data.
  2. Screenshots for the kubernetes cluster which include: Note: Place all screenshots for Kubernetes Cluster in the submission-screenshots/kubernetes-cluster directory
    • The output of the Horizontal Pod Autoscaler, showing an increase in the number of pods.
    • The Application Insights metrics which show the increase in the number of pods.
    • The email you received from the alert when the pod count increased.
  3. Screenshots for the Application Insights which include: Note: Place all screenshots for Application Insights in the submission-screenshots/application-insights directory
    • The metrics from the VM Scale Set instance--this will show CPU %, Available Memory %, Information about the Disk, and information about the bytes sent and received. There will be 7 graphs which display this data.
    • Application Insight Events which show the results of clicking 'vote' for each 'Dogs' & 'Cats'
    • The output of the traces query in Azure Log Analytics.
    • The chart created from the output of the traces query.
  4. Screenshots for the Autoscaling of the VM Scale Set which include: Note: Place all screenshots for Autoscaling VMSS in the submission-screenshots/autoscaling-vmss directory
    • The conditions for which autoscaling will be triggered (found in the 'Scaling' item in the VM Scale Set).
    • The Activity log of the VM scale set which shows that it scaled up with timestamp.
    • The new instances being created.
    • The metrics which show the load increasing, then decreasing once scaled up with timestamp.
  5. Screenshots for the Azure Runbook which include: Note: Place all screenshots for RunBook in the submission-screenshots/runbook directory
    • The alert configuration in Azure Monitor which shows the resource, condition, action group (this should include a reference to your Runbook), and alert rule details (may need 2 screenshots).
    • The email you received from the alert when the Runbook was executed.
    • The summary of the alert which shows 'why did this alert fire?', timestamps, and the criterion in which it fired.

Built With

Software

  • Python - Programming Language
  • VS Code - Integrated Development Environment
  • Azure DevOps - Source control and pipeline creation tool.

Open-source 3rd-party

License

License

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

nd081-c4-azure-performance-project-starter's People

Contributors

chrvasq avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.