NCS - Documents
Go to Portal
  • NIPA Cloud Space Overview
    • Welcome to NIPA Cloud Space documentation
    • NCS User Account
      • Create NIPA Cloud Space Account
      • Loging in to Nipa Cloud Space
      • Reset NCS Password
      • Activating Two-Factor Authentication
      • Deactivating Two-Factor Authentication
    • Co-working Projects
      • Create Co-working Project
      • Manage Project Member
      • Exporting Resource List
    • Billing & Wallet
      • Topup a Project Wallet
      • Redeem Voucher
      • Insufficient Wallet Balance
  • COMPUTE
    • Compute Instance
      • What is OS Status?
      • Launching Compute Instance
      • Managing Instance
        • Stop
        • Start
        • Restart
        • Resize (Change Machine Type)
        • Take Snapshot
        • Auto Backup
        • Reset Linux "root" Password
        • Reset Windows "Administrator" Password
      • SSH to Linux Compute Instance
        • Converting Key Pair for PuTTy
        • Windows Client using Key Pair
        • Windows Client using Password
        • MacOS/Linux using Key Pairs
        • MacOS/Linux using Password
      • Remote Desktop to Windows Instance
      • Setting Docker Image Caching
      • Renaming Instance
      • Exporting Instance List
      • How to change Compute Instance hostname
      • How to install QEMU Guest Agent
      • How to fix update kernel for RHEL
      • How to Update Rocky Linux 9
      • How to Upgrade Rocky Linux to 9.4
      • How to change RDP port on Windows
    • Compute Image
      • Create Image From a Bootable Volume
      • Importing Your Own Image
      • Export Image
      • Share Image to Between Projects
      • Exporting Image List
    • Key Pair
      • Managing Key Pair(s)
      • Creating a New Key Pair
      • Importing an Existing Key Pair
    • Deployment Script
      • Managing Deployment Script
      • Create a Deployment Script
      • Clone a Deployment Script
      • Edit a Deployment Script
      • Delete a Deployment Script
  • STORAGE
    • Block Storage
      • Managing Volume(s)
        • Create From Blank
        • Create From an Image
        • Create From a Volume
        • Create From a Snapshot
        • Transferring a Volume
        • Accepting a Tranferred Volume
        • Renaming a Volume
        • How to Change Volume Type
      • Managing Snapshot(s)
        • Create a Snapshot
        • Renaming a Volume Snapshot
      • Exporting Volume and Volume Snapshot List
    • Object Storage (S3)
      • Migrate file S3 AWS to S3 NIPA
      • Create an Object Storage Bucket
      • Delete an Object Storage Bucket
      • Create an Object Storage Sub-User
      • Regenerate Sub-User's Access Key
      • Revoke Sub-User's Access Key
      • Create Bucket Policy
      • Bucket Versioning
      • Access S3 Bucket with Cyberduck
        • Upload Files to a Bucket
        • Share File via Public Link
      • Access S3 Bucket with s3cmd
        • Basic command
        • การ set ACL สำหรับการเปิดใช้งาน Objects แบบ public
        • การสร้าง Presigned URL สำหรับการใช้งานชั่วคราว
      • Mount S3 Bucket on instances with s3fs-fuse
      • Mount the S3 bucket on the Windows
      • Access S3 buckets With AWS S3 Client SDK
        • S3Client Configuration
        • Basic Command
        • Multipart Upload
      • Access S3 buckets with internal network for NCS instance
      • Delete Lifecycle Policies
      • Move Objects Lifecycle Script
      • Configure a static website using S3 Bucket
    • NIPA Drive
      • Purchasing a Drive
  • NETWORKING
    • Networking
      • Managing VPC Network(s)
        • Create a Network
        • DHCP Setting
        • Create Port
        • Create Router
      • Managing Security Group(s)
        • Create a New Security Group
        • Create Security Group Presets
      • Managing External IP(s)
        • Create an External IP
        • Exporting External IP List
      • NAT Gateway with Ubuntu (VM) แบบ Host Route
      • NAT and VPN Gateway on NCS with Pfsense-2.6.0
  • LOAD BALANCING
    • Load Balancer as a Service
      • Create Load Balancer
      • Using Network Load Balancing
      • Using Application Load Balancing
      • Renaming a Load Balancer
      • Exporting Load Balancer List
      • Monitoring Load Balancer Using Prometheus
    • SSL Certificate
      • Import SSL Certificate
  • DATABASE AS A SERVICE
    • SQL Database
      • Create SQL Database Instance
        • Create MySQL Database Instance
      • Manage SQL Database Instance
        • Reboot Database Service
        • Delete Database Instance
        • Online Extend Storage Size
        • Edit Allowed CIDR
      • Auto-Scaling SQL Database Storage
        • Enable Auto-Scaling
        • Disable Auto-Scaling
        • Edit Auto-Scaling
      • Manage SQL Database Root User
        • Enable Root User
        • Reset Root User Password
      • Manage SQL Database Schema
        • Create Database Schema
        • Delete Database Schema
      • Manage SQL Database User
        • Create Database User
        • Delete Database User
        • Reset Password
        • Edit Access
      • Manage SQL Database Backup
        • Create Backup
        • Create A New SQL Database Instance From Backup
        • Delete Backup
      • Manage SQL Database Logs
        • Enable Logs
        • Disable Logs
        • Refresh Logs
        • Load More Logs
      • Manage Monitoring User
        • Create Monitoring User
        • Delete Monitoring User
      • Monitor SQL Database with Percona Monitoring and Management (PMM)
  • SCHEDULING
    • Schedules
      • Create Schedule
    • Jobs
  • Public API
    • What is NCS Public API ?
      • Download NCS Project RC File
      • Getting Start with NCS Public API
        • Using OpenStack Client Tool
        • Using REST API
        • Terraform with Openstack
        • Auto-scaling OpenStack Instances with Senlin and Prometheus
          • Installation Prometheus
          • Installation Alertmanager
  • MIGRATION
    • Migrating Linux VM from vSphere to NCS
    • Migrating Windows VM from vSphere to NCS
  • Customer Support
    • Having Problem Before Access a Project
    • Having Problem In a Project
  • Tutorial
    • My First Website
    • Access MySQL Database With MySQL Workbench
    • Pritunl for VPN server
    • Install Rancher Server with Docker Quick Start
      • Create RKE2 Cluster via Rancher Dashboard
    • Install odoo18 with external database
    • How to use LBaaS for mysql Load Balancing
    • How to use Cloudflare with Nipa Cloud Space
  • Release Notes
    • v5.0.X (v5.0.0-now)
      • v5.0.0
      • v5.1.0
      • v5.2.0
      • v5.2.1
      • v5.2.2
      • v5.2.3
      • v5.2.4
      • v.5.3.0
      • v5.4.0
    • v4.19.X (v4.19.0-v4.19.3)
      • v4.19.0
      • v4.19.1
      • v4.19.2
      • v4.19.3
    • v4.18.X (v4.18.0-v4.18.2)
      • v4.18.0
      • v4.18.1
      • v4.18.2
    • v4.17.X (v4.17.0-v4.17.3)
      • v4.17.0
      • v4.17.0.1
      • v4.17.1
      • v4.17.2
      • v4.17.3
    • v4.16.X (v4.16.0-v4.16.5)
      • v4.16.0
      • v4.16.1
      • v4.16.2
      • v4.16.3
      • v4.16.4
      • v4.16.5
    • v4.15.X (v4.15.0-v4.15.9)
      • v4.15.0
      • v4.15.1
      • v4.15.2
      • v4.15.3
      • v4.15.4
      • v4.15.5
      • v4.15.6
      • v4.15.7
      • v4.15.8
      • v4.15.9
    • v.4.14.X (v4.14.0-v4.14.2)
      • v.4.14.0
      • v4.14.1
      • 4.14.2
