Influxdb 查询五大cpu使用率

Influxdb 查询五大cpu使用率,influxdb,influxdb-python,Influxdb,Influxdb Python,我使用CloudLinux运行共享web主机。 从中,我可以得到一系列性能指标 因此,我的XDB是: 测量:左室射血分数 字段:CPU、EP、IO、IOPS、MEM、MEMPHY、NETI、NETO、NPROC、fEP、fMEM、fMEMPHY、fNPROC、lCPU、lCPUW、lEP、lIO、lIOPS、lMEM、lMEMPHY、lNETI、lNETO、lNPROC、nCPU 标记:xpool、host、user(其中:xpool是xen池uid,host是cloudLinux的主机名,us

我使用CloudLinux运行共享web主机。 从中,我可以得到一系列性能指标

因此,我的XDB是:

测量:左室射血分数

字段:CPU、EP、IO、IOPS、MEM、MEMPHY、NETI、NETO、NPROC、fEP、fMEM、fMEMPHY、fNPROC、lCPU、lCPUW、lEP、lIO、lIOPS、lMEM、lMEMPHY、lNETI、lNETO、lNPROC、nCPU

标记:xpool、host、user(其中:xpool是xen池uid,host是cloudLinux的主机名,user是共享主机的用户名)

每5秒收集一次数据

查询语句如何:

  • 从特定xpool+主机中选择记录,然后

  • 从it?中获取5个在5分钟内产生最高CPU使用率的唯一用户名?。 我们的名字有几百个,但我只想要前五名

  • 注意:与中的TOP()示例4类似,除非预期结果为:

    name: h2o_feet
    time                  top    location
    ----                  ---    --------
    2015-08-18T00:00:00Z  8.12   coyote_creek
    2015-08-18T00:54:00Z  2.054  santa_monica
    
    而不是:

    name: h2o_feet
    time                  top    location
    ----                  ---    --------
    2015-08-18T00:48:00Z  7.11   coyote_creek
    2015-08-18T00:54:00Z  6.982  coyote_creek
    2015-08-18T00:54:00Z  2.054  santa_monica
    2015-08-18T00:24:00Z  7.635  coyote_creek
    2015-08-18T00:30:00Z  7.5    coyote_creek
    2015-08-18T00:36:00Z  7.372  coyote_creek
    2015-08-18T00:00:00Z  8.12   coyote_creek
    2015-08-18T00:06:00Z  8.005  coyote_creek
    2015-08-18T00:12:00Z  7.887  coyote_creek
    
    因为“8.12”是“coyote_creek”的最高值,“2.054”是“santa_monica”的最高值

    诚恳


    -bino-

    子查询可能会有所帮助,例如,它来自使用telegraf的数据库:

    SELECT top,host FROM (SELECT TOP(usage_user, 1) AS top, host from cpu WHERE time > now() -1m GROUP BY host)
    
    它将输出如下内容:

    name: cpu
    time                top                 host
    ----                ---                 ----
    1527489800000000000 1.4937106918238994  1.host.tld
    1527489808000000000 0.3933910306845004  2.host.tld
    1527489810000000000 4.17981072555205    3.host.tld
    1527489810000000000 0.8654602675059009  4.host.tld
    
    第一个查询是:

    SELECT TOP(usage_user, 1) AS top, host from cpu WHERE time > now() -1m GROUP BY host
    
    正在使用
    TOP
    仅获取1项,并使用
    usage\u user

    然后使用子查询进行“漂亮打印”:

    SELECT top,host FROM (...)
    

    子查询可能会有所帮助,例如,它来自使用telegraf的数据库:

    SELECT top,host FROM (SELECT TOP(usage_user, 1) AS top, host from cpu WHERE time > now() -1m GROUP BY host)
    
    它将输出如下内容:

    name: cpu
    time                top                 host
    ----                ---                 ----
    1527489800000000000 1.4937106918238994  1.host.tld
    1527489808000000000 0.3933910306845004  2.host.tld
    1527489810000000000 4.17981072555205    3.host.tld
    1527489810000000000 0.8654602675059009  4.host.tld
    
    第一个查询是:

    SELECT TOP(usage_user, 1) AS top, host from cpu WHERE time > now() -1m GROUP BY host
    
    正在使用
    TOP
    仅获取1项,并使用
    usage\u user

    然后使用子查询进行“漂亮打印”:

    SELECT top,host FROM (...)