我目前正在使用(滥用?)Postgres存储时间序列数据,并且鉴于现在正在使用的数据量,我需要迁移到支持连续查询和保留策略的真实时间序列数据库.我正在查看InfluxDB,唯一让我退缩的是定义自定义聚合的能力.我目前在Postgres中定义了一个自定义聚合,该聚合根据一个表中的数据计算加权平均值,权重由其中一列中的值确定.例如,我有一个 score 列,其值在1到9之间.在计算加权平均分数时,如果分数在4到6之间,则将分数乘以10;如果在4到6之间,则将其乘以1000.在计算平均值之前是7和9.
I'm currently using (abusing?) Postgres to store time-series data, and given the amount of data now being consumed I'm needing to migrate over to a true time-series database that supports continuous queries and retention policies. I'm looking at InfluxDB, and the only thing holding me back is the ability to define custom aggregates. I currently have a custom aggregate defined in Postgres that calculates a weighted average for data in a table based, with weights being determined by the value in one of the columns. For example, I have a score column with values between 1 and 9. When calculating the weighted average score, I multiply the score by 10 if it's between 4 and 6, and multiply it by 1,000 if it's between 7 and 9 before calculating the average.
是否可以在InfluxDB中做类似的事情?
Is it possible to do something similar in InfluxDB?
推荐答案目前,InfluxDB不允许在InfluxQL中使用用户定义的功能.
At the moment InfluxDB doesn't allow for user defined functions within InfluxQL.
您可以同时使用InfluxDB和 Kapacitor 来实现您要执行的操作.特别是,您将使用Kapacitor中的用户定义的功能节点进行定义加权平均UDF,然后将UDF的结果写回到InfluxDB.
You could use both InfluxDB and Kapacitor together to achieve what you're trying to do. Particularly you'd use the User Defined Function Node in Kapacitor to define a weighted average UDF and then write the results of the UDF back into InfluxDB.
更多推荐
是否可以在InfluxDB中定义自定义聚合?
发布评论