使用Prometheus監控Linux系統各項指標

i042416發表於2019-11-25

首先在Linux系統上安裝一個探測器node explorer, 下載地址 https://prometheus.io/docs/guides/node-exporter/

這個探測器會定期將linux系統的各項硬體指標和核心引數通過9100埠和url metrics暴露給外部。

使用Prometheus監控Linux系統各項指標

啟動node explorer,顯示在9100埠上監聽:

使用Prometheus監控Linux系統各項指標

瀏覽器裡輸入hostname:9100/metrics就可以訪問到node explorer收集到的各項引數:

使用Prometheus監控Linux系統各項指標

一些例子:

CPU在不同工作模式下的使用時間:node_cpu_seconds_total

使用Prometheus監控Linux系統各項指標

檔案系統可用位元組數:node_filesystem_avail_bytes

使用Prometheus監控Linux系統各項指標

網路卡收到的位元組數:node_network_receive_bytes_total

使用Prometheus監控Linux系統各項指標

下面用Prometheus來收集和展示通過node explorer暴露出來的資料。

在Prometheus安裝目錄的prometheus.yml檔案裡定義一個job,指向Linux系統上執行的node explorer:

使用Prometheus監控Linux系統各項指標

本地啟動Prometheus,開啟下面的url:
http://localhost:9090/
輸入node_cpu_seconds_total{mode="system"},查詢該伺服器上所有CPU工作在系統態消耗的時間:

使用Prometheus監控Linux系統各項指標

還可以指定時間視窗,只查詢過去1分鐘之內的CPU執行資料:
rate(node_cpu_seconds_total{mode="system"}[1m])

使用Prometheus監控Linux系統各項指標

要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":


使用Prometheus監控Linux系統各項指標


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2665603/,如需轉載,請註明出處,否則將追究法律責任。

相關文章