0

我试图memcached在 influxdb + grafana 中绘制数据,我发现ps_cputimemicrosecond.

我如何将它转换为易于理解的人类可读格式。

涌入数据库:

> select * from memcached_syst limit 10;
name: memcached_syst
time                host                                         type       value
----                ----                                         ----       -----
1549595956627272659 ostack-infra-01_memcached_container-167ecaa7 ps_cputime 15853819249
1549596016550515653 ostack-infra-01_memcached_container-167ecaa7 ps_cputime 15853923573
1549596076550356985 ostack-infra-01_memcached_container-167ecaa7 ps_cputime 15854047878
1549596136550415911 ostack-infra-01_memcached_container-167ecaa7 ps_cputime 15854165969
1549596196550481720 ostack-infra-01_memcached_container-167ecaa7 ps_cputime 15854288341
1549596256550522792 ostack-infra-01_memcached_container-167ecaa7 ps_cputime 15854387422

格拉法纳查询:

SELECT mean("value") FROM "memcached_syst"  WHERE ("host" =~ /^$host$/ AND "type"='ps_cputime' ) AND $timeFilter GROUP BY time($interval) fill(null)

我能在这里做些什么来使它在parcent?

4

2 回答 2

0

您需要使用NON_NEGATIVE_DERIVATIVE,结果将以百分比表示:

SELECT NON_NEGATIVE_DERIVATIVE("value", 1s) / 1000
FROM "memcached_syst"
WHERE ("host" =~ /^$host$/ AND "type"='ps_cputime' ) AND $timeFilter
GROUP BY time($interval) fill(null)

此查询可能需要一些调整,例如按核心数量进行标准化。

于 2019-02-09T08:53:49.140 回答
0

您可以将微秒转换为小时并显示结果。转换为小时的公式 - 微秒 / 3600000000

  Select (column_name/3600000000)      as time_in_hrs from table_name;
于 2019-02-09T09:09:24.917 回答