Powered by GitBook
On this page
  • Prerequisite
  • Instructions
  • a. สร้าง Prometheus Listener
  • b. ติดตั้ง Prometheus
  • b. ติดตั้ง Grafana

Was this helpful?

  1. LOAD BALANCING
  2. Load Balancer as a Service

Monitoring Load Balancer Using Prometheus

monitor การใช้งาน Load Balancer ให้ละเอียดยิ่งขึ้น ด้วยการใช้งาน Prometheus และ Grafana

PreviousExporting Load Balancer ListNextSSL Certificate

Last updated 4 months ago

Was this helpful?

Prerequisite

  • มียอดคงเหลือใน Project มากกว่า 0 บาท (ขั้นตอนการเติมเงินเข้าสู่ Project)

  • มี Load Balancer ที่ต้องการ monitor ด้วย Prometheus และ Grafana

Instructions

ขั้นตอนในการ monitor Load Balancer ด้วย Prometheus และ Grafana แบ่งออกเป็น 3 ขั้นตอน

a. สร้าง Listener ที่มี protocol เป็น Prometheus

b. ติดตั้ง Prometheus

b. ติดตั้ง Grafana

a. สร้าง Prometheus Listener

ขั้นตอนในการสร้าง Listener ที่มี protocol เป็น Prometheus มีดังนี้

