参考文献
准备InfluxDB的相关查询语句
> SELECT * FROM "CPU_All3" WHERE time < now() - 5m and "Idle%" =~ /94.5/ and host =~ /qc_predepl_cms/
name: CPU_All3
time Cpus Idle% Steal% Sys% User% Wait% host
---- ---- ----- ------ ---- ----- ----- ----
1551689409000000000 4 94.5 0 0.9 0.7 3.9 qc_predepl_cms-ngx-02
>
> SELECT * FROM "CPU_All3" WHERE host =~ /qc_predepl_cms/ limit 10
name: CPU_All3
time Cpus Idle% Steal% Sys% User% Wait% host
---- ---- ----- ------ ---- ----- ----- ----
1551689409000000000 4 94.5 0 0.9 0.7 3.9 qc_predepl_cms-ngx-02
1551689412000000000 4 99.8 0 0.2 0.1 0 qc_predepl_cms-ngx-02
1551689415000000000 4 99.5 0 0 0.1 0.4 qc_predepl_cms-ngx-02
1551689418000000000 4 99.4 0 0.1 0.1 0.4 qc_predepl_cms-ngx-02
1551689421000000000 4 99.7 0 0.2 0.2 0 qc_predepl_cms-ngx-02
1551689424000000000 4 99.7 0 0.1 0.1 0.2 qc_predepl_cms-ngx-02
1551689427000000000 4 99.5 0 0.2 0.2 0.2 qc_predepl_cms-ngx-02
1551689430000000000 4 99.7 0 0.2 0.2 0 qc_predepl_cms-ngx-02
1551689433000000000 4 99.7 0 0.1 0.2 0.1 qc_predepl_cms-ngx-02
1551689436000000000 4 99.8 0 0.1 0.1 0 qc_predepl_cms-ngx-02
>
下面就在Grafana执行SELECT * FROM "CPU_All3" WHERE host =~ /qc_predepl_cms/
查询出表里面的数据,并呈现在Grafana中。
配置Grafana的数据源
填写基本连接访问influxdb数据库的信息,点击下方的test
按钮,可以测试是否连接成功。
创建Table表
点击表格的Edit
按钮,就可以进入编辑页面,下面主要讲如何获取数据到图表呈现。
设置数据的查询语句,并图表呈现
设置好查询语句,因为我的数据是3月4号的,所以还要设置一下时间区间才可以查询出来,如下:
网友评论