Cài prometheus

https://devopscube.com/install-configure-prometheus-linux/

Cài Node exporter

https://devopscube.com/monitor-linux-servers-prometheus-node-exporter/

Cài Grafana

https://devopscube.com/integrate-visualize-prometheus-grafana/

Lệnh start, stop, status

Chỉnh sửa cấu hình file prometheus
vi /etc/prometheus/prometheus.yml

Sau đó sử dụng lệnh dưới để khởi động lại
sudo systemctl stop prometheus
sudo systemctl start prometheus
sudo systemctl status prometheus
sudo systemctl enable prometheus

sudo systemctl start grafana-server
sudo systemctl enable grafana-server
sudo systemctl status grafana-server
sudo systemctl stop grafana-server

sudo systemctl start node_exporter
sudo systemctl stop node_exporter
sudo systemctl enable node_exporter
sudo systemctl status node_exporter

Tạo file Dockerfile để custom config premotheus

FROM prom/prometheus
ADD prometheus.yml /etc/prometheus/

Tạo file cấu hình của prometheus

# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:doc
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']

  - job_name: 'node'

    static_configs:
    - targets: ['localhost:9100']

Cài Prometheus với Docker, trỏ terminal tới folder chứa prometheus.yml

docker build -t prometheus .
docker run -tid -p 9090:9090 --name prometheus prometheus

Cài grafana

docker run -d --name=grafana -p 9200:3000 grafana/grafana

sss

docker run -d -p 9100:9100 -v "/proc:/host/proc" -v "/sys:/host/sys" -v "/:/rootfs" --net="host" prom/node-exporter -collector.procfs /host/proc -collector.sysfs /host/proc -collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"

results matching ""

    No results matching ""