
GitHub Actions Crash Course in Kannada | Complete CI/CD Workflow with Terraform, Docker & AWS
KIRIK TECH
What you’ll learn in this video: 0️⃣ Overview of Terraform and Infrastructure as Code (IaC) 1️⃣ How to write Terraform code to deploy an Azure Ubuntu VM 2️⃣ How to connect to the VM using SSH 3️⃣ How to install and configure Prometheus 4️⃣ How to install Node Exporter to collect Linux system metrics 5️⃣ Verify Prometheus UI and Node Exporter.... 🚀 Tools Used: #Terraform #Azure CLI #Ubuntu VM #Prometheus #Node Exporter ssh azureuser@PublicIP #Rakesh #------------------------ #connect to the server #refresh package lists sudo apt update sudo apt --fix-broken install -y #configure any unpacked but unconfigured packages sudo dpkg --configure -a #check package consistency (shows problems) sudo apt-get check #try to install systemd-sysv explicitly sudo apt install -y systemd-sysv #Run these exact commands (one after another) to finish package health-check and then install Prometheus and Alertmanager as before. Paste any error if a command fails. # 1) sanity checks sudo apt update -y sudo apt --fix-broken install -y sudo dpkg --configure -a sudo apt-get check # 2) create user & dirs sudo useradd --no-create-home --shell /bin/false prometheus || true sudo mkdir -p /etc/prometheus /var/lib/prometheus /var/lib/prometheus/alertmanager ls -lrt /etc/prometheus; /var/lib/prometheus; /var/lib/prometheus/alertmanager sudo chown -R prometheus:prometheus /var/lib/prometheus /etc/prometheus /var/lib/prometheus/alertmanager # 3) download Prometheus cd /tmp wget https://github.com/prometheus/prometheus/releases/download/v2.54.1/prometheus-2.54.1.linux-amd64.tar.gz tar -xvf prometheus-2.54.1.linux-amd64.tar.gz cd prometheus-2.54.1.linux-amd64 sudo cp prometheus promtool /usr/local/bin/ sudo cp -r consoles console_libraries /etc/prometheus sudo cp prometheus.yml /etc/prometheus/ sudo chown -R prometheus:prometheus /usr/local/bin/prometheus /usr/local/bin/promtool /etc/prometheus ``` # 4) write Prometheus systemd unit sudo tee /etc/systemd/system/prometheus.service typegreatedthan symbol here/dev/null type 2 lessedthan symbol here'EOF' [Unit] Description=Prometheus Monitoring Wants=network-online.target After=network-online.target [Service] User=prometheus Group=prometheus Type=simple ExecStart=/usr/local/bin/prometheus \ --config.file=/etc/prometheus/prometheus.yml \ --storage.tsdb.path=/var/lib/prometheus/ \ --web.console.templates=/etc/prometheus/consoles \ --web.console.libraries=/etc/prometheus/console_libraries [Install] WantedBy=multi-user.target EOF # 5) start Prometheus sudo systemctl daemon-reload sudo systemctl enable --now prometheus sudo systemctl status prometheus --no-pager #Step 2 – Add your VM’s node metrics (node exporter) #----------------------------------------------- cd /tmp wget https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz tar -xvzf node_exporter-1.8.2.linux-amd64.tar.gz cd node_exporter-1.8.2.linux-amd64 sudo cp node_exporter /usr/local/bin/ sudo useradd --no-create-home --shell /bin/false nodeusr || true sudo tee /etc/systemd/system/node_exporter.service typegreatedthan symbol here/dev/null typegreatedthan symbol here'EOF' [Unit] Description=Node Exporter After=network.target [Service] User=nodeusr ExecStart=/usr/local/bin/node_exporter Restart=always [Install] WantedBy=multi-user.target EOF sudo systemctl daemon-reload sudo systemctl enable --now node_exporter sudo systemctl status node_exporter --no-pager ############################################## #Add this node to Prometheus targets sudo vi /etc/prometheus/prometheus.yml ############################# sudo vi /etc/prometheus/rules.yml groups: - name: system-alerts rules: # CPU usage typegreatedthan symbol here 80% for 2 minutes - alert: HighCPUUsage expr: 100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[2m])) * 100) typegreatedthan symbol here 80 for: 2m labels: severity: warning annotations: summary: "Rakesh High CPU usage detected on {{ $labels.instance }}" description: "CPU usage is above 80% for more than 2 minutes." # Memory usage typegreatedthan symbol here80% for 2 minutes - alert: HighMemoryUsage expr: (1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)) * 100 typegreatedthan symbol here80 for: 2m labels: severity: warning annotations: summary: "High Memory usage detected on {{ $labels.instance }}" description: "Memory usage is above 80% for more than 2 minutes." ###################### sudo systemctl restart prometheus sudo systemctl status prometheus --no-pager ```

Cloud Stack Studio