我们正在使用kubernetes,它在Influxdb中收集数据。流入的值以grafana显示。
对于我们正在创建的新仪表板,我们使用grafana的查询并在node.js中实现它们。但是,节点中的查询返回的值是grafana中显示的值的2倍。
我们用来测试的查询是:
q=SELECT SUM(\"value\") FROM \"cpu/usage_rate\" WHERE time > now() - 5m
AND \"pod_namespace\" =~ /ournamespace/
AND \"pod_name\" =~ /ourSinglePod/ GROUP BY time(1m)
卷曲版本,便于复制:
curl -G http://10.144.1.5:8086/query?pretty=true --data-urlencode "db=k8s" --data-urlencode "q=SELECT SUM(\"value\") FROM \"cpu/usage_rate\" WHERE time > now() - 5m AND \"pod_namespace\" =~ /adserving/ AND \"pod_name\" =~ /ads-357196871-qek76/ GROUP BY time(1m)"
结果:
{
"results": [
{
"series": [
{
"name": "cpu/usage_rate",
"columns": [
"time",
"sum"
],
"values": [
[
"2017-01-26T18:51:00Z",
null
],
[
"2017-01-26T18:52:00Z",
156
],
[
"2017-01-26T18:53:00Z",
162
],
[
"2017-01-26T18:54:00Z",
148
],
[
"2017-01-26T18:55:00Z",
156
],
[
"2017-01-26T18:56:00Z",
154
]
]
}
]
}
]
}
grafana中图表中显示的值是这些值的一半。