"Post http://localhost:9092/kapacitor/v1/tasks: dial tcp connect: connection refused" error with UDF Kapacitor

Issues with UDF function in kapacitor.conf file.

I am trying to run a basic python script using UDF function through Kapacitor.
Here are the steps followed:

  1. Created a simple Python script that queries the Influxdb measurement ‘disk’.

tTest.py script:

def main():
import os
os.system(‘curl -G '\’ --data-urlencode 'q=select * from disk where used_percent=31' > /home/kapacitor/result.txt ')

if name==“main”:

  1. Configures the UDF function in kapacitor.conf file as:


enabled = true
default = true
name = “test”
urls = [“”]


Configuration for UDFs (User Defined Functions)

# Run python
prog = “/usr/bin/python2”
args = [“-u”, “/tmp/kapacitor_udf/tTest.py”]
timeout = “10s”

  1. TICK file:

dbrp “test”.“autogen”

var data = stream

On defining the TICK script, below error pops up:

root@kapacitor:/etc/kapacitor# kapacitor define cpu_alert -tick cpu_alert.tick
Post http://localhost:9092/kapacitor/v1/tasks: dial tcp connect: connection refused

However, if i disable the UDF function configuration in kapacitor.conf file and update the tick script to execute the Python program as below, the python script runs fine.

TICK script with exec() function:

dbrp “test”.“autogen”

.crit(lambda: int(“used_percent”) = 31)
// Whenever we get an alert write it to a file.

Please note that the Influx db and Kapacitor are on different machines as below: