采集 MongoDB的日志 并输出到 datahub 中
curl -L https://toolbelt.treasuredata.com/sh/install-redhat-td-agent3.sh | sh |
ruby和gem
cd /alidata/install/ |
插件 fluent-plugin-datahub
gem install fluent-plugin-datahub |
插件fluent-plugin-grok-parser
gem install fluent-plugin-grok-parser |
查看所有安装的gem包
[root@sh_02 openssl]# gem list |
mongodb的匹配
2018-08-01T22:00:31.367+0800 I COMMAND [conn4986471] command omdmain.item_region_erp command: find { find: "item_region_erp", filter: { ent_id: 1590271648210249400, region_code: "Q022", smg_out_key: { $exists: true }, status: "1", sale_price: { $gt: 0 }, $where: this.timestamp > this.smg_timestamp }, ntoreturn: 950, shardVersion: [ Timestamp 3000|4, ObjectId('5acbb4b0a7366023da49b822') ] } planSummary: IXSCAN { ent_id: 1, region_code: 1, item_code: 1, barcode: 1 } cursorid:112196383467 keysExamined:5859 docsExamined:5859 numYields:76 nreturned:950 reslen:902847 locks:{ Global: { acquireCount: { r: 158 } }, Database: { acquireCount: { r: 79 } }, Collection: { acquireCount: { r: 79 } } } protocol:op_command 1222ms |
日志格式
datahub endpoint:
http://dh-cn-hangzhou.aliyun-inc.com
project:datahub_43_booboowei
[root@sh_02 td-agent]# cat td-agent.conf
fluentd -c /alidata/install/fluentd/conf/datahub.conf
[root@sh_02 fluentd]# fluentd -c /alidata/install/fluentd/conf/datahub.conf
2018-08-08 17:21:21 +0800 [info]: parsing config file is succeeded path=”/alidata/install/fluentd/conf/datahub.conf”
2018-08-08 17:21:26 +0800 [warn]: ‘pos_file PATH’ parameter is not set to a ‘tail’ source.
2018-08-08 17:21:26 +0800 [warn]: this parameter is highly recommended to save the position to resume tailing.
2018-08-08 17:21:26 +0800 [info]: using configuration file:
问题汇总
使用ruby2.6的时候出现bug,具体如下
https://bugs.ruby-lang.org/issues/14976
2018-08-08 16:31:35 +0800 [info]: starting fluentd-1.2.4 pid=24157 ruby="2.6.0" |
解决方法:
将ruby改为2.3.6版本即可