Repository is archived
No commit activity in last 3 years
No release in over 3 years
Write Fluent logs to TimescaleDB
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 1.1
 Project Readme

fluent-plugin-timescaledb

Fluentd output plugin to store logs in TimescaleDB

Installation

You will probably need some Ruby tools available (e.g., ruby-dev) as well as the libpq library (libpq-dev/postgres-dev, depending on your OS).

RubyGems

$ gem install fluent-plugin-timescaledb

Bundler

Add following line to your Gemfile:

gem "fluent-plugin-timescaledb"

And then execute:

$ bundle

Configuration

You must have a running instance of TimescaleDB somewhere.

Create a database and then a table within it, something like this:

CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;
CREATE TABLE log_records (
                            time   TIMESTAMP NOT NULL,
                            tag    CHAR(128) NOT NULL,
                            record JSONB     NOT NULL
);
SELECT create_hypertable('log_records', 'time');

At your pleasure, you may want to add more indexes inside the JSONB block to allow for better querying. That's left as an exercise for the reader, depending on your exact needs.

To configure FluentD, add a block similar to this to your config.

<match **>
  @type timescaledb
  db_conn_string "host=localhost user=fluent password=supersecret dbname=fluent"
</match>

The exact value of db_conn_string is as defined by the pg Gem.

Copyright

  • Copyright(c) 2019: 1500 Services Ltd
  • License
    • Apache License, Version 2.0