Class: Fluent::Plugin::CwmHttpInput

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/in_http_cwm.rb

Overview

Custom HTTP Input Plugin class for CWM

Instance Method Summary collapse

Constructor Details

#initializeCwmHttpInput

Returns a new instance of CwmHttpInput.



69
70
71
72
73
74
# File 'lib/fluent/plugin/in_http_cwm.rb', line 69

def initialize
  super

  @redis = nil
  @deployment_api_metrics = default_api_metrics_hash
end

Instance Method Details

#configure(conf) ⇒ Object



76
77
78
79
80
# File 'lib/fluent/plugin/in_http_cwm.rb', line 76

def configure(conf)
  super

  set_up_redis
end

#startObject



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/fluent/plugin/in_http_cwm.rb', line 82

def start
  super

  # set up timer for flush interval
  timer_execute(:metrics_flush_timer, @redis_config.flush_interval) do
    flush_api_metrics
  end

  log.info("Starting HTTP server [#{@host}:#{@port}]...")
  http_server_create_http_server(:http_server, addr: @host, port: @port, logger: log) do |server|
    server.post("/#{tag}") do |req|
      data = parse_data(req.body)
      route(data) if update_deployment_metrics(data)

      # return HTTP 200 OK response to MinIO
      [200, { 'Content-Type' => 'text/plain' }, nil]
    end
  end
end