Prometheus主机相关指标表达式整理

问题描述

需要通过Prometheus采集监控的主机节点的cpu使用率、内存使用率、磁盘使用率等指标数据,并根据topk排序筛选出前topN的主机。对过程进行一下记录。

表达式

    //磁盘读速率top10
    private final static String TOP10_DISK_READ = "topk(10,sum(irate(node_disk_reads_completed_total{}[5m])) by(instance_addr))";
    //磁盘写速率top10
    private final static String TOP10_DISK_WRITE = "topk(10,sum(irate(node_disk_writes_completed_total{}[5m])) by(instance_addr))";
    //网络流入速率top10
    private final static String TOP10_NET_RECEIVE = "topk(10,sum(irate(node_network_receive_bytes_total{}[5m])) by(instance_addr))";
    //网络流出速率top10
    private final static String TOP10_NET_TRANSMIT = "topk(10,sum(irate(node_network_transmit_bytes_total{}[5m])) by(instance_addr))";
    //cpu使用率top10
    private final static String TOP10_LINUX_CPU_RATE = "topk(10,avg((1-irate(node_cpu_seconds_total{mode='idle'}[5m])) * 100) by(instance_addr))";
    //内存使用率top10
    private final static String TOP10_LINUX_MEMORY_RATE = "topk(10, avg((1 - node_memory_MemAvailable_bytes{}/node_memory_MemTotal_bytes{})* 100) by(instance_addr))";
    //磁盘使用率top10
    private final static String TOP10_LINUX_DISK_RATE = "topk(10, (1- (sum(node_filesystem_free_bytes{})by(instance_addr))/(sum(node_filesystem_size_bytes{})by(instance_addr))) * 100)";


    //磁盘读速率
    private final static String DISK_READ = "sum(irate(node_disk_reads_completed_total{instance_addr='$instance_addr'}[5m]))";
    //磁盘写速率
    private final static String DISK_WRITE = "sum(irate(node_disk_writes_completed_total{instance_addr='$instance_addr'}[5m]))";
    //网络流入速率
    private final static String NET_RECEIVE = "sum(irate(node_network_receive_bytes_total{instance_addr='$instance_addr'}[5m]))";
    //网络流出速率
    private final static String NET_TRANSMIT = "sum(irate(node_network_transmit_bytes_total{instance_addr='$instance_addr'}[5m]))";
    //CPU使用率
    private final static String LINUX_CPU_RATE = "avg((1-irate(node_cpu_seconds_total{mode='idle',instance_addr='$instance_addr'}[5m])) * 100)";
    //内存使用率
    private final static String LINUX_MEMORY_RATE = "avg((1 - node_memory_MemAvailable_bytes{instance_addr='$instance_addr'}/node_memory_MemTotal_bytes{instance_addr='$instance_addr'})* 100)";
    //磁盘使用率
    private final static String LINUX_DISK_RATE = "(1- (sum(node_filesystem_free_bytes{instance_addr='$instance_addr'}))/(sum(node_filesystem_size_bytes{instance_addr='$instance_addr'}))) * 100";

你可能感兴趣的:(prometheus,监控运维,prometheus,服务器,网络)