I can't make sense of the kapacitor record query syntax. The documentation 
only covers the HTTP API, not the CLI, but the Custom Anomaly Detection 
<https://docs.influxdata.com/kapacitor/v1.1/examples/anomaly_detection/> 
example 
gets one started and the response to kapacitor record query without 
arguments prints some guidelines.

Everything suggest that the query is a standard line protocol string. But 
there are some confusing differences. Observe:

$ influx
> CREATE DATABASE record
> USE record
> INSERT points a=1
> INSERT points b=2
> SELECT * FROM points
name: points
time a b
---- - -
1483716972843739426 1 
1483716980505185982 2

> exit
$ cat record_issue.tick
stream
    |from()
        .measurement('points')
    |log()
        .prefix('POINTS_ISSUE')
$ kapacitor define record_issue -type stream -tick record_issue.tick  -dbrp 
record.autogen
$ rid=$(kapacitor record query -query $'SELECT * FROM 
"record"."autogen"."points"' -type stream)
$ kapacitor replay -task record_issue -recording $rid -rec-time

At this point the log file shows:

[record_issue:log2] 2017/01/07 02:40:46 I! POINTS_ISSUE 
{"Name":"points","Database":"record","RetentionPolicy":"autogen","Group":"","Dimensions":{"ByName":false,"TagNames":null},"Tags":{},"Fields":{"a":1},"Time":"2017-01-06T15:36:12.843739426Z"}

which indicates that only the points with an 'a' field have been recorded. 
Executing the same query at the CLI returns both points.

Other differences:

$ rid=$(kapacitor record query -query $'SELECT a,b FROM 
"record"."autogen"."points"' -type stream)

still only returns 'a' field, not 'b' field, when replayed.

$ influx
> USE record
> INSERT points,t1=3 a=3,b=3
> INSERT points,t2=4 a=4,b=4
> SELECT * FROM points
name: points
time a b t1 t2
---- - - -- --
1483716972843739426 1 
1483716980505185982 2 
1483717340694062989 3 3 3 
1483717349891893752 4 4 4
> exit
$ rid=$(kapacitor record query -query $'SELECT a,b FROM 
"record"."autogen"."points"' -type stream)

only returns 'a', no tags.

$rid=$(kapacitor record query -query $'SELECT * FROM 
"record"."autogen"."points" GROUP BY *' -type stream)

Returns all the tags this time, but not the points without a in it (ie. the 
1483716980505185982 point).


Three questions:

   1. Why does each field key need to be named in the SELECT statement, 
   unlike CLI queries which return all the fields listed in the SELECT 
   statement.
   2. How do you return all fields (in order - multiple statements is not 
   suitable) from a measurement given the * doesn't work.
   3. Why is GROUP BY required to return the tags when it's unnecessary for 
   the CLI.


By the way, the record venture is invaluable. Being able to tweak kapacitor 
scripts, and test them on history data before deploring to practice is 
crucial.

Regards,
Heath

-- 
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/cd1c824d-7a25-4464-b325-d0075b5ebb50%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to