【问题标题】:kapacitor : not opening http port when a python udf is specifiedkapacitor:指定 python udf 时不打开 http 端口
【发布时间】:2018-09-11 18:27:29
【问题描述】:

我正在尝试通过此 URL https://www.youtube.com/watch?v=LL8g4qiBCNo 了解 kapacitor 用户定义函数 (udf)

当我没有指定 python udf 时,kapacitor 启动并侦听 http 端口 9092。

我在 kapacitor.conf 中的 [udf] 部分看起来像

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

我的 python udf (geo.py) 如下所示

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 ..."

使用上面的 udf 部分,kapacitor 不会在 http 端口 9092 上侦听

【问题讨论】:

    标签: python user-defined-functions influxdb telegraf kapacitor


    【解决方案1】:

    我通过替换出现的

    解决了上述问题
    print >> sys.stdout
    


    print >> sys.stderr
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-15
      • 1970-01-01
      • 2013-06-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多