Class: Fluent::NewrelicOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::NewrelicOutput
- Defined in:
- lib/fluent/plugin/out_newrelic.rb
Instance Method Summary collapse
-
#configure(conf) ⇒ Object
This method is called before starting.
-
#emit(tag, es, chain) ⇒ Object
This method is called when an event reaches Fluentd.
-
#shutdown ⇒ Object
This method is called when shutting down.
-
#start ⇒ Object
This method is called when starting.
Instance Method Details
#configure(conf) ⇒ Object
This method is called before starting.
10 11 12 |
# File 'lib/fluent/plugin/out_newrelic.rb', line 10 def configure(conf) super end |
#emit(tag, es, chain) ⇒ Object
This method is called when an event reaches Fluentd. ‘es’ is a Fluent::EventStream object that includes multiple events. You can use ‘es.each {|time,record| … }’ to retrieve events. ‘chain’ is an object that manages transactions. Call ‘chain.next’ at appropriate points and rollback if it raises an exception.
NOTE! This method is called by Fluentd’s main thread so you should not write slow routine here. It causes Fluentd’s performance degression.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fluent/plugin/out_newrelic.rb', line 31 def emit(tag, es, chain) chain.next es.each {|time,record| $stderr.puts "OK!" if (record.has_key?("server_events")) newhash = Hash.new # If the record value is not a array, then assign the name to value record.each_pair do |singlekey, singlevalue| if (singlevalue.class == String) newhash[singlekey]=singlevalue end end # Walk thro the array and assign each value record["server_events"].each_with_index do |attr, idx| temphash=Hash.new # Each value within the array is a hash # Iterate thro the hash and assign the values attr.each_pair do |key, value| temphash[key]=value newhash[key]=value end newhash["raw"]=temphash.clone Fluent::Engine.emit @tag, time.to_i, newhash end else # Emit as is Fluent::Engine.emit @tag, time, record end } end |
#shutdown ⇒ Object
This method is called when shutting down.
20 21 22 |
# File 'lib/fluent/plugin/out_newrelic.rb', line 20 def shutdown super end |
#start ⇒ Object
This method is called when starting.
15 16 17 |
# File 'lib/fluent/plugin/out_newrelic.rb', line 15 def start super end |