Is there a tool to check for syntax errors in a tick script?
Yes, there is a standalone binary that ships with the packages called
tickfmt that will format a TICKscript and naturally check its syntax.
Otherwise when you define a task via the API the syntax is always validated before saving the task.
Thanks that helps.
One more question: Is there a way to compile a tick script without actually running Kapacitor?
We want this because we want to deploy tick scripts automatically and want to make sure kapacitor define wont fail.
Not really, if this is critically important you could write a small program to do it for you and use the Kapacitor sources as a package in that program. The challenge you will run into though is that tasks run in a context which can be different from server to server, i.e which UDFs are present etc.
I might have to take this route I guess, is there some example code I can look at?
I’m currently trying to also check the syntax of tick scripts before running Kapacitor, by importing Kapacitor packages and running tick.Evaluate with tick scripts that we use.
The issue is that it seems that this function Evaluate needs the user to define the scope of a script, which would involve potentially defining all nodes if we want a general purpose syntax checker. This is also not even possible given that functions such as newBatchNode are not exported, and nor are the struct members of such nodes.
Is there any way these node functions could be exported, or is there some other better way of syntax checking that could be done using the Kapacitor packages externally?