fluent-plugin-lm-logs 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74ceac6a53b86efe8123cd6ec143d4839de6043815ebb10e763e2b3019122396
4
- data.tar.gz: f72441fc5646c2cdc6f602f066fca505e1bb713371a90bdbf019ea6cf07c80b0
3
+ metadata.gz: d615e41f382455dbcae73e2449a311c57bf2a9acc24e55d27127737e162a9469
4
+ data.tar.gz: e789739f1b6407674a89cb0fe6f54a91c5fdd6936158952113b53d5bf0f0a6fd
5
5
  SHA512:
6
- metadata.gz: ee9e805c8fe449abca81d6fdfff713130359c7b3cb5c246a48fc37e8f6a6a93ab25c2203c1aa5ecfb441ca0a3e7223373ebad31b2a5314660eba5ab5bb31ed0c
7
- data.tar.gz: a910b4872388fade3cf044e7f2c9e2562a23d5730a2faffc4f4daa9f942220a44c02fa3daead5e078e662eaddb8ecb27c034f3bb190324267b0b4a04e953cd87
6
+ metadata.gz: c99d630c5cf20b75afd1759ca6628dbe833e3cd3ff2d98c481651295f4dc8bae538e72dbf7f35acddcf23643385fc76e3463df35c9adb39494e2140987568733
7
+ data.tar.gz: 74d559060251b796f8ed252eab5a3df58daddf9f0cc467cefc266ff4f7b4f2944026390292b938eb8248c9cb07bd3f4abc0a039ba6c40dafb77109ad4a3fd9c1
@@ -2,10 +2,15 @@
2
2
  # under the Apache License Version 2.0.
3
3
  # This product includes software developed at LogicMonitor (https://www.logicmonitor.com).
4
4
  # Copyright 2020 LogicMonitor, Inc.
5
+ lib = File.expand_path('../lib', __FILE__)
6
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
7
+
8
+ require "fluent/plugin/version.rb"
9
+
5
10
 
6
11
  Gem::Specification.new do |spec|
7
12
  spec.name = "fluent-plugin-lm-logs"
8
- spec.version = '1.0.4'
13
+ spec.version = LmLogsFluentPlugin::VERSION
9
14
  spec.authors = ["LogicMonitor"]
10
15
  spec.email = "rubygems@logicmonitor.com"
11
16
  spec.summary = "LogicMonitor logs fluentd output plugin"
@@ -16,9 +21,10 @@ Gem::Specification.new do |spec|
16
21
  spec.metadata["source_code_uri"] = "https://github.com/logicmonitor/lm-logs-fluentd"
17
22
  spec.metadata["documentation_uri"] = "https://www.rubydoc.info/gems/lm-logs-fluentd"
18
23
 
19
- spec.files = [".gitignore", "Gemfile", "LICENSE", "README.md", "Rakefile", "fluent-plugin-lm-logs.gemspec", "lib/fluent/plugin/out_lm.rb"]
24
+ spec.files = [".gitignore", "Gemfile", "LICENSE", "README.md", "Rakefile", "fluent-plugin-lm-logs.gemspec", "lib/fluent/plugin/version.rb", "lib/fluent/plugin/out_lm.rb"]
20
25
  spec.require_paths = ["lib"]
21
26
  spec.required_ruby_version = '>= 2.0.0'
22
27
 
23
28
  spec.add_runtime_dependency "fluentd", [">= 1", "< 2"]
29
+ spec.add_runtime_dependency "net-http-persistent", '~> 4.0.1'
24
30
  end
@@ -7,9 +7,13 @@ require 'json'
7
7
  require 'openssl'
8
8
  require 'base64'
9
9
  require 'net/http'
10
+ require 'net/http/persistent'
10
11
  require 'net/https'
11
12
  require('zlib')
12
13
 
14
+ require_relative "version"
15
+
16
+
13
17
 
14
18
  module Fluent
15
19
  class LmOutput < BufferedOutput
@@ -54,12 +58,18 @@ module Fluent
54
58
  # Open sockets or files here.
55
59
  def start
56
60
  super
61
+ @http_client = Net::HTTP::Persistent.new name: "fluent-plugin-lm-logs"
62
+ @http_client.override_headers["Content-Type"] = "application/json"
63
+ @http_client.override_headers["User-Agent"] = log_source + "/" + LmLogsFluentPlugin::VERSION
64
+ @url = "https://#{@company_name}.logicmonitor.com/rest/log/ingest"
65
+ @uri = URI.parse(@url)
57
66
  end
58
67
 
59
68
  # This method is called when shutting down.
60
69
  # Shutdown the thread and close sockets or files here.
61
70
  def shutdown
62
71
  super
72
+ @http_client.shutdown
63
73
  end
64
74
 
65
75
  # This method is called when an event reaches to Fluentd.
@@ -160,22 +170,15 @@ module Fluent
160
170
  end
161
171
 
162
172
  def send_batch(events)
163
- url = "https://#{@company_name}.logicmonitor.com/rest/log/ingest"
164
173
  body = events.to_json
165
- uri = URI.parse(url)
166
174
 
167
175
  if @debug
168
- log.info "Sending #{events.length} events to logic monitor at #{url}"
176
+ log.info "Sending #{events.length} events to logic monitor at #{@url}"
169
177
  log.info "Request json #{body}"
170
178
  end
171
179
 
172
- http = Net::HTTP.new(uri.host, uri.port)
173
- http.use_ssl = true
174
-
175
- request = Net::HTTP::Post.new(uri.request_uri)
180
+ request = Net::HTTP::Post.new(@uri.request_uri)
176
181
  request['authorization'] = generate_token(events)
177
- request['Content-type'] = "application/json"
178
- request['User-Agent'] = log_source + "/" + version_id
179
182
 
180
183
  if @compression == "gzip"
181
184
  request['Content-Encoding'] = "gzip"
@@ -191,7 +194,8 @@ module Fluent
191
194
  request.each_header {|key,value| log.info "#{key} = #{value}" }
192
195
  end
193
196
 
194
- resp = http.request(request)
197
+ resp = @http_client.request @uri, request
198
+
195
199
  if @debug || (!resp.kind_of? Net::HTTPSuccess)
196
200
  log.info "Status code:#{resp.code} Request Id:#{resp.header['x-request-id']}"
197
201
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LmLogsFluentPlugin
4
+ VERSION = '1.0.5'
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-lm-logs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - LogicMonitor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-16 00:00:00.000000000 Z
11
+ date: 2023-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -30,6 +30,20 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2'
33
+ - !ruby/object:Gem::Dependency
34
+ name: net-http-persistent
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 4.0.1
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 4.0.1
33
47
  description: This output plugin sends fluentd records to the configured LogicMonitor
34
48
  account.
35
49
  email: rubygems@logicmonitor.com
@@ -44,6 +58,7 @@ files:
44
58
  - Rakefile
45
59
  - fluent-plugin-lm-logs.gemspec
46
60
  - lib/fluent/plugin/out_lm.rb
61
+ - lib/fluent/plugin/version.rb
47
62
  homepage: https://www.logicmonitor.com
48
63
  licenses:
49
64
  - Apache-2.0
@@ -65,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
80
  - !ruby/object:Gem::Version
66
81
  version: '0'
67
82
  requirements: []
68
- rubygems_version: 3.3.7
83
+ rubygems_version: 3.4.10
69
84
  signing_key:
70
85
  specification_version: 4
71
86
  summary: LogicMonitor logs fluentd output plugin