首頁>技術>

簡介

node_exporter是在*NIX類系統上,提供到匯出系統指標的服務。

部署

可以執行下面的命令下載並執行,進行測試。

VERSION="1.0.1"wget  -t 100  -c  https://github.com/prometheus/node_exporter/releases/download/v${VERSION}/node_exporter-${VERSION}.linux-amd64.tar.gztar zxvf node_exporter-${VERSION}.linux-amd64.tar.gzcd node_exporter-${VERSION}.linux-amd64./node_expoter

可以直接執行下面的指令碼進行安裝,適合systemd服務管理的Linux系統,安裝程系統的服務,並設定了開機啟動

#!/bin/bashVERSION="1.0.1"wget  -t 100  -c  https://github.com/prometheus/node_exporter/releases/download/v${VERSION}/node_exporter-${VERSION}.linux-amd64.tar.gzif [ ! -e prometheus-${VERSION}.linux-amd64.tar.gz ]then    echo "安裝包下載失敗"    exit 1fitar xvfz node_exporter-${VERSION}.linux-amd64.tar.gz -C /opt/cd /optln -s node_exporter-${VERSION}.linux-amd64  node_exportercat > /etc/systemd/system/node_exporter.service <<EOF[Unit]Description=node_exporterAfter=network.target[Service]Type=simpleWorkingDirectory=/opt/node_exporterExecStart=/opt/node_exporter/node_exporterLimitNOFILE=65536PrivateTmp=trueRestartSec=2StartLimitInterval=0Restart=always[Install]WantedBy=multi-user.targetEOF
docker部署

如果有docker環境的主機可以直接透過映象部署

docker run -d \  --net="host" \  --pid="host" \  -v "/:/host:ro,rslave" \  quay.io/prometheus/node-exporter:latest \  --path.rootfs=/host
檢視指標

預設是使用http協議,直接使用curl就可以獲取到指標資料:

curl http://localhost:9100/metrics
prometheus配置

配置prometheus job 進行指標收集;如果是比較固定的資產,我們可以使用靜態配置即可。

# my global configglobal:  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 configurationalerting:  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_exporter'    static_configs:    # 這裡配置的就是node_exporter的地址    - targets: ['localhost:9100', "192.168.142.53:9100","192.168.10.6:9100"]

配置好以後,reload一下prometheus就可以載入

kill -HUP [promethues_pid]
指標展示

指標可以透過prometheus的WebUI進行檢視

http://[promethe server ip]:9090

如果需要畫圖,可以直接使用grafana,有人已經配置好了圖形可以透過grafana官方下的dashboard找到,配置好prometheus資料來源,直接匯入grafana就可以直接展示了。

19
最新評論
  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • List集合轉JSONObject