使用InfluxQL计算区间内具有相同值的点(行)?

时间:2016-12-04 16:05:09

标签: influxdb

我正在尝试利用我对InfluxQL的适度SQL知识,但我遗漏了一些关于时间序列db的性质的东西。

用例

当问题更新时,我会从问题跟踪器中编写测量值:

<script> export default { props: ['plans'], data() { return{ stripeEmail: '', stripeToken: '', plan: 3, status: false }; }, created(){ this.stripe = StripeCheckout.configure({ key: admin.stripeKey, image: "https://stripe.com/img/documentation/checkout/marketplace.png", locale: "auto", panelLabel: "Subscribe for: ", email: admin.user.email, //here you are using function(token) within it the `this` will not reference the Vue instance, hence this.$http is undefined. //token: function(token){ //so change it to use the ES2015 arrow syntax token:(token) => { this.stripeEmail = token.email; this.stripeToken = token.id; //this.$el.submit(); this.$http.post('payments/checkout', this.$data) .then( response => alert('Thank you for your purchase!.'), response => this.status = response.body.status ); } }); }, methods: { buy(){ let plan = this.findPlanById(this.plan); this.stripe.open({ name: plan.name, description: plan.description, zipCode: true, amount: plan.price }); }, findPlanById(id){ return this.plans.find(plan => plan.id == id); } } };

问题

鉴于这会返回问题状态行:

issue_updated,project=facebook,ticket=fb1,assignee=coolman status="todo"

如果这是SQL(fiddle),我会使用SELECT status FROM "issue_updated" (然后添加COUNT)。但是,以下内容为我提供了不支持混合聚合和非聚合查询

WHERE time > NOW() - 1Y GROUP BY time(5m)

有人可以在这里提供一些指导吗? TA

1 个答案:

答案 0 :(得分:1)

您正在寻找的是能够根据当前不支持的字段值进行分组。

据我所知,如果你稍微修改你的架构,应该可以做你正在寻找的东西。而不是

issue_updated,project=facebook,ticket=fb1,assignee=coolman status="todo"

待办事项

issue_updated,project=facebook,ticket=fb1,assignee=coolman,status=todo value=1

然后

SELECT count(value) FROM "issue_updated" WHERE time > now() - 52w GROUP BY status
name: issue_updated
tags: status=other
time            count
----            -----
1449523659065350722 1

name: issue_updated
tags: status=todo
time            count
----            -----
1449523659065350722 2

应该有用。