Class: LogStash::Outputs::Monasca::MonascaLogApiClient
- Inherits:
-
Object
- Object
- LogStash::Outputs::Monasca::MonascaLogApiClient
- Defined in:
- lib/logstash/outputs/monasca/monasca_log_api_client.rb
Constant Summary collapse
- SUPPORTED_API_VERSION =
%w(3.0)
Instance Method Summary collapse
-
#initialize(host, version) ⇒ MonascaLogApiClient
constructor
A new instance of MonascaLogApiClient.
- #send_logs(logs, auth_token) ⇒ Object
Constructor Details
#initialize(host, version) ⇒ MonascaLogApiClient
Returns a new instance of MonascaLogApiClient.
31 32 33 34 35 36 |
# File 'lib/logstash/outputs/monasca/monasca_log_api_client.rb', line 31 def initialize(host, version) @logger = Cabin::Channel.get(LogStash) rest_client_url = LogStash::Outputs::Helper::UrlHelper .generate_url(host, '/' + check_version(version)).to_s @rest_client = RestClient::Resource.new(rest_client_url) end |
Instance Method Details
#send_logs(logs, auth_token) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/logstash/outputs/monasca/monasca_log_api_client.rb', line 38 def send_logs(logs, auth_token) begin post_header = { 'X-Auth-Token' => auth_token, 'Content-Type' => 'application/json', } request(logs.to_json, post_header) rescue => e @logger.warn('Sending event to monasca-log-api threw exception', :exceptionew => e) end end |