pythonuser-defined-functionsinfluxdbtelegrafkapacitor

kapacitor : not opening http port when a python udf is specified


I am trying to learn about kapacitor User Defined Functions (udf) from this URL https://www.youtube.com/watch?v=LL8g4qiBCNo

kapacitor starts and listens on http port 9092 when I do not specify a python udf.

My [udf] section in kapacitor.conf looks like

[udf]
[udf.functions]
    [udf.functions.geoSum]
      prog = "/usr/bin/python"
      args = ["-u", "/tmp/geo.py"]
      timeout = "20s"

My python udf (geo.py) looks like the following

import sys
from agent import Agent, Handler
import udf_pb2
class GeoSum(Handler):
    def __init__(self):
                self._field = ''
                self.size = 0
    def info(self):
        response = udf_pb2.Response()
        response.info.wants = udf_pb2.STREAM
        response.info.provides = udf_pb2.STREAM
        response.info.options['field'].valueTypes.append(udf_pb2.STRING)
        response.info.options['size'].valueTypes.append(udf_pb2.INT)
        response.info.options['magic'].valueTypes.extend([
              udf_pb2.INT,
              udf_pb2.DOUBLE,
              udf_pb2.DURATION
        ])
        return response

if __name__ == '__main__':
    agent = Agent()
    handler = GeoSum()
    agent.handler = handler

    print >> sys.stdout, "Starting GeoSum ..."
    agent.start()
    agent.wait()
    print >> sys.stdout, "Stoping GeoSum ..."

With the above udf section kapacitor does not listen on http port 9092


Solution

  • I resolved the above issue by replacing the occurrences of

    print >> sys.stdout
    

    with

    print >> sys.stderr