从30天前开始在InfluxQL/InfluxDB中获得差异 [英] Get difference since 30 days ago in InfluxQL/InfluxDB

查看:170
本文介绍了从30天前开始在InfluxQL/InfluxDB中获得差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在grafana仪表板中有一个统计信息,显示磁盘的当前使用情况.要获取该信息,我使用以下查询:

I have a single stat in my grafana dashboard showing the current usage of a disk. To get that info I use the following query:

SELECT last("used") FROM "disk" WHERE "host" = 'server.mycompany.com' 
AND "path" = '/dev/sda1' AND $timeFilter

我想添加另一个统计信息,以显示过去30天使用量的增加/减少.为此,我假设我要获取最近的测量值和30天前的测量值并减去它们.

I want to add another stat showing the increase/decrease in usage over the last 30 days. I assume for this I want to get the last measurement and the measurement from 30 days ago and subtract them.

如何在InfluxQL中做到这一点?

How can I do this in InfluxQL?

推荐答案

它不会很完美,但是会产生一些效果

It wont be perfect, but something to the effect of

SELECT last("used") - first("used") FROM "disk" WHERE ... AND time > now() - 30d

应该足够了.

这篇关于从30天前开始在InfluxQL/InfluxDB中获得差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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