Closed liulei18 closed 5 years ago
可以的, 写到readme里面了.
但是只是实现性质的, 虽然我们也在使用, 不过未必适用各种各样的场景, 比如说有字段缺失时的处理可能不妥, 甚至有可能有错误.
我尽快修掉这个问题吧. 如果确保字段不会缺失, 可以用. 否则还是先不要用.. :((
好的,感谢,gohangout 不需要引入插件就可以写入到clickhouse吧?而hangout我看文档是需要的
不需要.
drwxr-xr-x. 2 root root 4096 Dec 26 17:47 codec
drwxr-xr-x. 2 root root 4096 Dec 26 17:47 condition_filter
-rw-r--r--. 1 root root 517 Dec 26 17:47 config_parser.go
-rw-r--r--. 1 root root 1666 Dec 26 17:47 example.yml
drwxr-xr-x. 2 root root 4096 Dec 26 17:47 field_deleter
drwxr-xr-x. 2 root root 4096 Dec 26 17:47 field_setter
drwxr-xr-x. 2 root root 4096 Dec 26 17:47 filter
-rwxr-xr-x. 1 root root 3042 Dec 26 17:47 gohangout.go
-rw-r--r--. 1 root root 10864621 Nov 6 10:03 gohangout-linux-386-656cd32
-rwxr-xr-x. 1 root root 12744270 Nov 6 10:03 gohangout-linux-x64-656cd32
drwxr-xr-x. 2 root root 4096 Dec 26 17:47 input
-rw-r--r--. 1 root root 770 Dec 26 17:47 Makefile
drwxr-xr-x. 2 root root 4096 Dec 26 17:47 output
-rw-r--r--. 1 root root 17683 Dec 26 17:47 README.md
drwxr-xr-x. 2 root root 4096 Dec 26 17:47 simplejson
drwxr-xr-x. 2 root root 4096 Dec 26 17:47 test
drwxr-xr-x. 2 root root 4096 Dec 26 17:47 value_render
drwxr-xr-x. 2 root root 4096 Dec 26 17:47 vendor
-rw-r--r--. 1 root root 985 Dec 26 17:47 yaml_config_parser.go
./gohangout-linux-x64-656cd32 --config example.yml
F1226 18:51:30.150692 14057 translate.go:101] could not parse http://corp.com/dict/user.yml:yaml: line 26: mapping values are not allowed in this context
goroutine 1 [running]:
github.com/golang/glog.stacks(0xc420183b00, 0xc42019e400, 0x9c, 0x1e7)
/Users/liujia/.go/src/github.com/golang/glog/glog.go:769 +0xcf
github.com/golang/glog.(*loggingT).output(0xc278e0, 0xc400000003, 0xc4201ae0b0, 0xbd59b9, 0xc, 0x65, 0x0)
/Users/liujia/.go/src/github.com/golang/glog/glog.go:720 +0x345
github.com/golang/glog.(*loggingT).printf(0xc278e0, 0x3, 0x963026, 0x15, 0xc4201339f8, 0x2, 0x2)
/Users/liujia/.go/src/github.com/golang/glog/glog.go:655 +0x14c
github.com/golang/glog.Fatalf(0x963026, 0x15, 0xc4201339f8, 0x2, 0x2)
/Users/liujia/.go/src/github.com/golang/glog/glog.go:1148 +0x67
github.com/childe/gohangout/filter.NewTranslateFilter(0xc420183950, 0x9)
/Users/liujia/.go/src/github.com/childe/gohangout/filter/translate.go:101 +0x3dc
github.com/childe/gohangout/filter.BuildFilter(0xc42013f370, 0x9, 0xc420183950, 0xbea4c0, 0xc420146620, 0x0, 0x0, 0x0, 0xbea4c0, 0xc420146620)
/Users/liujia/.go/src/github.com/childe/gohangout/filter/filter.go:127 +0x184a
github.com/childe/gohangout/filter.BuildFilters(0xc4201835f0, 0xbea4c0, 0xc420146620, 0xc42014b7e0, 0x2, 0x2, 0x470, 0x0, 0x0)
/Users/liujia/.go/src/github.com/childe/gohangout/filter/filter.go:51 +0x5f5
main.buildPluginLink(0xc4201835f0, 0x2, 0xc420133f30, 0x1)
/Users/liujia/.go/src/github.com/childe/gohangout/gohangout.go:41 +0x496
main.main()
/Users/liujia/.go/src/github.com/childe/gohangout/gohangout.go:77 +0x14e
我给的example.yml你不能直接拿来用~ 要看自己的需求配置.
我创建topic命令如下:kafka-topics.sh --create --zookeeper mini2:2181 --replication-factor 1 --partitions 1 --topic goweblog
查看topic描述: kafka-topics.sh --describe --zookeeper mini2:2181 --topic goweblog 结果如下
Topic:goweblog PartitionCount:1 ReplicationFactor:1 Configs:
Topic: goweblog Partition: 0 Leader: 2 Replicas: 2 Isr: 2
我的配置文件如下:
inputs:
- Kafka:
topic:
goweblog: 1
codec: json
consumer_settings:
bootstrap.servers: "192.168.252.206:9092,192.168.252.203:9092,192.168.50.252:9092"
group.id: gohangout.goweblog
filters:
- Grok:
src: message
match:
- '^(?P<logtime>\S+) (?P<name>\w+) (?P<status>\d+)$'
remove_fields: ['message']
- Date:
location: 'Asia/Shanghai'
src: logtime
formats:
- 'RFC3339'
remove_fields: ["logtime"]
outputs:
- Elasticsearch:
hosts:
- http://192.168.252.206:9200
- http://192.168.252.203:9200
- http://192.168.50.252:9200
index: 'web-%{+2006-01-02}' #golang里面的渲染方式就是用数字, 而不是用YYMM.
index_type: "logs"
bulk_actions: 5000
bulk_size: 20
flush_interval: 60
启动执行 ./gohangout-linux-x64-656cd32 --config config.yml 报如下错误
E1227 13:03:23.470667 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:23.573058 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:23.673324 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:23.773577 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:23.873833 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:23.974085 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:24.074327 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:24.174576 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:24.274831 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:24.375093 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:24.475332 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:24.575600 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:24.675854 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:24.776105 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:24.876347 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:24.976596 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:25.076854 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:25.177107 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:25.277275 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:25.377535 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:25.477792 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:25.578050 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:25.678308 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:25.778540 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:25.878797 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:25.979049 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:26.079308 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:26.179579 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:26.279828 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:26.380089 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:26.480325 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:26.580592 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:26.680848 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:26.781101 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:26.881344 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:26.981595 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:27.081856 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:27.182109 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:27.282341 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:27.382592 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:27.482843 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:27.583107 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:27.683343 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:27.783595 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
我的kafka集群版本kafka_2.11-0.8.2.2,我测试过,集群可以正常的生产和消费消息,所以我认为应该不是kafka的问题,我比较疑惑的是假如golang消费kafka数据用的kafka高阶api的话,配置文件不需要指定zookeeper的地址吗?我看文档没有任何关于zk配置的介绍
kafka-console-consumer.sh --zookeeper mini2:2181 --topic goweblog --from-beginning
{"logtime":"Nov 11, 2015 12:22:12 PM","name":"gohangout","status":0}
不需要指定ZK, 只要指定kafka的broker地址.
E1227 13:03:23.470667 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:23.573058 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:23.673324 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:23.773577 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:23.873833 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:23.974085 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 13:03:24.074327 30986 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
./gohangout-linux-x64-656cd32 --config example.yml --logtostderr -v 10 看一下日志.
./gohangout-linux-x64-656cd32 --config example.yml --logtostderr -v 10 看一下日志.
I1227 17:44:43.180495 3128 gohangout.go:75] map[inputs:[map[Kafka:map[consumer_settings:map[bootstrap.servers:192.168.252.206:9092,192.168.252.203:9092,192.168.50.252:9092 group.id:gohangout.goweblog] topic:map[goweblog:1] codec:json]]] filters:[map[Grok:map[src:message match:[^(?P<logtime>\S+) (?P<name>\w+) (?P<status>\d+)$] remove_fields:[message]]] map[Date:map[location:Asia/Shanghai src:logtime formats:[RFC3339] remove_fields:[logtime]]]] outputs:[map[Elasticsearch:map[hosts:[http://192.168.252.206:9200 http://192.168.252.203:9200 http://192.168.50.252:9200] index:web-%{+2006-01-02} index_type:logs bulk_actions:5000 bulk_size:20 flush_interval:60]]]]
I1227 17:44:43.180709 3128 output.go:21] output type: Elasticsearch
I1227 17:44:43.180727 3128 output.go:23] output config: map[bulk_size:20 flush_interval:60 hosts:[http://192.168.252.206:9200 http://192.168.252.203:9200 http://192.168.50.252:9200] index:web-%{+2006-01-02} index_type:logs bulk_actions:5000]
I1227 17:44:43.182625 3128 filter.go:34] filter type: Date
I1227 17:44:43.182705 3128 filter.go:36] filter config: map[location:Asia/Shanghai src:logtime formats:[RFC3339] remove_fields:[logtime]]
I1227 17:44:43.183719 3128 filter.go:47] filter type: Grok
I1227 17:44:43.183739 3128 filter.go:49] filter config: map[match:[^(?P<logtime>\S+) (?P<name>\w+) (?P<status>\d+)$] remove_fields:[message] src:message]
I1227 17:44:43.183785 3128 grok.go:58] patterns:map[]
I1227 17:44:43.183832 3128 grok.go:130] final pattern:^(?P<logtime>\S+) (?P<name>\w+) (?P<status>\d+)$
I1227 17:44:43.184289 3128 gohangout.go:44] input[1] map[Kafka:map[topic:map[goweblog:1] codec:json consumer_settings:map[bootstrap.servers:192.168.252.206:9092,192.168.252.203:9092,192.168.50.252:9092 group.id:gohangout.goweblog]]]
I1227 17:44:43.184967 3128 broker.go:106] 192.168.252.43:56073 -> 192.168.252.206:9092
I1227 17:44:43.185013 3128 broker.go:107] request length: 58. api: 3 CorrelationID: 1
I1227 17:44:43.187290 3128 broker.go:135] response length in header: 24
I1227 17:44:43.187320 3128 broker.go:158] response length: 24. CorrelationID: 1
I1227 17:44:43.187348 3128 brokers.go:50] got 0 brokers
E1227 17:44:43.187402 3128 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 17:44:43.287678 3128 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
E1227 17:44:43.387941 3128 group_consumer.go:254] could not find coordinator: could not find coordinator from all brokers
kafka中json数据如下 {"logtime":"Nov 11, 2015 12:22:12 PM","name":"gohangout","status":0}
日志中有这样一行输出 I1227 17:44:43.187348 3128 brokers.go:50] got 0 brokers 我的配置文件bootstrap.servers对应的kafka集群地址是应该用逗号隔开?
inputs:
- Kafka:
topic:
goweblog: 1
codec: json
consumer_settings:
bootstrap.servers: "192.168.252.206:9092,192.168.252.203:9092,192.168.50.252:9092"
group.id: gohangout.goweblog
filters:
- Grok:
src: message
match:
- '^(?P<logtime>\S+) (?P<name>\w+) (?P<status>\d+)$'
remove_fields: ['message']
- Date:
location: 'Asia/Shanghai'
src: logtime
formats:
- 'RFC3339'
remove_fields: ["logtime"]
outputs:
- Elasticsearch:
hosts:
- http://192.168.252.206:9200
- http://192.168.252.203:9200
- http://192.168.50.252:9200
index: 'web-%{+2006-01-02}' #golang里面的渲染方式就是用数字, 而不是用YYMM.
index_type: "logs"
bulk_actions: 5000
bulk_size: 20
flush_interval: 60
kafka集群地址是应该用逗号隔开, 格式是没错的. 你们是什么版本的kafka, 奇怪为啥拿到的broker数量是0.
可能是版本太低了, 0.9之前的版本我没有测试过. 我这边0.9.0.X , 2.0 这两个版本都有使用, 是集群.
I1228 18:09:55.000614 28336 gohangout.go:75] map[inputs:[map[Kafka:map[topic:map[testclickhouse:3] codec:json consumer_settings:map[bootstrap.servers:mini5:9092,mini6:9092,mini7:9092 group.id:gohangout.testclickhouse]]]] filters:[map[Grok:map[match:[^(?P<id>\S+) (?P<name>\w+)$] remove_fields:[message] src:message]]] outputs:[map[Clickhouse:map[fields:[id name] bulk_actions:1 flush_interval:1 hosts:[tcp://localhost:8123] table:cms.testclickhouse]]]]
I1228 18:09:55.000804 28336 output.go:21] output type: Clickhouse
I1228 18:09:55.000822 28336 output.go:23] output config: map[table:cms.testclickhouse fields:[id name] bulk_actions:1 flush_interval:1 hosts:[tcp://localhost:8123]]
I1228 18:09:55.000887 28336 clickhouse_output.go:86] query: INSERT INTO cms.testclickhouse ("id","name") VALUES (?,?)
向kafka中生产如下数据 {"id":"p0001","name":"gohangout"}
启动没有报错信息,数据没有写入到clickhouse的对应的表中
配置文件如下
inputs:
- Kafka:
topic:
testclickhouse: 3
codec: json
consumer_settings:
bootstrap.servers: "mini5:9092,mini6:9092,mini7:9092"
group.id: gohangout.testclickhouse
filters:
- Grok:
src: message
match:
- '^(?P<id>\S+) (?P<name>\w+)$'
remove_fields: ['message']
outputs:
- Clickhouse:
hosts:
- 'tcp://localhost:8123'
table: cms.testclickhouse
fields: ['id', 'name']
bulk_actions: 1
flush_interval: 1
8123是HTTP接口, TCP的应该是9000端口.
多谢~
版本问题, 我需要再查一下原因, 自己搭建一个0.8版本的测下看, 因为只看kafka文档说明,应该是支持0.8版本的.
之前的版本只是测试用, 最新代码更新了一些功能, 修复了一些问题.
这个版本打包好了放在 https://github.com/childe/gohangout/releases/tag/d1cd103