TICKScript doesn't work

(God of English forgive me) Hello! I use Kapacitor for the first time. At the moment, the situation is as follows:
-Installed TICK Stack (Chronograf replaced by Grafana)
-There is a table in InfluxDB with the following data:

time        | cache |  url      | name
10:20:30     123      0.0.0.50    name1
10:20:30     123      0.0.0.51    name1
10:20:35     123      0.0.0.01    name1
10:20:33     321      0.0.0.00    name1
10:20:31     200      0.0.0.50    name2

This is host replication data. Each host has 4 URLs and replication with 4 URLs (URL with 5 and URL with 0). A collection of hosts is called a node (name1 for example). It is necessary to output only hosts with different cache values.
-I tried stream and batch TICKScript, but without success.
Batch example:

var firstrep = stream
         .where(lambda: "url" =~ /\S+5\d/)
         .period(1h)
         .every(1m)
         .groupBy('name')
         .fill(0)
var secondrep = batch
    |query('SELECT max("cache") FROM "tablename" WHERE "url" =~ /\S+0\d/')
         .period(1h)
         .every(1m)
         .groupBy('name')
         .fill(0)
firstrep
    |join(secondrep).as('one','two')
    |eval(lambda: "first.max - two.max").as('delta')
    |InfluxDBOut().database('kapacitor').measurment('deltas')

But there is error in the regex, something about ‘/’, and I can’t fix it long time.
Stream example:

var firstrep = stream
      |from()
              .database('telegraf')
              .measurement('tablename')
          .where("url" =~ /\S+5\d/)
         .groupBy('name')
      |window()
         .period(1h)
         .every(1m)
   |mean('cache')
            .as('cache')
var secondrep = stream
      |from()
              .database('telegraf')
              .measurement('tablename')
          .where("url" =~ /\S+0\d/)
         .groupBy('name')
      |window()
         .period(1h)
         .every(1m)
   |mean('cache')
            .as('cache')
firstrep
    |join(secondrep).as('firstrep','secondrep')
            .tolerance(10s)
    |eval(lambda: "firstrep.cache- secondrep.cache").as('delta')
    |InfluxDBOut().database('kapacitor').measurment('deltas')

For start and check the script I do:

kapacitor define deltatask -tick tickscript.tick -dbrp “telegraf”.“tablename”

After this:

kapacitor enable deltatask

The stream TICKScript compile fine, but there is no data in db, i tried to check httpOut() → {“series”:null}. In DOT processed = 0 everywhere. Probably I need to edit kapacitor.conf, but I don’t understand exactly how. I trying without “where” condition - it seems like it doesn’t see the data, maybe you know some steps to test it. Thank you!

Hi @_login40k,

Not sure what’s going on with your TICK script, but as an aid in debugging it, you might try installing Chronograf, then going to the ‘Alerting’ tab, and paste in your TICK script, and running it there. You can also select ‘Editor+Logs’ to see real-time output of what is happening with your TICK script.

Also, when building complicated TICK scripts, I tend to add in a fair number of |log() statements to get output along the way to see what the issue might be.

Best Regards,
dg

1 Like

Thanks - good idea. |log() - works on Windows?

It does. And from the Chronograf interface it will show you the logs in real-time in a split-pane with the TICK script.

dg