Ashley Coolman
Ashley Coolman

Reputation: 11585

Using InfluxQL to count points (rows) with same value within an interval?

I'm trying to leverage my moderate SQL-knowledge for InfluxQL, but I'm missing something(s) about the nature of timeseries db.

Use case

I write a measurements from our issue tracker, when an issue is updated:

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

Problem

Given this returns rows of issues statuses:

SELECT status 
FROM  "issue_updated" 

If this was SQL (fiddle) I would use COUNT(and then add the WHERE time > NOW() - 1Y GROUP BY time(5m)). However the following gives me Mixing aggregate and non-aggregate queries is not supported

SELECT status, count(status) as 'Count'
FROM "issue_updated" 

Can someone give some guidance here? ta

Upvotes: 1

Views: 1288

Answers (1)

Michael Desa
Michael Desa

Reputation: 4747

Sounds like what you're looking for is the ability to group by a field value which isn't currently supported.

From what I can tell, if you modify your schema a bit, it should be possible to do what you're looking. Instead of

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

Do

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

then

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

should work.

Upvotes: 1

Related Questions