跨测量的InfluxDB数学 [英] InfluxDB mathematics across measurements

查看:63
本文介绍了跨测量的InfluxDB数学的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的InfluxDB中有两个度量值,分别是 mem_used mem_ available .
我尝试查询这些度量值,并使用

I have two measurements in my InfluxDB, say, mem_used and mem_ available.
I tried to query across those measurements and do a mathematics with

SELECT mean("mem_used_value") / mean("mem_available_value") FROM 
    (
     SELECT mean("value") AS "mem_used_value", 
            mean("value") AS "mem_available_value"
     FROM "dbname"."autogen"."mem_used",
          "dbname"."autogen"."mem_available"
     GROUP BY time(1m)
    )
GROUP BY time(1m)

查询的结果非常奇怪,我想知道InfluxDB是否有可能在所有测量中执行​​数学运算.

The result of the query is very weird, and I was wondering if it’s possible for InfluxDB to perform a mathematics across measurements.

我对此功能进行了一些研究,发现问题 3552跨测量的数学仍在打开.但是,这是三年前提出的要求.

I have did some research about this feature and found the issue 3552 Mathematics across measurements is still opening. However, it was requested three years ago.

有没有办法做到这一点?任何建议都欢迎.

Is there any approach to do this? any advice is welcome.

推荐答案

Influx QL中没有JOIN.

There's no JOINs in Influx QL.

请记住:这不是关系数据库,查询语言可能看起来很熟悉,但这是完全不同的事情.

Remember pls: that's NOT a relational DB, the query language may look familiar, but it is a totally different thing.

这就是您可以做的.

1)最聪明的&最合法的方法:正确调整尺寸.

1) The smartest & legit-iest way: shape your measurement properly.

当前您没有:应该不进行两次测量,而是进行一次测量,例如(在

Currently you didn't: there should not be two measurements, but one, like (in line protocol notation)

memusage,host=yourhost,othertag=something,yetanotertag=anything mem_used=123,mem_available=321 yourtimestamp

2)使用 Kapacitor 加入您的一共测量.

2) Use Kapacitor to join your measurements altogether.

在那里,您可以直接在Kapacitor中进行数学运算,也可以简单地将联接的结果写回到单个度量中,然后在纯InfluxQL中进行汇总.

There, you can do math right in Kapacitor, or simply write the result of the join back into a single measurement and later do your aggregations in plain InfluxQL.

这篇关于跨测量的InfluxDB数学的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