GithubHelp home page GithubHelp logo

fluent-plugin-postgres's Introduction

fluent-plugin-postgres, a plugin for Fluentd

Installation:

  • Prereq: Install postgresql headers: apt-get install libpq-dev
  • Install the gem:
    • gem install fluent-plugin-postgres or
    • /usr/lib/fluent/ruby/bin/fluent-gem install fluent-plugin-postgres

Changes from mysql:

  • We currently don't support json format
  • You need to specify a SQL query
  • Placeholders are numbered (yeah, I know).

Other than that, just bear in mind that it's Postgres SQL.

Quick example

<match output.by.sql.*>
  type postgres
  host master.db.service.local
  # port 3306 # default
  database application_logs
  username myuser
  password mypass
  key_names status,bytes,vhost,path,rhost,agent,referer
  sql INSERT INTO accesslog (status,bytes,vhost,path,rhost,agent,referer) VALUES ($1,$2,$3,$4,$5,$6,$7)
  flush_intervals 5s
</match>

Component

PostgresOutput

Plugin to store Postgres tables over SQL, to each columns per values, or to single column as json.

Configuration

MysqlOutput

MysqlOutput needs MySQL server's host/port/database/username/password, and INSERT format as SQL, or as table name and columns.

<match output.by.sql.*>
  type mysql
  host master.db.service.local
  # port 3306 # default
  database application_logs
  username myuser
  password mypass
  key_names status,bytes,vhost,path,rhost,agent,referer
  sql INSERT INTO accesslog (status,bytes,vhost,path,rhost,agent,referer) VALUES (?,?,?,?,?,?,?)
  flush_intervals 5s
</match>

<match output.by.names.*>
  type mysql
  host master.db.service.local
  database application_logs
  username myuser
  password mypass
  key_names status,bytes,vhost,path,rhost,agent,referer
  table accesslog
  # 'columns' names order must be same with 'key_names'
  columns status,bytes,vhost,path,rhost,agent,referer
  flush_intervals 5s
</match>

Or, insert json into single column.

<match output.as.json.*>
  type mysql
  host master.db.service.local
  database application_logs
  username root
  table accesslog
  columns jsondata
  format json
  flush_intervals 5s
</match>

To include time/tag into output, use include_time_key and include_tag_key, like this:

<match output.with.tag.and.time.*>
  type mysql
  host my.mysql.local
  database anydatabase
  username yourusername
  password secret

  include_time_key yes
  ### default `time_format` is ISO-8601
  # time_format %Y%m%d-%H%M%S
  ### default `time_key` is 'time'
  # time_key timekey

  include_tag_key yes
  ### default `tag_key` is 'tag'
  # tag_key tagkey

  table anydata
  key_names time,tag,field1,field2,field3,field4
  sql INSERT INTO baz (coltime,coltag,col1,col2,col3,col4) VALUES (?,?,?,?,?,?)
</match>

Or, for json:

<match output.with.tag.and.time.as.json.*>
  type mysql
  host database.local
  database foo
  username root

  include_time_key yes
  utc   # with UTC timezome output (default: localtime)
  time_format %Y%m%d-%H%M%S
  time_key timeattr

  include_tag_key yes
  tag_key tagattr
  table accesslog
  columns jsondata
  format json
</match>
#=> inserted json data into column 'jsondata' with addtional attribute 'timeattr' and 'tagattr'

TODO

  • implement 'tag_mapped'
    • dynamic tag based table selection

Copyright

  • Copyright
    • Copyright 2013 Uken Games
  • License
    • Apache License, Version 2.0

fluent-plugin-postgres's People

Contributors

cosmo0920 avatar tagomoris avatar pitr avatar dterror-zz avatar notpeter avatar tobiasmuehl avatar kiyoto avatar

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.