td-agent 安装,配置,采集日志到postgresql

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012551524/article/details/86705452

系统版本:ubuntu 16.04

td-agent版本:2.1.0

postgresql版本:10.0


  1. 安装td-agent: curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-xenial-td-agent2.sh | sh
  2. 配置td-agent小版本:vi /lib/systemd/system/td-agent.service
  3. 启动td-agent:  systemctl daemon-reload  %{color: #24292e; font-variant-ligatures: normal;}systemctl start td-agent% 
  4. 配置安装Postgresql Output Plugin: %{color: #24292e; font-variant-ligatures: normal;}sudo /usr/sbin/td-agent-gem install fluent-plugin-postgres%
  5. 查看已安装的Plugin: /usr/sbin/td-agent-gem list | grep fluent-plugin
  6. 修改配置文件:vi /etc/td-agent/td-agent.conf  

    <source>

      @type tail

      path /tmp/tarcy/1.log

      pos_file /var/log/td-agent/1.log.pos

      tag postgresql.*

      format /^(?<order_id>[^|]*)[|]*(?<ts>[^|]*)[|]*(?<pos>[^|]*)$/

      time_format %Y-%m-%d %H:%M:%S.%N

      multiline_flush_interval 5s

      refresh_interval 5s

    </source>

    <match postgresql.tmp.tarcy.1.log>

      @type postgres

      host localhost

      port 5432

      database postgres

      username postgres

      password postgres

      key_names order_id,ts,pos

      sql INSERT INTO s1 VALUES ($1,$2,$3)

      flush_intervals 5s

    </match>

猜你喜欢

转载自blog.csdn.net/u012551524/article/details/86705452
td