class Fluent::Plugin::DynatraceOutput
Fluentd output plugin for Dynatrace
Constants
- HTTP_REQUEST_LOCK
Attributes
agent[RW]
Default injection parameters. Requires the :inject helper to be added to the helpers above and the
inject lines to be uncommented in the #write and #process methods
config_section :inject do
config_set_default :time_type, :string config_set_default :localtime, false
end
uri[RW]
Default injection parameters. Requires the :inject helper to be added to the helpers above and the
inject lines to be uncommented in the #write and #process methods
config_section :inject do
config_set_default :time_type, :string config_set_default :localtime, false
end
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_dynatrace.rb, line 60 def configure(conf) compat_parameters_convert(conf, :inject) super @uri = URI.parse(@active_gate_url) @agent = Net::HTTP.new(@uri.host, @uri.port) return unless uri.scheme == 'https' @agent.use_ssl = true @agent.verify_mode = OpenSSL::SSL::VERIFY_NONE if @ssl_verify_none end
failure_message(res)
click to toggle source
# File lib/fluent/plugin/out_dynatrace.rb, line 134 def failure_message(res) res_summary = if res "#{res.code} #{res.message} #{res.body}" else 'res=nil' end "failed to request #{uri} (#{res_summary})" end
multi_workers_ready?()
click to toggle source
# File lib/fluent/plugin/out_dynatrace.rb, line 103 def multi_workers_ready? false end
prefer_buffered_processing()
click to toggle source
# File lib/fluent/plugin/out_dynatrace.rb, line 99 def prefer_buffered_processing true end
prepare_request(uri)
click to toggle source
# File lib/fluent/plugin/out_dynatrace.rb, line 113 def prepare_request(uri) req = Net::HTTP::Post.new(uri, { 'User-Agent' => user_agent }) req['Content-Type'] = 'application/json; charset=utf-8' req['Authorization'] = "Api-Token #{@api_token}" req end
process(_tag, es)
click to toggle source
# File lib/fluent/plugin/out_dynatrace.rb, line 80 def process(_tag, es) # es = inject_values_to_event_stream(tag, es) es.each do |_time, record| send_to_dynatrace("#{record.to_json.chomp}\n") end end
send_to_dynatrace(body)
click to toggle source
# File lib/fluent/plugin/out_dynatrace.rb, line 121 def send_to_dynatrace(body) HTTP_REQUEST_LOCK.synchronize do agent.start unless agent.started? req = prepare_request(@uri) res = @agent.request(req, body) return if res.is_a?(Net::HTTPSuccess) raise failure_message res end end
shutdown()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/out_dynatrace.rb, line 73 def shutdown @agent.finish if @agent.started? super end
user_agent()
click to toggle source
# File lib/fluent/plugin/out_dynatrace.rb, line 109 def user_agent "fluent-plugin-dynatrace v#{DynatraceOutputConstants.version}" end
write(chunk)
click to toggle source
# File lib/fluent/plugin/out_dynatrace.rb, line 87 def write(chunk) body = [] chunk.each do |_time, record| # body.push(inject_values_to_record(chunk.metadata.tag, time, record)) body.push(record) end send_to_dynatrace("#{body.to_json.chomp}\n") unless body.empty? end