Install Prometheus (vm)

  


               Prometheus คือตัวที่เอาไว้ใช้ moniter ทรัพยากรเครื่อง และแจ้งเตือนได้นะครับ สมมุติว่าเราสร้างต่อจาก vm ละกัน

  1. ในเครื่อง vm ใช้คำสั่ง sudo apt -y install prometheus-node-exporter
  2. ในเครื่อง host หรือ control ใช้คำสั่ง sudo apt -y install prometheus
  3. แก้ไขไฟล์ config ของ prometheus โดยใช้คำสั่งเข้าไปที่ cd /etc/prometheus/ 
  4. sudo nano prometheus.yml เข้าไปแก้ไข (หรือถ้าใช้ gui จะใช้ sudo chmod 777 prometheus.yml แล้วเปิดมาแก้ตามโปรแกรม notepad แล้วค่อยใช้ sudo chmod 755 prometheus.yml แก้คืน)
  5. โดยแก้ตามนี้นะครับ

    global:
      scrape_interval:
    60s
      evaluation_interval:
    60s
      external_labels:
        monitor: '
    vm'
    alerting:
      alertmanagers:
      - static_configs:
        - targets: ['localhost:9093']
    rule_files:
    scrape_configs:
      - job_name: 'prometheus'
      static_configs:
        - targets: ['localhost:9090']
      - job_name: 'node'
      static_configs:
        - targets: ['localhost:9100']
      - job_name: '
    node1'
      static_configs:
        - targets: ['
    192.168.1.31:9100']
      - job_name: '
    node2'
      static_configs:
        - targets: ['
    192.168.1.32:9100']

  6. แล้วใช้คำสั่ง sudo systemctl restart prometheus เพื่อให้มันดึงค่า config ใหม่นะครับ
  7. ทีนี้เปิด webbrowser แล้วเข้าไปที่ url : localhost:9090 นะครับ
  8. ไปที่ Tab Status -> Targets นะครับ จะเห็นว่าเครื่อง vm ของเรามาขึ้น STATE : UP ในนี้แล้วแสดงเชื่อมต่อสมบูรณ์นะครับ ถ้าต่อไม่ได้จะขึ้น STATE : DOWN นะครับ 
  9. เมื่อเชื่อมต่อไม่ได้ให้ลองเข้าไปเช็คที่ vm นะครับ บางทีใช้คำสั่ง sudo systemctl status prometheus-node-exporter แล้วมันจะบอกว่าไม่ได้ทำงานอยู่ ติด mask ไว้ แก้ด้วยการ sudo systemctl unmask prometheus-node-exporter แล้วก็สั่งมันทำงาน sudo systemctl start prometheus-node-exporter เอานะครับ

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

โปรโมชั่นเน็ต TOT

โน๊ตบุ๊ค acer switch sa5-271 แบตบวม T^T

Blog นี้สร้างเพื่อ?