You're most likely seeing <nil> values there because Telegraf is not
sending the uptime field with every point to the 'system' measurement.
There are a couple of different ways to handle this issue:

* You can use a `|default()
<https://docs.influxdata.com/kapacitor/v1.1/nodes/default_node/>` node to
default the value to something if it is not present. This won't quite work
with uptime, though, since there isn't a "default" value for a system's
uptime.

* You can convert your task to use batch
<https://docs.influxdata.com/kapacitor/v1.1/nodes/batch_node/> instead of
stream, which will be equivalent to running the query on the InfluxDB CLI.
This would make your task look more like this:

```
var data = batch
    |query('SELECT last("uptime") as last_uptime FROM system')
        .period(window)
        .every(every)
        .groupBy('host')
```

For this issue in particular I would recommend using a batch task.

On Mon, Jan 9, 2017 at 7:54 PM, <[email protected]> wrote:

> Hi Ross,
>
> Thanks for the reply.
> I do see the error in the `kapacitor show`, I must of missed it the first
> time! Here is the message :
> "Error: last3: invalid influxql func last with field uptime: invalid field
> type: <nil>"
>
> I don't get why that is <nil> ?
>
> The influxdb query "select last(uptime) from system" returns correctly.
> If I run "SHOW FIELD KEYS on systems", I see that the "uptime" field is an
> "integer"
>
> Thanks
>
> On Tuesday, January 10, 2017 at 4:20:29 AM UTC+8, Ross McDonald wrote:
>>
>> ​If the task stops executing, there should be an error stating why it was
>> stopped next to the `Error:` heading in the `kapacitor show` output.
>>
>> Can you share the output to the output of `kapacitor show` for your task?
>> Is there anything in the Kapacitor service logs for your task that look
>> like an error?
>>
>> On Mon, Jan 9, 2017 at 12:45 AM, <[email protected]> wrote:
>>
>>> Hi,
>>>
>>> I have the following :
>>> Kapacitor,  v1.1.1
>>> InfluxDB, v 1.1.1
>>> Telegraf, v1.1.2
>>>
>>>
>>> I am having a little bit of trouble with the |last() function. (Or maybe
>>> my understanding of it)
>>> My TICK script gets loaded into Kapacitor with out any error.
>>> After some time the "kapacitor show tasks" command lists the task as
>>> "Executing:false".
>>> I guess this is when the task has its first match on the incoming data
>>> stream.
>>>
>>> I have this in my TICK script :
>>> ----------------
>>> var window = 1m
>>> var every = 1m
>>>
>>> var data = stream
>>>     |from()
>>>         .measurement('system')
>>>         .groupBy('host')
>>>     |window()
>>>         .period(window)
>>>         .every(every)
>>>     |last('uptime')
>>>         .as('last_uptime')
>>> ----------------
>>>
>>> "system" is my measurement in InfluxDB.
>>> "host" is a tag value in InfluxDB.
>>> "uptime" is a field("integer") in InflxuDB.
>>>
>>> I use the following to mach :
>>> ----------------
>>> var crit = lambda: "last_uptime" < 300
>>> var critReset = lambda: "last_uptime" >= 300
>>> ----------------
>>>
>>> If I remove the "|Last()" function than the TICK scrip stays enabled,
>>> but gives the wrong outcome.
>>> IE; I get alerts for all points when "uptime" is from 0 to 300.
>>> I just want to match on the last value.
>>>
>>> Thanks for your help
>>> Brendan
>>>
>>> --
>>> 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/ms
>>> gid/influxdb/1f8c74ac-fa94-4286-9720-5b230d320722%40googlegroups.com
>>> <https://groups.google.com/d/msgid/influxdb/1f8c74ac-fa94-4286-9720-5b230d320722%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/3b91965c-6941-4711-917d-13ea6878e22e%40googlegroups.com
> <https://groups.google.com/d/msgid/influxdb/3b91965c-6941-4711-917d-13ea6878e22e%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/CAD8sRLDeLh3MhgF%3D%2BewkKZJNL4%3D2Uy%2Bkb83K5RS_qdGhru5zuA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to