1. เข้าหน้า Load Balancer detail

เข้าหน้า Load Balancer detail โดยการ click ที่ชื่อ Load Balancer ในหน้า Load Balancer list

2. เข้าหน้าสร้าง Listener

เปิดหน้าสร้าง Listener จากการ click ปุ่มที่แถบ menu bar

3. สร้าง Listener ที่มี protocol เป็น Prometheus

ในหน้าสร้าง Listener เลือก protocol เป็น Prometheus และเลือก port เป็นเลขที่ต้องการ และ click ปุ่ม CREATE เพื่อ confirm การสร้าง

b. ติดตั้ง Prometheus

ติดตั้ง Prometheus ใน server โดยในตัวอย่างนี้ จะเลือกติดตั้งบน Compute Instance

1. สร้าง directory ใหม่

สร้าง directory ใหม่ที่ path /opt/prometheus-setup เพื่อเก็บ file ที่จะดาวน์โหลด โดยใช้ command

sudo mkdir /opt/prometheus-setup
cd /opt/prometheus-setup

2. สร้าง user ชื่อ prometheus

sudo useradd prometheus

3. ดาวน์โหลด Prometheus server

ใช้ wget ดาวน์โหลด Prometheus server จาก Github ซึ่งควรใช้เป็น version ล่าสุด (ตรง {version} ให้ใส่ version ล่าสุดลงไป)

wget https://github.com/prometheus/prometheus/releases/download/v{version}/prometheus-{version}.linux-amd64.tar.gz 

4. เเตกไฟล์ที่ download มา

ใช้ tar เเตกไฟล์ prometheus-{version}.linux-amd64.tar.gz

tar -xvzf prometheus-{version}.linux-amd64.tar.gz

5. จัดการ file และกำหนดสิทธิเข้าถึง

เพิ่มไฟล์ที่เเตกออกมาลงใน path เพื่อให้สามารถเข้าถึงได้ง่าย และ เปลี่ยนการจัดการในไฟล์เเละไดเรกทอรี กับ user prometheus

sudo mv prometheus-{version}.linux-amd64 prometheus
sudo mv  prometheus/prometheus  /usr/bin/
sudo chown prometheus:prometheus /usr/bin/prometheus
sudo mkdir /etc/prometheus
sudo cp prometheus/prometheus.yml /etc/prometheus/
sudo chown -R prometheus:prometheus /etc/prometheus
sudo chown -R prometheus:prometheus /opt/prometheus-setup

6. ทดสอบ version ของ Prometheus server

