DevOps AI
  • Home
  • Bảo mật
  • AI & Automation
  • DevOps & Cloud
  • Bộ đề luyện thi cloud
No Result
View All Result
DevOpsAI
  • Home
  • Bảo mật
  • AI & Automation
  • DevOps & Cloud
  • Bộ đề luyện thi cloud
No Result
View All Result
DevOpsAI
No Result
View All Result
Home DevOps & Cloud

Grafana là gì? Dựng Grafana – Prometheus để monitor Server

Setup bộ tool monitoring & logging cơ bản với grafana, prometheus

Hiếu Tạ by Hiếu Tạ
25 Tháng 4, 2025
in DevOps & Cloud
0
Share on FacebookShare on Twitter

Grafana là gì?

Grafana là gì ? Grafana là một giao diện/dashboard theo dõi hệ thống (opensource). Hướng dẫn tìm hiểu Grafana là gì và Prometheus để monitor server Công cụ cho phép giám sát trực quan hóa dữ liệu, có thể tạo các cảnh báo, bộ lọc đặc biệt cho dữ liệu.

Tại sao sử dụng Grafana

  • Grafana là gì: Sử dụng để giám sát cơ sở hạ tầng.
  • Giúp theo dõi người dùng, sự kiện dễ dàng vì nó tự động hóa việc thu thập, quản lý và xem dữ liệu.
  • Các nhà lãnh đạo, phân tích bảo mật, nhà phát triển,… sử dụng dữ liệu được phân tích, được trực quan hóa để đưa ra các quyết định của họ.
  • Sử dụng nguồn dữ liệu đa dạng (AWS CloudWatch, Microsoft SQL Server, Prometheus, MySQL, InfluxDB,…
  • Trực quan hóa đa dạng, có nhiều tùy chọn để trực quan hóa.
  • Cho phép đưa ra các cảnh báo thông qua Slack, PagerDuty khi một chỉ số dữ liệu đạt được một ngưỡng được đặt trước.
  • Có thể tập hợp dữ liệu với nhau từ các nguồn khác nhau.
  • Trang tổng quan: trực quan hóa dữ liệu với báo cáo mẫu hoặc tùy chỉnh theo mục đích, cho phép chia sẻ báo cáo.

Cài đặt

Cài đặt Prometheus

Là một hệ thống mã nguồn mở, sử dụng để giám sát dựa trên các số liệu. Nó thu thập dữ liệu từ các service và host. Dữ liệu sau đó được lưu trong cơ sở dữ liệu chuỗi thời gian (time-series database)

Download

cd /tmp 
wget https://github.com/prometheus/prometheus/releases/download/v2.36.2/prometheus-2.36.2.linux-amd64.tar.gz

Unzip

Related Post

GitHub Action DevOpsify Check Tool – Tự động kiểm tra bảo mật & hiệu suất

GitHub Action DevOpsify Check Tool – Tự động kiểm tra bảo mật & hiệu suất

11 Tháng 6, 2025
DevOpsify Check Tool – Công cụ dòng lệnh đa năng cho DevOps, IT và lập trình viên

DevOpsify Check Tool – Công cụ dòng lệnh đa năng cho DevOps, IT và lập trình viên

7 Tháng 6, 2025

Hướng Dẫn Thiết Lập LDAPS Trên Windows Server 2022

26 Tháng 4, 2025

Đổi MTU cho Calico trong Kubernetes

30 Tháng 4, 2025
tar -xzf prometheus-2.36.2.linux-amd64.tar.gz

Move to /opt

sudo mv prometheus-2.36.2.linux-amd64 /opt/prometheus/ 
cd /opt/prometheus/

Add user

$ sudo useradd -s /sbin/false prometheus

Add permission and ownership

$ sudo chmod 775 .
$ sudo chown -R prometheus:prometheus .

Setup prometheus as a service

$ sudo nano /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus Server
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/opt/prometheus/prometheus 
--config.file=/opt/prometheus/prometheus.yml 
--storage.tsdb.path=/opt/prometheus/ 
--web.console.templates=/opt/prometheus/consoles 
--web.console.libraries=/opt/prometheus/console_libraries
[Install]
WantedBy=multi-user.target

Start Prometheus

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

Open browser on port 9090

Cài đặt Grafana

Add key to APT key

$ wget -q -O – https://packages.grafana.com/gpg.key | sudo apt-key add –

Add Grafana repository to APT sources

$ sudo add-apt-repository “deb https://packages.grafana.com/oss/deb stable main”

Update packages

$ sudo apt update

Install Grafana

$ sudo apt install grafana

Start Grafana server

$ sudo systemctl start grafana-server

Show status Grafana server

$ sudo systemctl status grafana-server

Enable Grafana at boot time

$ sudo systemctl enable grafana-server

Open Browser on port 3000

Cài đặt Node Exporter

Là package chính thức được sử dụng để lấy nhiều thông tin phần cứng và các thông số hệ điều hành linux.

Download

$ cd /tmp
$ wget https://github.com/prometheus/node_exporter/releases/download/v1.0.0-rc.1/node_exporter-1.0.0-rc.1.linux-amd64.tar.gz

Unzip

$ tar -xzf node_exporter-1.0.0-rc.1.linux-amd64.tar.gz

Move to /opt/node_exporter

$ sudo mv node_exporter-1.0.0-rc.1.linux-amd64 /opt/node_exporter
$ cd /opt/node_exporter

Setup Node Exporter as a Service

$ sudo nano /etc/systemd/system/node_exporter.service
[Unit]
Description=node_exporter
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/opt/node_exporter/node_exporter
[Install]
WantedBy=multi-user.target

Start Node Exporter

$ sudo systemctl daemon-reload
$ sudo systemctl start node_exporter
$ sudo systemctl enable node_exporter
$ sudo systemctl status node_exporter

Add Node Exporter to Prometheus

Edit prometheus.yml

$ sudo nano /opt/prometheus/prometheus.yml
...
scrape_configs:
  ...
  - job_name: 'node_exporter'
	  static_configs:
	    - targets: ['localhost:9100']
...

Restart Prometheus

$ sudo systemctl restart prometheus

Check targets

  • open Prometheus on browser → Status → Targets

Tích hợp Prometheus vào Grafana

Open Grafana → Configure

Chọn Data source -> Add data source -> search prometheus

set url = http://localhost:9090 → save

Tạo dashboard

Chọn Dashboards → import

Set ID = *1860 → load*

Set Prometheus = Prometheus → import

Kết quả:

Chúc các đồng chí thành công

grafana

Chọn last 15 minutes và refesh 1m ở góc phải phía trên


Tags: công cụdemohệ điều hànhkiến trúcloggingmornitoringpackagerepositorySQLtool
Hiếu Tạ

Hiếu Tạ

Graduated as a Software Engineer. I have more than 3-year experience in developing software and DevOps, used to many services of AWS, and Azure, K8S, and using Windows or Linux on-premies proficiently to set up servers, proxy, build and deploy multiple programming languages (Java, GO, NET,...)..... Experience with CMS such SiteCore, ElasticPath, AEM... Implement CICD via Jenkins scripting, infrastructure as code via Terraform, and AWS Cloud Formation.

Related Posts

GitHub Action DevOpsify Check Tool – Tự động kiểm tra bảo mật & hiệu suất
DevOps & Cloud

GitHub Action DevOpsify Check Tool – Tự động kiểm tra bảo mật & hiệu suất

by devopsify
11 Tháng 6, 2025
DevOpsify Check Tool – Công cụ dòng lệnh đa năng cho DevOps, IT và lập trình viên
Bảo mật

DevOpsify Check Tool – Công cụ dòng lệnh đa năng cho DevOps, IT và lập trình viên

by devopsify
7 Tháng 6, 2025
Hướng Dẫn Thiết Lập LDAPS Trên Windows Server 2022
DevOps & Cloud

Hướng Dẫn Thiết Lập LDAPS Trên Windows Server 2022

by devopsify
26 Tháng 4, 2025
Next Post

5 TypeScript config giúp code của bạn chất lượng hơn

Để lại một bình luận Hủy

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Recommended

Các website demo hay được sử dụng cho thực hành Automation Test

Các website demo hay được sử dụng cho thực hành Automation Test

11 Tháng 6, 2025
Cài đặt Maven trên Windows

Cài đặt Maven trên Windows

11 Tháng 6, 2025
Hướng dẫn cài đặt Kubernetes trên Ubuntu 22.04

Hướng dẫn cài đặt Kubernetes trên Ubuntu 22.04

1 Tháng 5, 2025
Tổng hợp các phiên bản Stable Diffusion: So sánh, tính năng và yêu cầu phần cứng

Tổng hợp các phiên bản Stable Diffusion: So sánh, tính năng và yêu cầu phần cứng

13 Tháng 6, 2025
Sử dụng VS Code và Playwright MCP tự động test demo website Demoblaze thông qua GitHub Copilot Agent

Sử dụng VS Code và Playwright MCP tự động test demo website Demoblaze thông qua GitHub Copilot Agent

16 Tháng 6, 2025
MCP server 2025 tốt nhất : Hướng dẫn chọn & bảo mật

MCP server 2025 tốt nhất : Hướng dẫn chọn & bảo mật

16 Tháng 6, 2025
DevOpsify Check Tool hỗ trợ MCP – Tự động hóa kiểm tra qua AI Claude & VS Code

DevOpsify Check Tool hỗ trợ MCP – Tự động hóa kiểm tra qua AI Claude & VS Code

13 Tháng 6, 2025
GitHub Action DevOpsify Check Tool – Tự động kiểm tra bảo mật & hiệu suất

GitHub Action DevOpsify Check Tool – Tự động kiểm tra bảo mật & hiệu suất

11 Tháng 6, 2025
DevOpsify

Cộng đồng DevOps Việt Nam chia sẽ kiến thức giúp tăng tốc quá trình phát triển ứng dụng và tự động hóa trong lĩnh vực Cloud DevOps & AI.

Bài viết mới

  • Sử dụng VS Code và Playwright MCP tự động test demo website Demoblaze thông qua GitHub Copilot Agent
  • MCP server 2025 tốt nhất : Hướng dẫn chọn & bảo mật
  • DevOpsify Check Tool hỗ trợ MCP – Tự động hóa kiểm tra qua AI Claude & VS Code

Categories

  • AI & Automation
  • Bảo mật
  • Chưa phân loại
  • DevOps & Cloud
  • Tin tức
No Result
View All Result
  • Home
  • Bảo mật
  • AI & Automation
  • DevOps & Cloud
  • Bộ đề luyện thi cloud

© 2025 DevOpsify