Skip to content

Instantly share code, notes, and snippets.

@repeatedly
repeatedly / filter_record_reformer.rb
Last active August 29, 2015 14:05
Filter example3: record_reformer
require 'socket'
require 'ostruct'
module Fluent
class RecordReformerFilter < Filter
Fluent::Plugin.register_filter('record_reformer', self)
def initialize
super
end
@repeatedly
repeatedly / filter_add_metadata.rb
Last active August 29, 2015 14:05
Filter example2: add tag and time like existence mixins
module Fluent
class AddMetadataFilter < Filter
Plugin.register_filter('add_metadata', self)
config_param :include_time_key, :bool, :default => false
config_param :time_key, :string, :default => 'time'
config_param :time_format, :string, :default => nil
config_param :include_tag_key, :bool, :default => false
config_param :tag_key, :string, :default => 'tag'
config_param :localtime, :bool, :default => true
@repeatedly
repeatedly / filter_grep.rb
Last active August 29, 2015 14:05
Filter example1: grep filter
class Fluent::GrepFilter < Fluent::Filter
Fluent::Plugin.register_filter('grep', self)
REGEXP_MAX_NUM = 20
config_param :input_key, :string, :default => nil # obsolete
config_param :regexp, :string, :default => nil # obsolete
config_param :exclude, :string, :default => nil # obsolete
config_param :replace_invalid_sequence, :bool, :default => false
(1..REGEXP_MAX_NUM).each {|i| config_param :"regexp#{i}", :string, :default => nil }
@repeatedly
repeatedly / filter_and_label.md
Last active August 29, 2015 14:05
v1でのラベル and フィルタの実装

v11は互換性が無かったためガリガリと実装出来たが,v1ではそれは出来ないため,必要な機能だけうまくマージする必要がある.

Agent

プラグイン群の実行単位としてAgentを導入して,Engineはそのrootを指すようにした.ラベルもAgentの一部で,いくつかの処理はrootに委譲する. RootAgentはsourceを持てるが,Labelなどは実装的に持てなくなっている.

名前はcontextとかの方がいいかもしれない?

InputもOutputもAgentではない

@repeatedly
repeatedly / td-agent-2-build-for-ubuntu-14.04.md
Last active August 29, 2015 14:03
Vagrantを使ってUbuntu 14.04向けtd-agent 2のビルド方法

Ubuntu 14.04

vagrant upだと上手くいかないので,test-kitchen経由の方がやりやすい.が,どっちにしろ上手くいかないので,以下の手順でやる

1 まずインスタンスを作る

$ bundle exec kitchen create default-ubuntu-1404
@repeatedly
repeatedly / in_tail_check_list.md
Last active August 29, 2015 14:03
in_tail check list

English

Fixed path

  • Check reading /path/to/file
    • read_from_head true / false
  • Check /path/to/file rotation (waiting rotate_wait time and read logs in parallel)
    • mv file file1; touch file
    • mv file file1
  • rm file
@repeatedly
repeatedly / td-agent
Created June 18, 2014 07:48
/etc/init.d/td-agent for td-agent 2.x
#!/bin/bash
#
# /etc/rc.d/init.d/td-agent
#
# chkconfig: - 80 20
# description: td-agent
# processname: td-agent
# pidfile: /var/run/td-agent/td-agent.pid
#
### BEGIN INIT INFO
@repeatedly
repeatedly / about_td_agent2.md
Last active November 16, 2016 02:11
td-agent2について

rpmで問題が起きたのでまとめておく.あと英語で書くと日本の人が読んでくれないのでまず日本語で…

なぜパッケージを分けているのか

非互換のある変更が単なるアップデートで入るのを防ぐため

現在のtd-agentは1.1.19だが,2.0.0と1.2.0があった場合,yum updateでは2.0.0が入ってしまう.これでは,Rubyのバージョンが変わった場合などはgemの再インストールが必要で,単なるアップデートでは起動出来なくなるという問題がある(chefとか使っていれば多分防ぐことは出来るが強制することは出来ない).

Rubyのバージョンアップと依存ライブラリのバージョンアップを分けることが出来ない

@repeatedly
repeatedly / scope_bench.d
Created May 18, 2014 23:38
scope(exit) overhead in dlang. See http://lk4d4.darth.io/posts/defer/
import std.array;
import std.stdio;
import std.datetime;
import core.sync.mutex;
final class Queue
{
private:
Mutex _mutex;
int[] _arr;
Run options: exclude {:env=>:win}
DNS
connects to valid domains (FAILED - 1)
fires on_resolve_failed for invalid domains
Coolio::StatWatcher
fire on_change when the file it is watching is modified
should pass previous and current file stat info given a stat watcher
should raise when the handler does not take 2 parameters