-
Notifications
You must be signed in to change notification settings - Fork 1
Home
To build a simple web app, deploy it in the cloud, and monitor it in real-time using DevOps tools.
We started with a Python Flask app that shows a simple message like "Hello from DevOps!".
Why Flask?
- It's a lightweight Python web framework β perfect for beginners.
- Easy to write and test.
- Simple to extend with monitoring tools.
Instead of running the app manually, we wrapped it into a Docker container.
Why Docker?
- Makes the app portable: βRuns the same anywhere.β
- Simplifies deployment (no need to install Python, Flask, etc., on each server).
- Easy to manage multiple apps as containers.
We wrote a Dockerfile to: Use a Python base image. Install Flask and monitoring tools.
Start the app automatically when the container runs.
We wanted to track app usage β like how many times itβs visited.
π How? We added a special URL /metrics using prometheus_flask_exporter.
π Why /metrics?
- It gives live information like:
- How many requests your app received
- What type (GET/POST)
- What status codes (200/404/etc.)
- These are machine-readable numbers, perfect for monitoring.
We needed a server to host our app, so we used an Azure Virtual Machine (VM).
π Why Azure VM?
- Itβs like a computer in the cloud.
- You control it like your own system.
- Easy to install Docker and run multiple containers.
We used Prometheus to collect data from the app automatically.
π Why Prometheus?
- It pulls data from /metrics every few seconds.
- Stores all the data in a time-series database.
- Helps us track performance over time.
π οΈ We configured prometheus.yml to tell Prometheus:
βHey, go check on this container called webapp every 15 seconds at port 5000.β
Seeing numbers is fine⦠but visual dashboards make it easier!
π Why Grafana?
- Turns raw metrics into charts and graphs.
- Helps identify issues quickly.
- Lets you customize dashboards for your app.
π οΈ We connected Grafana to Prometheus and built a dashboard showing:
- Request rates
- Errors (if any)
- Traffic over time
Manually deploying containers every time is tiring. π Why GitHub Actions?
- It automates the process when you push code to GitHub.
- It builds the Docker image, pushes it to Docker Hub, and deploys it to the Azure VM via SSH.
π We used GitHub Secrets to keep:
- Docker credentials
- SSH key to login to the Azure VM
Prometheus couldnβt βtalkβ to Flask app until we connected both to a custom Docker network (devops-net).
π Why Docker Network? Allows containers to communicate using their names. For example, Prometheus can reach webapp:5000 because theyβre on the same network.
You have a working system where:
- A Flask app is deployed in Docker on Azure.
- Prometheus collects its metrics.
- Grafana visualizes them.
- GitHub Actions automates deployment when code is updated.