prometheus_exporter 2.3.0 → 2.3.1
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/CHANGELOG +5 -0
- data/exe/prometheus_exporter +7 -0
- data/lib/prometheus_exporter/client.rb +34 -2
- data/lib/prometheus_exporter/middleware.rb +1 -1
- data/lib/prometheus_exporter/server/runner.rb +3 -1
- data/lib/prometheus_exporter/server/web_server.rb +13 -6
- data/lib/prometheus_exporter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c0089a6263d4775bbad13bf5714621eb7a353873468b020efc6ed216cbe6c917
|
|
4
|
+
data.tar.gz: f9676e32af68fff888a360a19f8cd55bbee2b855db11009ca3c7272eab58a449
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 790b2ac6223cfa571c4b5c3404f79844a2f41e632151424448640d74a07f36fc4cb81e6935ec86de1208498536a1a115c2b62cb918aada3513823160287db556
|
|
7
|
+
data.tar.gz: a886c589c2e6decb57301754d654593216ad502f8690095d83749dba3b70243e98ac1b9a21071270777f7a5229f1852aa73c2d64a5029426669b4c8dfdf12805
|
data/CHANGELOG
CHANGED
|
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.3.1] - 2025-11-11
|
|
9
|
+
|
|
10
|
+
- FIX: get controller full path instead of controller name - Alex Platteeuw
|
|
11
|
+
- FEATURE: Secure PrometheusExporter scraping with SSL - Nicolas Rodriquez
|
|
12
|
+
|
|
8
13
|
## [2.3.0] - 2025-08-01
|
|
9
14
|
|
|
10
15
|
- FEATURE: Added puma_busy_threads metric that provides a holistic view of server workload by calculating (active threads - idle threads) + queued requests
|
data/exe/prometheus_exporter
CHANGED
|
@@ -71,6 +71,13 @@ def run
|
|
|
71
71
|
opt.on('--logger-path PATH', String, '(optional) Path to file for logger output. Defaults to STDERR') do |o|
|
|
72
72
|
options[:logger_path] = o
|
|
73
73
|
end
|
|
74
|
+
|
|
75
|
+
opt.on('--tls-key-file PATH', String, "(optional) Enable server TLS using a private key PATH") do |o|
|
|
76
|
+
options[:tls_key_file] = o
|
|
77
|
+
end
|
|
78
|
+
opt.on('--tls-cert-file PATH', String, "(optional) Enable server TLS using a certificate PATH") do |o|
|
|
79
|
+
options[:tls_cert_file] = o
|
|
80
|
+
end
|
|
74
81
|
end.parse!
|
|
75
82
|
|
|
76
83
|
logger = Logger.new(options[:logger_path])
|
|
@@ -56,11 +56,15 @@ module PrometheusExporter
|
|
|
56
56
|
port: ENV.fetch("PROMETHEUS_EXPORTER_PORT", PrometheusExporter::DEFAULT_PORT),
|
|
57
57
|
max_queue_size: nil,
|
|
58
58
|
thread_sleep: 0.5,
|
|
59
|
+
connect_timeout: nil,
|
|
59
60
|
json_serializer: nil,
|
|
60
61
|
custom_labels: nil,
|
|
61
62
|
logger: Logger.new(STDERR),
|
|
62
63
|
log_level: Logger::WARN,
|
|
63
|
-
process_queue_once_and_stop: false
|
|
64
|
+
process_queue_once_and_stop: false,
|
|
65
|
+
tls_ca_file: nil,
|
|
66
|
+
tls_cert_file: nil,
|
|
67
|
+
tls_key_file: nil
|
|
64
68
|
)
|
|
65
69
|
@logger = logger
|
|
66
70
|
@logger.level = log_level
|
|
@@ -83,11 +87,18 @@ module PrometheusExporter
|
|
|
83
87
|
@worker_thread = nil
|
|
84
88
|
@mutex = Mutex.new
|
|
85
89
|
@thread_sleep = thread_sleep
|
|
90
|
+
@connect_timeout = connect_timeout
|
|
86
91
|
|
|
87
92
|
@json_serializer = json_serializer == :oj ? PrometheusExporter::OjCompat : JSON
|
|
88
93
|
|
|
89
94
|
@custom_labels = custom_labels
|
|
90
95
|
@process_queue_once_and_stop = process_queue_once_and_stop
|
|
96
|
+
|
|
97
|
+
@tls_ca_file = tls_ca_file
|
|
98
|
+
@tls_cert_file = tls_cert_file
|
|
99
|
+
@tls_key_file = tls_key_file
|
|
100
|
+
|
|
101
|
+
@ssl_context = build_ssl_context if use_ssl?
|
|
91
102
|
end
|
|
92
103
|
|
|
93
104
|
def custom_labels=(custom_labels)
|
|
@@ -228,7 +239,14 @@ module PrometheusExporter
|
|
|
228
239
|
|
|
229
240
|
close_socket_if_old!
|
|
230
241
|
if !@socket
|
|
231
|
-
@socket = TCPSocket.new @host, @port
|
|
242
|
+
@socket = TCPSocket.new @host, @port, connect_timeout: @connect_timeout
|
|
243
|
+
|
|
244
|
+
if use_ssl?
|
|
245
|
+
@socket = OpenSSL::SSL::SSLSocket.new(@socket, @ssl_context)
|
|
246
|
+
@socket.sync_close = true
|
|
247
|
+
@socket.connect
|
|
248
|
+
end
|
|
249
|
+
|
|
232
250
|
@socket.write("POST /send-metrics HTTP/1.1\r\n")
|
|
233
251
|
@socket.write("Transfer-Encoding: chunked\r\n")
|
|
234
252
|
@socket.write("Host: #{@host}\r\n")
|
|
@@ -246,6 +264,20 @@ module PrometheusExporter
|
|
|
246
264
|
raise
|
|
247
265
|
end
|
|
248
266
|
|
|
267
|
+
def use_ssl?
|
|
268
|
+
@tls_ca_file && @tls_cert_file && @tls_key_file
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
def build_ssl_context
|
|
272
|
+
require "openssl"
|
|
273
|
+
ssl_context = OpenSSL::SSL::SSLContext.new()
|
|
274
|
+
ssl_context.cert = OpenSSL::X509::Certificate.new(File.read(@tls_cert_file))
|
|
275
|
+
ssl_context.key = OpenSSL::PKey::RSA.new(File.read(@tls_key_file))
|
|
276
|
+
ssl_context.ca_file = @tls_ca_file
|
|
277
|
+
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
|
278
|
+
ssl_context
|
|
279
|
+
end
|
|
280
|
+
|
|
249
281
|
def wait_for_empty_queue_with_timeout(timeout_seconds)
|
|
250
282
|
start_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
|
|
251
283
|
while @queue.length > 0
|
|
@@ -78,7 +78,7 @@ class PrometheusExporter::Middleware
|
|
|
78
78
|
action = controller = nil
|
|
79
79
|
if controller_instance
|
|
80
80
|
action = controller_instance.action_name
|
|
81
|
-
controller = controller_instance.
|
|
81
|
+
controller = controller_instance.controller_path
|
|
82
82
|
elsif (cors = env["rack.cors"]) && cors.respond_to?(:preflight?) && cors.preflight?
|
|
83
83
|
# if the Rack CORS Middleware identifies the request as a preflight request,
|
|
84
84
|
# the stack doesn't get to the point where controllers/actions are defined
|
|
@@ -59,6 +59,8 @@ module PrometheusExporter::Server
|
|
|
59
59
|
verbose: verbose,
|
|
60
60
|
auth: auth,
|
|
61
61
|
realm: realm,
|
|
62
|
+
tls_cert_file: tls_cert_file,
|
|
63
|
+
tls_key_file: tls_key_file,
|
|
62
64
|
)
|
|
63
65
|
@server.start
|
|
64
66
|
end
|
|
@@ -67,7 +69,7 @@ module PrometheusExporter::Server
|
|
|
67
69
|
@server.stop
|
|
68
70
|
end
|
|
69
71
|
|
|
70
|
-
attr_accessor :unicorn_listen_address, :unicorn_pid_file
|
|
72
|
+
attr_accessor :unicorn_listen_address, :unicorn_pid_file, :tls_cert_file, :tls_key_file
|
|
71
73
|
attr_writer :prefix,
|
|
72
74
|
:port,
|
|
73
75
|
:bind,
|
|
@@ -62,13 +62,20 @@ module PrometheusExporter::Server
|
|
|
62
62
|
|
|
63
63
|
@collector = opts[:collector] || Collector.new(logger: @logger)
|
|
64
64
|
|
|
65
|
-
@
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
webrick_options = { Port: @port, BindAddress: @bind, Logger: @logger, AccessLog: @access_log }
|
|
66
|
+
|
|
67
|
+
if opts[:tls_cert_file] && opts[:tls_key_file]
|
|
68
|
+
require "webrick/https"
|
|
69
|
+
require "openssl"
|
|
70
|
+
|
|
71
|
+
webrick_options[:SSLEnable] = true
|
|
72
|
+
webrick_options[:SSLCertificate] = OpenSSL::X509::Certificate.new(
|
|
73
|
+
File.read(opts[:tls_cert_file]),
|
|
71
74
|
)
|
|
75
|
+
webrick_options[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(File.read(opts[:tls_key_file]))
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
@server = WEBrick::HTTPServer.new(webrick_options)
|
|
72
79
|
|
|
73
80
|
@server.mount_proc "/" do |req, res|
|
|
74
81
|
res["Content-Type"] = "text/plain; charset=utf-8"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: prometheus_exporter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.3.
|
|
4
|
+
version: 2.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sam Saffron
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-11-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: webrick
|