fluent-plugin-lm-logs 1.0.4 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/fluent-plugin-lm-logs.gemspec +8 -2
- data/lib/fluent/plugin/out_lm.rb +23 -12
- data/lib/fluent/plugin/version.rb +5 -0
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b7c2e1fc4c9c42e768327c9dead6b9eaa9f8a77b44ea7697b51306617e2702a
|
4
|
+
data.tar.gz: 4aee4bdb365b8c7efd52c2aa33ed8d5b0f83cb3ca7e551986062721b33faea24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f96d200ceb54255e82e09248179b442032c96a1f6bf28efeb410a8a5b4f9423ad5c08815f71cc9a47b2f03c9bbaeef258cdfe52b435b168e65cdaa0bb832adbd
|
7
|
+
data.tar.gz: 8dbfcce551188386379bb479021e24dc8b027f6edba4fd0f87ef17ef4eda1535010a0eaf5ca973fda304cfed339a4b0e53306e9fda012336686cc70c75d5b868
|
data/README.md
CHANGED
@@ -71,6 +71,7 @@ See the [LogicMonitor Helm repository](https://github.com/logicmonitor/k8s-helm-
|
|
71
71
|
| `force_encoding` | Specify charset when logs contains invalid utf-8 characters. |
|
72
72
|
| `include_metadata` | When `true`, appends additional metadata to the log. default `false`. |
|
73
73
|
| `device_less_logs` | When `true`, do not map log with any resource. record must have `service` when `true`. default `false`. |
|
74
|
+
| `http_proxy` | http proxy string eg. `http://user:pass@proxy.server:port`. Default `nil` |
|
74
75
|
|
75
76
|
|
76
77
|
|
@@ -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 =
|
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
|
data/lib/fluent/plugin/out_lm.rb
CHANGED
@@ -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
|
@@ -42,6 +46,8 @@ module Fluent
|
|
42
46
|
config_param :version_id, :string, :default => "version_id"
|
43
47
|
|
44
48
|
config_param :device_less_logs, :bool, :default => false
|
49
|
+
|
50
|
+
config_param :http_proxy, :string, :default => nil
|
45
51
|
|
46
52
|
# This method is called before starting.
|
47
53
|
# 'conf' is a Hash that includes configuration parameters.
|
@@ -54,12 +60,24 @@ module Fluent
|
|
54
60
|
# Open sockets or files here.
|
55
61
|
def start
|
56
62
|
super
|
63
|
+
proxy_uri = :ENV
|
64
|
+
if @http_proxy
|
65
|
+
proxy_uri = URI.parse(http_proxy)
|
66
|
+
elsif ENV['HTTP_PROXY'] || ENV['http_proxy']
|
67
|
+
log.info("Using HTTP proxy defined in environment variable")
|
68
|
+
end
|
69
|
+
@http_client = Net::HTTP::Persistent.new name: "fluent-plugin-lm-logs", proxy: proxy_uri
|
70
|
+
@http_client.override_headers["Content-Type"] = "application/json"
|
71
|
+
@http_client.override_headers["User-Agent"] = log_source + "/" + LmLogsFluentPlugin::VERSION
|
72
|
+
@url = "https://#{@company_name}.logicmonitor.com/rest/log/ingest"
|
73
|
+
@uri = URI.parse(@url)
|
57
74
|
end
|
58
75
|
|
59
76
|
# This method is called when shutting down.
|
60
77
|
# Shutdown the thread and close sockets or files here.
|
61
78
|
def shutdown
|
62
79
|
super
|
80
|
+
@http_client.shutdown
|
63
81
|
end
|
64
82
|
|
65
83
|
# This method is called when an event reaches to Fluentd.
|
@@ -160,22 +178,15 @@ module Fluent
|
|
160
178
|
end
|
161
179
|
|
162
180
|
def send_batch(events)
|
163
|
-
url = "https://#{@company_name}.logicmonitor.com/rest/log/ingest"
|
164
181
|
body = events.to_json
|
165
|
-
uri = URI.parse(url)
|
166
182
|
|
167
183
|
if @debug
|
168
|
-
log.info "Sending #{events.length} events to logic monitor at #{url}"
|
184
|
+
log.info "Sending #{events.length} events to logic monitor at #{@url}"
|
169
185
|
log.info "Request json #{body}"
|
170
186
|
end
|
171
187
|
|
172
|
-
|
173
|
-
http.use_ssl = true
|
174
|
-
|
175
|
-
request = Net::HTTP::Post.new(uri.request_uri)
|
188
|
+
request = Net::HTTP::Post.new(@uri.request_uri)
|
176
189
|
request['authorization'] = generate_token(events)
|
177
|
-
request['Content-type'] = "application/json"
|
178
|
-
request['User-Agent'] = log_source + "/" + version_id
|
179
190
|
|
180
191
|
if @compression == "gzip"
|
181
192
|
request['Content-Encoding'] = "gzip"
|
@@ -191,9 +202,9 @@ module Fluent
|
|
191
202
|
request.each_header {|key,value| log.info "#{key} = #{value}" }
|
192
203
|
end
|
193
204
|
|
194
|
-
resp =
|
195
|
-
if @debug || (!resp.kind_of?
|
196
|
-
log.info "Status code:#{resp.code} Request Id:#{resp.header['x-request-id']}"
|
205
|
+
resp = @http_client.request @uri, request
|
206
|
+
if @debug || resp.kind_of?(Net::HTTPMultiStatus) || !resp.kind_of?(Net::HTTPSuccess)
|
207
|
+
log.info "Status code:#{resp.code} Request Id:#{resp.header['x-request-id']} message:#{resp.body}"
|
197
208
|
end
|
198
209
|
end
|
199
210
|
|
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
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LogicMonitor
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-21 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,13 +58,14 @@ 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
|
50
65
|
metadata:
|
51
66
|
source_code_uri: https://github.com/logicmonitor/lm-logs-fluentd
|
52
67
|
documentation_uri: https://www.rubydoc.info/gems/lm-logs-fluentd
|
53
|
-
post_install_message:
|
68
|
+
post_install_message:
|
54
69
|
rdoc_options: []
|
55
70
|
require_paths:
|
56
71
|
- lib
|
@@ -65,8 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
80
|
- !ruby/object:Gem::Version
|
66
81
|
version: '0'
|
67
82
|
requirements: []
|
68
|
-
rubygems_version: 3.
|
69
|
-
signing_key:
|
83
|
+
rubygems_version: 3.4.10
|
84
|
+
signing_key:
|
70
85
|
specification_version: 4
|
71
86
|
summary: LogicMonitor logs fluentd output plugin
|
72
87
|
test_files: []
|