Kapacitor tick script not running

So we have kapacitor setup wihtin our install

ID Type Status Executing Databases and Retention Policies
test stream enabled true [“analytics”.“analytics”]

But nothing happens with the script or data.

our code is

stream
|from()
.database(‘analytics’)
.measurement(‘CLIENT_VALUES’)
.groupBy(*)
|window()
.period(1m)
.every(1m)
.align()
|mean(‘qty’)
.as(‘qty’)
|influxDBOut()
.database(‘analytics’)
.measurement(‘newValues’)

what happens if you run kapacitor show ?

Hard to say what is wrong just by looking at the script. Is Kapacitor processing the data, if so are there any errors shown when you run the above command?

Also, run journalctl -fu kapacitor | grep “your alert/script name” you will be able to see what happens when the script is run by Kapacitor.

so the last command I got

journalctl -fu kapacitor | grep test
No journal files were found.

I agree not very helpful when it just stays enable and you can’t see it writing or running. I even changed kapacitor into debug mode nothing in the logs just http requests.

Script output from the first command.

ID: test
Error:
Template:
Type: stream
Status: enabled
Executing: true
Created: 05 Oct 18 02:50 BST
Modified: 05 Oct 18 04:27 BST
LastEnabled: 05 Oct 18 04:27 BST
Databases Retention Policies: [“analytics”.“analytics”]
TICKscript:
stream
|from()
.database(‘analytics’)
.measurement(‘CLIENT_VALUES’)
.groupBy(*)
|window()
.period(1m)
.every(1m)
.align()
|mean(‘qty’)
.as(‘qty’)
|influxDBOut()
.database(‘analytics’)
.measurement(‘newValues’)

DOT:
digraph test {
graph [throughput=“0.00 points/s”];

stream0 [avg_exec_time_ns=“0s” errors=“0” working_cardinality=“0” ];
stream0 -> from1 [processed=“0”];

from1 [avg_exec_time_ns=“0s” errors=“0” working_cardinality=“0” ];
from1 -> window2 [processed=“0”];

window2 [avg_exec_time_ns=“0s” errors=“0” working_cardinality=“0” ];
window2 -> mean3 [processed=“0”];

mean3 [avg_exec_time_ns=“0s” errors=“0” working_cardinality=“0” ];
mean3 -> influxdb_out4 [processed=“0”];

influxdb_out4 [avg_exec_time_ns=“0s” errors=“0” points_written=“0” working_cardinality=“0” write_errors=“0” ];
}

Hmm, ok if you try tailing the logs instead

Sorry if i am teaching you to suck eggs here.
sudo tail -f /var/log/kapacitor/kapacitor.log

It looks from the output that Kapacitor is not streaming the data from the database. If the script was bad you would have errors listed next to each node in the output from teh first command. if you receieved no error messages when defining your TICK script then I’d look at the connection between the Kapacitor instance and InfluxDB.

One thing i notice in your script is you are not passing a retention policy to the |from() node.

Could you add this to your script:

var rp = ‘retention-policy-name’

Then in the |From node between the .database(‘analytics’) and .measurement(‘CLIENT_VALUES’)

.retentionPolicy(rp)

While you specify the RP when defining the script in Kapacitor, i think you may still need to explicitly set it in the script.

Hope that helps

This is most helpful because this is not easy to debug. Updated the rp to

var rp = ‘analytics’

stream
|from()
.database(‘analytics’)
.retentionPolicy(rp)

Bec the output of the tasks shows that

ID Type Status Executing Databases and Retention Policies
test stream enabled true [“analytics”.“analytics”]

With the kapacitor and connection to influx is that the one in the config?

I have this setup

enabled = true
default = true
name = “localhost”
urls = [“http://localhost:8086”]
username = “kapacitor”
password = “password”
timeout = 0

Agreed it can be a bit painful at times when it comes to debugging but the more you do it the easier it gets apparently (i’m not sure though :smiley:)

anways,

You’ve set the RP in the script and looking at that output it is the one you need. what affect did this have?
When you created the database and RP did you specify the default RP?

If you query influxdb directly, do you see the data in your database?
When you select the database (use database-name) specify your RP to be certain.

If you haven’t already, could you check in Influx and see what RP’s are associated with the database? It could be something simple like your data is going to the autogen RP which means your script won’t see the points being processed.

A side note, I’ve seen a lot of people with scripts using the “default” RP - The issue is that RP doesn’t actually exist. Its created as “autogen” but labelled as the default in InfluxDB.

You’re config looks good it doesn’t look any different to mine. Do you use any SSL certs? self signed or CA signed?

Also, how are you collecting the data. Telegraf?

let me check the RP thanks for the help yes interesting to debug :slight_smile: I am pushing the data into influx from flink and then what to alter it using kapacitor

Hi @BenTheCeler

I just wondered how you were getting on with this. Were you able to solve your issue?