fluent-plugin-grafana-loki 1.2.20 → 1.3.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 +5 -1
- data/lib/fluent/plugin/out_loki.rb +78 -5
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 392322f21a178f97e079ce0a9c0fff34f1ace1d13321b1a720d060cbd96171c3
|
|
4
|
+
data.tar.gz: b4e6fff6f38c344069ba407a191ca90cfb33a76f79ff1b8e969859ccb8cfba2e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 77aadf99e24c00616cb7089b8cf156517572ca23e7582233a85c6dff476c33e38a022d57cc0d09b80e5697500fce8b2c4c2bec45eab8622820bc8e2c86519f66
|
|
7
|
+
data.tar.gz: 1e9bcc0b0b89e33683d3574c750c6c37d50a109577b2f082b5d0921a5ae0004e4245899c48503ad01f87be00216fd6f7a3f0f9ecf35e7e676cc3f44c9310afea
|
data/README.md
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
[Fluentd](https://fluentd.org/) is a data collector for unified logging layer, it can be configured with the Loki output plugin, provided in this folder, to ship logs to Loki.
|
|
4
4
|
|
|
5
|
-
See [
|
|
5
|
+
See the [Fluentd documentation](../../../docs/sources/send-data/fluentd/_index.md) for detailed information.
|
|
6
|
+
|
|
7
|
+
## Client certificates (mTLS)
|
|
8
|
+
|
|
9
|
+
For mutual TLS in front of Loki, configure `cert`, `key`, and optionally `ca_cert`. A PEM `cert` file may include the leaf plus intermediate chain; **sending the full chain requires Ruby 3.0+**. See [Client certificate verification](../../../docs/sources/send-data/fluentd/_index.md#client-certificate-verification) in the Loki docs.
|
|
6
10
|
|
|
7
11
|
## Development
|
|
8
12
|
|
|
@@ -18,8 +18,11 @@
|
|
|
18
18
|
require 'fluent/env'
|
|
19
19
|
require 'fluent/plugin/output'
|
|
20
20
|
require 'net/http'
|
|
21
|
+
require 'rubygems/version'
|
|
21
22
|
require 'yajl'
|
|
22
23
|
require 'time'
|
|
24
|
+
require 'zlib'
|
|
25
|
+
require 'stringio'
|
|
23
26
|
|
|
24
27
|
module Fluent
|
|
25
28
|
module Plugin
|
|
@@ -45,16 +48,28 @@ module Fluent
|
|
|
45
48
|
desc 'Authentication: Authorization header with Bearer token scheme'
|
|
46
49
|
config_param :bearer_token_file, :string, default: nil
|
|
47
50
|
|
|
48
|
-
desc 'TLS:
|
|
51
|
+
desc 'TLS: client certificate file (PEM). May contain multiple PEM blocks (leaf plus intermediate chain); full chain is sent only on Ruby 3.0+.'
|
|
49
52
|
config_param :cert, :string, default: nil
|
|
50
53
|
config_param :key, :string, default: nil
|
|
51
54
|
|
|
52
55
|
desc 'TLS: CA certificate file for server certificate verification'
|
|
53
56
|
config_param :ca_cert, :string, default: nil
|
|
54
57
|
|
|
58
|
+
desc 'TLS: the ciphers to use for the tls connection (e.g TLS1_0, TLS1_1, TLS1_2)'
|
|
59
|
+
config_param :ciphers, :string, default: nil
|
|
60
|
+
|
|
61
|
+
desc 'TLS: The minimum version for the tls connection'
|
|
62
|
+
config_param :min_version, :string, default: nil
|
|
63
|
+
|
|
55
64
|
desc 'TLS: disable server certificate verification'
|
|
56
65
|
config_param :insecure_tls, :bool, default: false
|
|
57
66
|
|
|
67
|
+
desc 'Custom HTTP headers'
|
|
68
|
+
config_param :custom_headers, :hash, default: {}
|
|
69
|
+
|
|
70
|
+
desc 'Compress HTTP request payload'
|
|
71
|
+
config_param :compress, :enum, list: %i[gzip], default: nil
|
|
72
|
+
|
|
58
73
|
desc 'Loki tenant id'
|
|
59
74
|
config_param :tenant, :string, default: nil
|
|
60
75
|
|
|
@@ -132,14 +147,43 @@ module Fluent
|
|
|
132
147
|
!@key.nil? && !@cert.nil?
|
|
133
148
|
end
|
|
134
149
|
|
|
150
|
+
# Net::HTTP exposes extra_chain_cert for the client TLS chain in Ruby 3.0+ stdlib.
|
|
151
|
+
def self.extra_chain_cert_supported?
|
|
152
|
+
Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0')
|
|
153
|
+
end
|
|
154
|
+
|
|
135
155
|
def load_client_cert
|
|
136
|
-
@
|
|
156
|
+
@extra_chain_cert = nil
|
|
157
|
+
if @cert
|
|
158
|
+
raw = File.read(@cert)
|
|
159
|
+
pem_certs = raw.scan(/-----BEGIN CERTIFICATE-----.+?-----END CERTIFICATE-----/m)
|
|
160
|
+
if pem_certs.empty?
|
|
161
|
+
# No PEM blocks found - fall back to OpenSSL's native parsing,
|
|
162
|
+
# which handles DER-encoded (binary) certificates.
|
|
163
|
+
@cert = OpenSSL::X509::Certificate.new(raw)
|
|
164
|
+
else
|
|
165
|
+
# PEM file: use the first cert as the client certificate,
|
|
166
|
+
# and any remaining certs as the intermediate CA chain (Ruby 3.0+ only).
|
|
167
|
+
@cert = OpenSSL::X509::Certificate.new(pem_certs[0])
|
|
168
|
+
remaining = pem_certs[1..]
|
|
169
|
+
if !remaining.empty?
|
|
170
|
+
if self.class.extra_chain_cert_supported?
|
|
171
|
+
@extra_chain_cert = remaining.map { |c| OpenSSL::X509::Certificate.new(c) }
|
|
172
|
+
elsif !@client_cert_intermediate_chain_skipped_logged
|
|
173
|
+
@client_cert_intermediate_chain_skipped_logged = true
|
|
174
|
+
log.warn 'client certificate file contains multiple PEM blocks, but sending the intermediate chain ' \
|
|
175
|
+
'requires Ruby 3.0+. Only the leaf certificate will be presented; mTLS may fail if the ' \
|
|
176
|
+
'server requires the full chain.'
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
end
|
|
137
181
|
@key = OpenSSL::PKey.read(File.read(@key)) if @key
|
|
138
182
|
end
|
|
139
183
|
|
|
140
184
|
def validate_client_cert_key
|
|
141
185
|
if !@key.is_a?(OpenSSL::PKey::RSA) && !@key.is_a?(OpenSSL::PKey::DSA)
|
|
142
|
-
raise "Unsupported private key type #{key.class}"
|
|
186
|
+
raise "Unsupported private key type #{@key.class}"
|
|
143
187
|
end
|
|
144
188
|
end
|
|
145
189
|
|
|
@@ -183,12 +227,17 @@ module Fluent
|
|
|
183
227
|
)
|
|
184
228
|
end
|
|
185
229
|
|
|
186
|
-
# Optionally present client certificate
|
|
230
|
+
# Optionally present client certificate (with intermediate chain if available; Ruby 3.0+ only).
|
|
187
231
|
if !@cert.nil? && !@key.nil?
|
|
188
232
|
opts = opts.merge(
|
|
189
233
|
cert: @cert,
|
|
190
234
|
key: @key
|
|
191
235
|
)
|
|
236
|
+
if @extra_chain_cert && self.class.extra_chain_cert_supported?
|
|
237
|
+
opts = opts.merge(
|
|
238
|
+
extra_chain_cert: @extra_chain_cert
|
|
239
|
+
)
|
|
240
|
+
end
|
|
192
241
|
end
|
|
193
242
|
|
|
194
243
|
# For server certificate verification: set custom CA bundle.
|
|
@@ -198,6 +247,19 @@ module Fluent
|
|
|
198
247
|
ca_file: @ca_cert
|
|
199
248
|
)
|
|
200
249
|
end
|
|
250
|
+
|
|
251
|
+
if @ciphers
|
|
252
|
+
opts = opts.merge(
|
|
253
|
+
ciphers: @ciphers
|
|
254
|
+
)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
if @min_version
|
|
258
|
+
opts = opts.merge(
|
|
259
|
+
min_version: @min_version.to_sym
|
|
260
|
+
)
|
|
261
|
+
end
|
|
262
|
+
|
|
201
263
|
opts
|
|
202
264
|
end
|
|
203
265
|
|
|
@@ -213,10 +275,21 @@ module Fluent
|
|
|
213
275
|
req = Net::HTTP::Post.new(
|
|
214
276
|
@uri.request_uri
|
|
215
277
|
)
|
|
278
|
+
@custom_headers.each do |key, value|
|
|
279
|
+
req.add_field(key, value)
|
|
280
|
+
end
|
|
216
281
|
req.add_field('Content-Type', 'application/json')
|
|
217
282
|
req.add_field('Authorization', "Bearer #{@auth_token_bearer}") unless @auth_token_bearer.nil?
|
|
218
283
|
req.add_field('X-Scope-OrgID', tenant) if tenant
|
|
219
|
-
|
|
284
|
+
payload = Yajl.dump(body)
|
|
285
|
+
if @compress == :gzip
|
|
286
|
+
req.add_field('Content-Encoding', 'gzip')
|
|
287
|
+
compressed = StringIO.new
|
|
288
|
+
Zlib::GzipWriter.wrap(compressed) { |gz| gz.write(payload) }
|
|
289
|
+
req.body = compressed.string
|
|
290
|
+
else
|
|
291
|
+
req.body = payload
|
|
292
|
+
end
|
|
220
293
|
req.basic_auth(@username, @password) if @username
|
|
221
294
|
|
|
222
295
|
opts = http_request_opts(@uri)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-grafana-loki
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- woodsaj
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2026-04-01 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: fluentd
|
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
150
150
|
- !ruby/object:Gem::Version
|
|
151
151
|
version: '0'
|
|
152
152
|
requirements: []
|
|
153
|
-
rubygems_version: 3.
|
|
153
|
+
rubygems_version: 3.4.10
|
|
154
154
|
signing_key:
|
|
155
155
|
specification_version: 4
|
|
156
156
|
summary: Output plugin to ship logs to a Grafana Loki server
|