在 influxDb 中用不同的 where 子句减去两个计数值

Subtract two count values with different where clause in influxDb

我在 influxDb 中使用两个键进行测量:operationcountoperation 键可以存储两个不同的值:'add' 和 'delete'。

我想将 operation='delete' 时的 sum(count) 值减去 operation='add' 时的 sum(count) 值。

mysql 支持以下查询,但它在 influxql 中抛出错误:

select (select sum(count) from measurement where operation='add') - (select sum(count) from measurement where operation='delete');

如何使用单个 influxql 查询完成此操作?我不认为 influxql 在这种情况下允许两个不同的 where 子句。

InfluxQL 不支持这种多查询数学。您需要在应用程序级别对其进行计算。