fluent-plugin-lm-logs 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/fluent/plugin/out_lm.rb +42 -15
- data/lib/fluent/plugin/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19349cb3a0b92808dbf10c877ddefd7afae737fd2b643de6fb4c9b44b613dd08
|
4
|
+
data.tar.gz: 5cd7858230f353def6da39d4a3669ff236560149deb0a7ea32f344eb8d67430b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40af1f578e4307a26dce585dd5817f131fcc938cb8a16561441069960950e90a6f5db7abb5af79e091be39ed9f8eab273df33fcc64fc37a71d8d5830e2eabf79
|
7
|
+
data.tar.gz: b14b17c709c137a1b35b7043faa32bde3ede821036d22732de429757e5c70f187b82094069adeefd60a974923d4b1623ea4b0a6b6ce3e6a46b1e1e9d7f0cba4c
|
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
|
|
data/lib/fluent/plugin/out_lm.rb
CHANGED
@@ -25,9 +25,9 @@ module Fluent
|
|
25
25
|
|
26
26
|
# config_param defines a parameter. You can refer a parameter via @path instance variable
|
27
27
|
|
28
|
-
config_param :access_id, :string, :default =>
|
28
|
+
config_param :access_id, :string, :default => nil
|
29
29
|
|
30
|
-
config_param :access_key, :string, :default =>
|
30
|
+
config_param :access_key, :string, :default => nil, secret: true
|
31
31
|
|
32
32
|
config_param :company_name, :string, :default => "company_name"
|
33
33
|
|
@@ -46,7 +46,12 @@ module Fluent
|
|
46
46
|
config_param :version_id, :string, :default => "version_id"
|
47
47
|
|
48
48
|
config_param :device_less_logs, :bool, :default => false
|
49
|
+
|
50
|
+
config_param :http_proxy, :string, :default => nil
|
49
51
|
|
52
|
+
# Use bearer token for auth.
|
53
|
+
config_param :bearer_token, :string, :default => nil, secret: true
|
54
|
+
|
50
55
|
# This method is called before starting.
|
51
56
|
# 'conf' is a Hash that includes configuration parameters.
|
52
57
|
# If the configuration is invalid, raise Fluent::ConfigError.
|
@@ -58,13 +63,31 @@ module Fluent
|
|
58
63
|
# Open sockets or files here.
|
59
64
|
def start
|
60
65
|
super
|
61
|
-
|
66
|
+
configure_auth
|
67
|
+
proxy_uri = :ENV
|
68
|
+
if @http_proxy
|
69
|
+
proxy_uri = URI.parse(http_proxy)
|
70
|
+
elsif ENV['HTTP_PROXY'] || ENV['http_proxy']
|
71
|
+
log.info("Using HTTP proxy defined in environment variable")
|
72
|
+
end
|
73
|
+
@http_client = Net::HTTP::Persistent.new name: "fluent-plugin-lm-logs", proxy: proxy_uri
|
62
74
|
@http_client.override_headers["Content-Type"] = "application/json"
|
63
75
|
@http_client.override_headers["User-Agent"] = log_source + "/" + LmLogsFluentPlugin::VERSION
|
64
76
|
@url = "https://#{@company_name}.logicmonitor.com/rest/log/ingest"
|
65
77
|
@uri = URI.parse(@url)
|
66
78
|
end
|
67
79
|
|
80
|
+
def configure_auth
|
81
|
+
@use_bearer_instead_of_lmv1 = false
|
82
|
+
if @access_id == nil || @access_key == nil
|
83
|
+
log.info "Access Id or access key null. Using bearer token for authentication."
|
84
|
+
@use_bearer_instead_of_lmv1 = true
|
85
|
+
end
|
86
|
+
if @use_bearer_instead_of_lmv1 && @bearer_token == nil
|
87
|
+
log.error "Bearer token not specified. Either access_id and access_key both or bearer_token must be specified for authentication with Logicmonitor."
|
88
|
+
raise ArgumentError, 'No valid authentication specified. Either access_id and access_key both or bearer_token must be specified for authentication with Logicmonitor.'
|
89
|
+
end
|
90
|
+
end
|
68
91
|
# This method is called when shutting down.
|
69
92
|
# Shutdown the thread and close sockets or files here.
|
70
93
|
def shutdown
|
@@ -195,23 +218,27 @@ module Fluent
|
|
195
218
|
end
|
196
219
|
|
197
220
|
resp = @http_client.request @uri, request
|
198
|
-
|
199
|
-
|
200
|
-
log.info "Status code:#{resp.code} Request Id:#{resp.header['x-request-id']}"
|
221
|
+
if @debug || resp.kind_of?(Net::HTTPMultiStatus) || !resp.kind_of?(Net::HTTPSuccess)
|
222
|
+
log.info "Status code:#{resp.code} Request Id:#{resp.header['x-request-id']} message:#{resp.body}"
|
201
223
|
end
|
202
224
|
end
|
203
225
|
|
204
226
|
|
205
227
|
def generate_token(events)
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
228
|
+
|
229
|
+
if @use_bearer_instead_of_lmv1
|
230
|
+
return "Bearer #{@bearer_token}"
|
231
|
+
else
|
232
|
+
timestamp = DateTime.now.strftime('%Q')
|
233
|
+
signature = Base64.strict_encode64(
|
234
|
+
OpenSSL::HMAC.hexdigest(
|
235
|
+
OpenSSL::Digest.new('sha256'),
|
236
|
+
@access_key,
|
237
|
+
"POST#{timestamp}#{events.to_json}/log/ingest"
|
238
|
+
)
|
239
|
+
)
|
240
|
+
return "LMv1 #{@access_id}:#{signature}:#{timestamp}"
|
241
|
+
end
|
215
242
|
end
|
216
243
|
end
|
217
244
|
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
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LogicMonitor
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -65,7 +65,7 @@ licenses:
|
|
65
65
|
metadata:
|
66
66
|
source_code_uri: https://github.com/logicmonitor/lm-logs-fluentd
|
67
67
|
documentation_uri: https://www.rubydoc.info/gems/lm-logs-fluentd
|
68
|
-
post_install_message:
|
68
|
+
post_install_message:
|
69
69
|
rdoc_options: []
|
70
70
|
require_paths:
|
71
71
|
- lib
|
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
83
|
rubygems_version: 3.4.10
|
84
|
-
signing_key:
|
84
|
+
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: LogicMonitor logs fluentd output plugin
|
87
87
|
test_files: []
|