ทดสอบการติดตั้ง Prometheus โดยการใช้ command นี้ เพื่อดู version ของ Prometheus

prometheus --version

โดยผลลัพท์ควรจะเป็นดังนี้

7. สร้าง service ของ Prometheus

สร้าง service ของ Prometheus

sudo vi /etc/systemd/system/prometheus.service

จากนั้น add config ดังนี้

[Unit]
Description=Prometheus

[Service]
User=prometheus
ExecStart=/usr/bin/prometheus --config.file /etc/prometheus/prometheus.yml --storage.tsdb.path /opt/prometheus-setup/

[Install]
WantedBy=multi-user.target

8. start service Prometheus

ใช้ systemd daemon เเละ start Prometheus service

sudo systemctl daemon-reload
sudo systemctl start prometheus
sudo systemctl enable prometheus

9. แก้ไข config source ของ Prometheus

เปิด file config

sudo vi /etc/prometheus/prometheus.yml

โดยใช้ config และระบุ IP address ของ Load Balancer และ port ของ Listener ดังนี้

# my global configuration which means it will applicable for all jobs in file
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. scrape_interval should be provided for scraping data from exporters 
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. Evaluation interval checks at particular time is there any update on alerting rules or not.

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'. Here we will define our rules file path 
#rule_files:
#  - "node_rules.yml"
#  - "db_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape: In the scrape config we can define our job definitions
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'node-exporter'
    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'. 

    # target are the machine on which exporter are running and exposing data at particular port.
    static_configs:
        - targets: ['{Load Balancer IP address}:{Listener port}']

10. restart Prometheus service

sudo systemctl restart prometheus

11. ตรวจสอบการทำงานของ Prometheus

ใช้ browser เข้าไปดู หน้า homepage ของ Prometheus ที่ URL http://{your_server_ip}:9090 และ ดู metrics ที่มาจาก load balancer ได้

b. ติดตั้ง Grafana

ติดตั้ง Grafana ใน Compute Instance เดียวกันกับ Prometheus

1. update และ upgrade apt

สั่ง update และ upgrade apt ด้วย command นี้

sudo apt update -y && sudo apt upgrade -y

2. ติดตั้ง package ที่จำเป็นของ Grafana

ติดตั้ง package ที่จำเป็นของ Grafana โดยใช้ command นี้

sudo apt install -y apt-transport-https software-properties-common wget

3. ติดตั้ง Grafana GPG

download และ จัดเก็บ Grafana GPG ด้วย command นี้

sudo mkdir -p /etc/apt/keyrings/
wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null

4. เพิ่ม Grafana APT repository

เพิ่ม Grafana APT repository ด้วย command นี้

echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list

แล้วต่อด้วย command

sudo apt update

5. ติดตั้ง Grafana

ติดตั้ง Grafana โดยใช้ command นี้

sudo apt install grafana

6. เปิดใช้งาน Grafana

ตรวจสอบ version ของ Grafana ด้วย command นี้

sudo grafana-server -v

เปิดการทำงานของ Grafana ด้วย command นี้

sudo systemctl start grafana-server
sudo systemctl enable grafana-server

7. ตรวจสอบการทำงานของ Grafana service

ตรวจสอบการทำงานของ Grafana service ด้วย command นี้

sudo systemctl status grafana-server

8. เข้าใช้งาน Grafana ผ่าน UI

เข้า URL http://{your_server_ip}:3000 เพื่อเปิด Grafana UI โดยใช้

Username: admin

Password: admin

10. เพิ่ม datasource จาก Prometheus

เพิ่ม datasource จาก Prometheus จาก connections > data sources

เลือก Prometheus และกำหนด Prometheus server URL เป็น http://localhost:9090

11. ปรับแต่ง Grafana dashboard

ปรับแต่ง Grafana dashboard ตามต้องการ

Load Balancer list
Load Balancer detail
Load Balancer - Listener list