prometheus之SQL監控cpu,內存,硬盤使用率,網卡速率

監控服務器CPU、內存、磁盤、I/O等信息,首先需要安裝node_exporter。node_exporter的作用是用於機器系統數據收集。

cpu使用率:

100 - (avg(irate(node_cpu_seconds_total{mode="idle"}[5m]))by (instance) * 100)

內存使用率:

100 - (node_memory_MemFree_bytes+node_memory_Cached_bytes+node_memory_Buffers_bytes) / node_memory_MemTotal_bytes * 100

磁盤使用率:

100 - node_filesystem_free_bytes{fstype=~"ext4|xfs"} / node_filesystem_size_bytes{fstype=~"ext4|xfs"} * 100

#網卡速率 單位是kb, 大於10M

(irate(node_network_transmit_bytes_total{device!~"lo"}[5m]) / 1000) >10*1024

1、cpu使用率

100 - (avg(irate(node_cpu_seconds_total{mode="idle"}[5m]))by (instance) * 100)


prometheus之SQL監控cpu,內存,硬盤使用率,網卡速率


2、內存使用率

100 - (node_memory_MemFree_bytes+node_memory_Cached_bytes+node_memory_Buffers_bytes) / node_memory_MemTotal_bytes * 100


prometheus之SQL監控cpu,內存,硬盤使用率,網卡速率


3、磁盤使用率

100 - node_filesystem_free_bytes{mountpoint="/",fstype=~"ext4|xfs"} / node_filesystem_size_bytes{mountpoint="/",fstype=~"ext4|xfs"} * 100


prometheus之SQL監控cpu,內存,硬盤使用率,網卡速率


4、網卡速率

irate(node_network_transmit_bytes_total{device!~"lo"}[5m]) / 1000 出去流量


prometheus之SQL監控cpu,內存,硬盤使用率,網卡速率


irate(node_network_receive_bytes_total{device!~"lo"}[5m]) / 1000 進入流量


prometheus之SQL監控cpu,內存,硬盤使用率,網卡速率


分享到:


相關文章: