Class: Chef::Handler::Graylog::Sender::Http
- Inherits:
-
Chef::HTTP::BasicClient
- Object
- Chef::HTTP::BasicClient
- Chef::Handler::Graylog::Sender::Http
show all
- Defined in:
- lib/chef/handler/graylog/sender/http.rb
Defined Under Namespace
Classes: GraylogSSLPolicy
Instance Method Summary
collapse
Constructor Details
#initialize(url, config = {}) ⇒ Http
Returns a new instance of Http.
31
32
33
34
|
# File 'lib/chef/handler/graylog/sender/http.rb', line 31
def initialize(url, config = {})
@config = config
super(URI.parse(url), :ssl_policy => GraylogSSLPolicy)
end
|
Instance Method Details
#config ⇒ Object
36
37
38
39
|
# File 'lib/chef/handler/graylog/sender/http.rb', line 36
def config
{:rest_timeout => @config[:timeout] || 1}
end
|
41
42
43
44
|
# File 'lib/chef/handler/graylog/sender/http.rb', line 41
def configure_ssl(http_client)
http_client.use_ssl = true
ssl_policy.apply_to(http_client, @config)
end
|
#send_payload(message) ⇒ Object
46
47
48
49
50
|
# File 'lib/chef/handler/graylog/sender/http.rb', line 46
def send_payload(message)
request(:POST, url, JSON.dump(message.to_hash), 'X-Graylog-Chef-Handler-Version' => Graylog::VERSION)
rescue => e
Chef::Log.error("[#{self.class}] Sending GELF message failed: #{e.message}")
end
|