Class: Fluent::TagdataOutput

Inherits:
Output
  • Object
show all
Includes:
HandleTagNameMixin
Defined in:
lib/fluent/plugin/out_tagdata.rb

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/fluent/plugin/out_tagdata.rb', line 13

def configure(conf)
	super
	if @out_keys.empty?
		raise ConfigError, "out_tagdata: out_keys option is required on out_tagdata output."
	end
	if @firstpoint < 0
		raise ConfigError, "out_tagdata: firstpoint option is required a zero or positive number."
	end
end

#emit(tag, es, chain) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/fluent/plugin/out_tagdata.rb', line 23

def emit(tag, es, chain)
	es.each do |time,record|
		tagd = tag.dup
		get_mapped_tag_to_out_keys(tagd, time, record)
		filter_record(tagd, time, record)
		Fluent::Engine.emit(tagd, time, record)
	end
	chain.next
end

#get_mapped_tag_to_out_keys(tag, time, record) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fluent/plugin/out_tagdata.rb', line 33

def get_mapped_tag_to_out_keys(tag, time, record)
	tags = tag.split('.')
	@firstpoint.times do
		tags.shift
	end
	tagdata = {}
	key_end = nil
	@out_keys.each do |key,value|
		tagdata.store( key, tags.shift )
		key_end = key
	end
	if !tags.empty?
		tagdata[key_end] = tagdata[key_end] + '.' + tags.join('.')
	end
	tagdata.each do |key,value|
		record[key] = value
	end
end