You can use the count function paired with a GROUP BY time. For example:

SELECT count("f_status") from jobstatus where time > now() - 1h group by
time(10m)

Would give you 6 data points with counts for 10 minute buckets in the last
hour. Or

SELECT count("f_status") from jobstatus where time > now() - 1h

Would give you the count for the last hour. If you want to see on a per
host basis, add host to your group by clause. i.e. GROUP BY host, time(10m)

On Fri, Dec 23, 2016 at 9:51 AM, Rodrigo Pereira <
[email protected]> wrote:

> Hi everybody,
>
> Rather new to Influxdb here, and trying to create some visualizations on
> top of it.
>
> Got a bit stuck trying to create a query to get a specific count. I have a
> custom service constantly pushing a measurement jobstatus with host, job,
> and status. More or less every 5 mins Influx receives that metric for each
> (host, job) pair. While I am able to create a table that shows for example
> all the host/job pairs where status is -1 (but, very important, showing
> only the last status received for each host/job) I'm not being able to
> create a query that just counts them, so I can display it on a single stat
> panel.  Any hints?
>
> I'm using this to display a table in Grafana with the list of host/service
> :
>
> SELECT last("f_status") as "Current Status", "f_old_status" as "Previous
> Status" FROM "autogen"."jobstatus" WHERE "t_status" = '-1' GROUP BY t_host,
> t_job
>
> Any help appreciated.
>
> rgds.
>
> --
> Remember to include the version number!
> ---
> You received this message because you are subscribed to the Google Groups
> "InfluxData" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/influxdb.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/influxdb/a88d379d-ed65-4a03-a578-937fd9b04e52%40googlegroups.com
> <https://groups.google.com/d/msgid/influxdb/a88d379d-ed65-4a03-a578-937fd9b04e52%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Remember to include the version number!
--- 
You received this message because you are subscribed to the Google Groups 
"InfluxData" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/influxdb/CAHRno_yWxJxvvaW46u73%3DDKa_ORJkeAkT_wGNgRSj0Fx%3D3ijcg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to