Giter VIP home page Giter VIP logo

Comments (6)

zhoufwind avatar zhoufwind commented on September 18, 2024 1

@caohuigh 我这边试了下,好像没遇到你说的报错,这个配置你试下?

indexer-kafka-test.yml

inputs:
    - Stdin:
        codec: json

filters:
    - Convert:
        fields:
            server:
                setto_if_fail: 0
                to: int
            id:
                setto_if_fail: 0
                to: int

outputs:
    - Stdout: {}
gohangout --config indexer-kafka-test.yml
{"server":666,"ip":"1.2.3.4","id":100}
{"server":666,"ip":"1.2.3.4","id":100,"@timestamp":"2019-05-09T18:21:38.904303797+08:00"}

另外,panic: interface conversion: interface {} is string, not map[interface {}]interface {}这个错误更像是yaml格式(类似前排空格缩进)问题,可以查下你的yaml文件格式是不是有问题。

from gohangout.

childe avatar childe commented on September 18, 2024

@caohuigh 使用Convert转成int类型. https://github.com/childe/gohangout/#convert

from gohangout.

devNullgh avatar devNullgh commented on September 18, 2024

@childe 谢谢回复,您指的是使用FILTER里面的convert?我主要是想把string类型转成int64,格式是怎样的,可以给个例子吗?

from gohangout.

childe avatar childe commented on September 18, 2024
Convert:
    fields:
        server:
            setto_if_fail: 0
            to: int
        ip:
            to: int
            setto_if_fail: 0

from gohangout.

devNullgh avatar devNullgh commented on September 18, 2024

@childe

不好意思,是我没说清楚引起误解了,我想请教的是Convert应该放在什么位置?是放在filters下面吗?
比如这样:

inputs:

- Kafka:
    topic:
      ... ...

filters:

- Convert:
  fields:
      server:
          to: int
          remove_if_fail: false
      id:
          to: int
          remove_if_fail: false

outputs:

- Clickhouse:
      ... ...

但是我这样写运行的时候却报错了:
I0509 15:52:21.857921 187339 filter.go:72] filter type: Convert
panic: interface conversion: interface {} is nil, not map[interface {}]interface {}

goroutine 27 [running]:
github.com/childe/gohangout/filter.BuildFilterBoxes(0xc0001b5a40, 0x9f6740, 0xc0001e9630, 0x1, 0x0, 0x0)

我在output中的fields中是这样写的:
fields: ['server', 'ip', 'id']
我也试过:
fields: [server, 'ip', id]
但无论使用fields的哪种写法,结合上面的Convert时都会报错,是我哪里格式写错了吗?

from gohangout.

devNullgh avatar devNullgh commented on September 18, 2024

@zhoufwind
非常感谢您的建议,我检查了一下,确实在filters字段中整体少了一个空格,导致一直看不出来,已经测试入库成功了,谢谢!

from gohangout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.