自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

CentOS7搭建Prometheus 監(jiān)控Linux主機

系統(tǒng) Linux
prometheus可以拆分成多個節(jié)點進行指標收集。本文主要介紹CentOS7搭建Prometheus 監(jiān)控Linux主機。

 簡介

prometheus可以拆分成多個節(jié)點進行指標收集。

安裝環(huán)境:CentOS7

[[374562]]

安裝prometheus

  1. wget -c https://github.com/prometheus/prometheus/releases/download/v2.23.0/prometheus-2.23.0.linux-amd64.tar.gz 
  2. tar zxvf prometheus-2.23.0.linux-amd64.tar.gz  -C /opt/ 
  3. cd /opt/ 
  4. ln -s prometheus-2.23.0.linux-amd64 prometheus 
  5. cat > /etc/systemd/system/prometheus.service <<EOF 
  6. [Unit] 
  7. Description=prometheus 
  8. After=network.target 
  9.  
  10. [Service] 
  11. Type=simple 
  12. WorkingDirectory=/opt/prometheus 
  13. ExecStart=/opt/prometheus/prometheus --config.file="/opt/prometheus/prometheus.yml" 
  14. LimitNOFILE=65536 
  15. PrivateTmp=true 
  16. RestartSec=2 
  17. StartLimitInterval=0 
  18. Restart=always 
  19.  
  20. [Install] 
  21. WantedBy=multi-user.target 
  22. EOF 
  23. systemctl daemon-reload  
  24. systemctl enable prometheus 
  25. systemctl start prometheus 

 [[374563]]

配置Prometheus

這里配置的是監(jiān)聽/opt/prometheus/servers/目錄下的json文件

  1. cat > /opt/prometheus/prometheus.yml <<EOF 
  2. # my global config 
  3. global
  4.   scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute
  5.   evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute
  6.   # scrape_timeout is set to the global default (10s). 
  7. # Alertmanager configuration 
  8. alerting: 
  9.   alertmanagers: 
  10.   - static_configs: 
  11.     - targets: 
  12.       # - alertmanager:9093 
  13.  
  14. Load rules once and periodically evaluate them according to the global 'evaluation_interval'
  15. rule_files: 
  16.   # - "first_rules.yml" 
  17.   # - "second_rules.yml" 
  18.  
  19. # A scrape configuration containing exactly one endpoint to scrape: 
  20. # Here it's Prometheus itself. 
  21. scrape_configs: 
  22.   # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. 
  23.   - job_name: 'prometheus' 
  24.  
  25.     # metrics_path defaults to '/metrics' 
  26.     # scheme defaults to 'http'
  27.  
  28.     static_configs: 
  29.     - targets: ['localhost:9090'
  30.      
  31.   - job_name: 'servers' 
  32.     file_sd_configs: 
  33.     - refresh_interval: 61s 
  34.       files: 
  35.         - /opt/prometheus/servers/*.json 
  36. EOF 
  37. systemctl restart prometheus 

 json格式

[[374564]]

每個json文件需要是一個數組對象,如果不需要自定義標簽,可以直接寫到targets里面去也可以,可以有多個文件

  1. [     
  2.     { 
  3.         "targets": [ 
  4.             "192.168.1.164:9100" 
  5.         ], 
  6.         "labels": { 
  7.             "instance""192.168.1.164"
  8.             "job""node_exporter" 
  9.         } 
  10.     }, 
  11.     { 
  12.         "targets": [ 
  13.             "192.168.1.167:9100" 
  14.         ], 
  15.         "labels": { 
  16.             "instance""192.168.1.167"
  17.             "job""node_exporter" 
  18.         } 
  19.     } 

 安裝node_exporter

安裝到/opt/node_exporter路徑下,保持默認的端口

  1. https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz 
  2. tar zxvf node_exporter-1.0.1.linux-amd64.tar.gz -C /opt/ 
  3. cd /opt/ 
  4. ln -s  node_exporter-1.0.1.linux-amd64 node_exporter 
  5. cat > /etc/systemd/system/node_exporter.service <<EOF 
  6. [Unit] 
  7. Description=node_exporter 
  8. After=network.target 
  9.  
  10. [Service] 
  11. Type=simple 
  12. WorkingDirectory=/opt/node_exporter 
  13. ExecStart=/opt/node_exporter/node_exporter 
  14. LimitNOFILE=65536 
  15. PrivateTmp=true 
  16. RestartSec=2 
  17. StartLimitInterval=0 
  18. Restart=always 
  19.  
  20. [Install] 
  21. WantedBy=multi-user.target 
  22. EOF 
  23. systemctl daemon-reload 
  24. systemctl enable node_exporter 
  25. systemctl start node_exporter 

 圖形展示

直接安裝grafana進行展示

  1. yum -y install   https://dl.grafana.com/oss/release/grafana-7.3.6-1.x86_64.rpm 
  2. systemctl enable grafana-server 
  3. systemctl start grafana-server 

 啟動之后,grafana默認監(jiān)聽的是3000端口,直接使用瀏覽器進行訪問就可以了,默認用戶名密碼是admin/admin,第一次登陸之后會提示修改。


配置數據源:鼠標左邊的菜單 Configuration -> Data Source -> Add data source -> 選擇prometheus -> url那欄填入prometheus的地址就可以了 -> 最后 Save & test 就可以了。

grafana.com/grafana/dashboards 官網已經有人做好的模板,我們直接import進來就可以了。

導入面板:鼠標左邊的菜單 Dashboards -> Import -> 填入id -> Load -> 選擇數據源就可以了。

我經常用的是:1860 、8919 這兩個來查看node_exporter監(jiān)控


總結

安裝這些服務都是使用systemd進行管理的,操作起來比較方便的。

這里沒有設置告警,可以根據自己的需要設置對應的告警規(guī)則,使用alertmanager進行告警。

 

責任編輯:姜華 來源: 今日頭條
相關推薦

2020-11-20 08:15:40

Grafana + P

2020-07-16 08:37:39

NginxCentOS7搭建

2019-06-27 10:17:40

Centos7Pinpoint監(jiān)控

2011-03-24 11:03:05

Nagios監(jiān)控Linux

2020-11-06 08:05:05

CentOS

2014-09-28 10:37:45

LinuxNagiosNRPE

2023-12-27 08:47:41

PrometheusLinux架構

2021-05-12 07:42:41

CentOS7Python3系統(tǒng)

2020-08-28 11:20:01

CentOS7RocketMQ 4.運維

2014-10-09 10:04:23

CentOS集群

2017-02-27 11:06:59

RHEL7CentOS7密碼

2010-06-01 10:32:04

linux Mrtg

2018-05-04 09:32:32

Linux快速監(jiān)控rwho

2021-10-26 08:08:34

Node ExporLinux 監(jiān)控

2023-10-09 08:12:00

2021-10-25 07:57:45

Node ExportLinux 監(jiān)控

2023-02-26 12:03:26

2021-04-12 07:41:57

Centos7系統(tǒng)分布式集群

2022-05-18 08:32:05

服務監(jiān)控Prometheus開源

2020-12-30 08:09:46

運維Prometheus 監(jiān)控
點贊
收藏

51CTO技術棧公眾號