Tags are not valid for functions in InfluxQL. There is no way to pass
"hosts" to COUNT(). You will not be able to graph a count of hosts in
Grafana without post-processing of the data.

On Wed, Sep 28, 2016 at 9:48 AM, Paul Letskii <[email protected]> wrote:

> Thank you all for advices.
>
> I think, I have to give more details about my situation.
>
> InfluxDB 1.0; Telegraf 1.0
>
> I have Telegraf collecting metrics from a servers and pulling it into
> InfluxDB. I use this InfluxDB as datasource for Grafana.
> Mem is a standard measurement. It has "hosts" in tags.
>
>
> What I want: I want to count hosts. So, if it was ordinary SQL, I can do
> something like SELECT COUNT("hosts") FROM mem.
>
> SHOW TAG VALUES FROM mem WITH KEY = "host" do the trick, but I need to get
> it in Grafana. And there is no SHOW, only SELECT.
>
>
>
> On Wednesday, September 28, 2016 at 6:15:37 PM UTC+3, Sean Beckett wrote:
>>
>> Do you have a field key named "value"? I was giving examples, but without
>> access to your schema I can't give actual queries. However, the SHOW TAG
>> VALUES FROM mem_usage_percent WITH KEY = "host" query gives you what you
>> want. Did you try that?
>>
>> On Wed, Sep 28, 2016 at 5:35 AM, Paul Letskii <[email protected]> wrote:
>>
>>> I'm still getting empty result:
>>>
>>> SELECT "host", "value" FROM mem WHERE time < now() - 2m
>>>
>>> Success! (no results to display)
>>>
>>> My goal is to count number of hosts and get this number into Grafana.
>>>
>>>
>>>
>>> On Tuesday, September 27, 2016 at 6:41:30 PM UTC+3, Sean Beckett wrote:
>>>>
>>>> That is because "host" is a tag
>>>> <https://docs.influxdata.com/influxdb/v1.0/concepts/glossary/#tag>,
>>>> not a field
>>>> <https://docs.influxdata.com/influxdb/v1.0/concepts/glossary/#field>.
>>>> SELECT statements must include at least one field.
>>>>
>>>> If you want only the values of "host", that's a SHOW
>>>> <https://docs.influxdata.com/influxdb/v1.0/query_language/schema_exploration/#explore-tag-values-with-show-tag-values>
>>>> query, not a SELECT
>>>> <https://docs.influxdata.com/influxdb/v1.0/query_language/data_exploration/#the-select-statement-and-the-where-clause>
>>>> query:
>>>>
>>>> SHOW TAG VALUES FROM mem_usage_percent WITH KEY = "host"
>>>>
>>>> Note that the SHOW query does not accept a "WHERE time" clause. To get
>>>> hosts during a particular time, use a SELECT query with a field as well:
>>>>
>>>> SELECT "host", "value" FROM mem_usage_percent WHERE time > ...
>>>>
>>>>
>>>>
>>>> On Tue, Sep 27, 2016 at 12:04 AM, Paul Letskii <[email protected]>
>>>> wrote:
>>>>
>>>>> Ok. But how have I change this query: "SELECT "host" FROM
>>>>> "mem_usage_percent"" to get just hosts field?
>>>>> According to documentation it is correct query (
>>>>> https://docs.influxdata.com/influxdb/v1.0/query_language/da
>>>>> ta_exploration/#the-select-statement-and-the-where-clause)
>>>>>
>>>>>
>>>>> On Monday, September 26, 2016 at 6:00:06 PM UTC+3, Sean Beckett wrote:
>>>>>>
>>>>>> Every SELECT statement must have at least one field. You selecting
>>>>>> only a tag. Use either "SHOW TAG VALUES" or include a field in the query.
>>>>>>
>>>>>> On Mon, Sep 26, 2016 at 6:55 AM, Paul Letskii <[email protected]>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi all!
>>>>>>>
>>>>>>> InfluxDB version 1.0\
>>>>>>>
>>>>>>> I'm trying to get list of hosts from measurement
>>>>>>> "mem_usage_percent".
>>>>>>>
>>>>>>> This query works:
>>>>>>> SELECT * FROM "mem_usage_percent"
>>>>>>>
>>>>>>> This one doesn't:
>>>>>>> SELECT "host" FROM "mem_usage_percent"
>>>>>>> Accordingly to documentation it has to.
>>>>>>>
>>>>>>> My final goal is to count number of unique hosts. Like: SELECT
>>>>>>> count("host") FROM "mem_usage_percent"
>>>>>>>
>>>>>>> What is correct syntax to get information from certain field?
>>>>>>>
>>>>>>> Thank you in advance!
>>>>>>>
>>>>>>> Best regards,
>>>>>>> Paul Letskii
>>>>>>>
>>>>>>> --
>>>>>>> Remember to include the InfluxDB version number with all issue
>>>>>>> reports
>>>>>>> ---
>>>>>>> You received this message because you are subscribed to the Google
>>>>>>> Groups "InfluxDB" 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/f3c71013-7e8c-4fd
>>>>>>> b-9808-0b1fb35e9052%40googlegroups.com
>>>>>>> <https://groups.google.com/d/msgid/influxdb/f3c71013-7e8c-4fdb-9808-0b1fb35e9052%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Sean Beckett
>>>>>> Director of Support and Professional Services
>>>>>> InfluxDB
>>>>>>
>>>>> --
>>>>> Remember to include the InfluxDB version number with all issue reports
>>>>> ---
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "InfluxDB" 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/215c75a2-3837-4c6
>>>>> 0-b5bd-14bb26f74fbe%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/influxdb/215c75a2-3837-4c60-b5bd-14bb26f74fbe%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>>
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Sean Beckett
>>>> Director of Support and Professional Services
>>>> InfluxDB
>>>>
>>> --
>>> Remember to include the InfluxDB version number with all issue reports
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "InfluxDB" 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/ms
>>> gid/influxdb/38bc648d-1930-47ee-bef9-62112bba5a00%40googlegroups.com
>>> <https://groups.google.com/d/msgid/influxdb/38bc648d-1930-47ee-bef9-62112bba5a00%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Sean Beckett
>> Director of Support and Professional Services
>> InfluxDB
>>
> --
> Remember to include the InfluxDB version number with all issue reports
> ---
> You received this message because you are subscribed to the Google Groups
> "InfluxDB" 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/f5a8354f-745e-48eb-9322-852ee6d7cbc3%40googlegroups.com
> <https://groups.google.com/d/msgid/influxdb/f5a8354f-745e-48eb-9322-852ee6d7cbc3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Sean Beckett
Director of Support and Professional Services
InfluxDB

-- 
Remember to include the InfluxDB version number with all issue reports
--- 
You received this message because you are subscribed to the Google Groups 
"InfluxDB" 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/CALGqCvMo9oGQS45bSUy9AXf85JEKsxydF12q%3DsTU%3DoVb0wGK%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to