fluent-plugin-prometheus 1.0.0 → 1.0.1

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
  SHA1:
3
- metadata.gz: b6e00809503106fad10f9d831e67091e69ed56da
4
- data.tar.gz: 5f84aeff3ed1a79a6da4c7ea18a5332c02304baa
3
+ metadata.gz: 2a57fd10632488d41ca2f4fd29de81b238e35ca8
4
+ data.tar.gz: 2008368dbac8114bf331f4b35171f23fea3d0224
5
5
  SHA512:
6
- metadata.gz: 7658cc206cc8063ea61d83730b37db12a311f152a560c3c5d669c9f73dd9994c417b1a30810531d101c56821f4395f5d875fe5ef5cabb67e72948974186cdad9
7
- data.tar.gz: ac72182e9fea379125a487f521d42a29bbf354d857abf3dc778daffdec8aa8bd346d444b3ab001cbcac951fde2b72c3ad208e0e2748aa9d5a14d35b34e73e1c3
6
+ metadata.gz: 5ce7f491f1f8528f6da19b0d20eff61a0c48fa76b082d83b8a3fdcf9493355a9def2ba5dccbb07941348a0d2ef0c34a8602f002e7e02f2109df6737414f7c3c1
7
+ data.tar.gz: ed7d1d932ecc7a498279cb836860633a51916e910f315addcb3c42519ed2f3aede977871959eaebb731b3725842a88905fd628dd633477e976f545cab86185b6
data/README.md CHANGED
@@ -4,8 +4,6 @@
4
4
 
5
5
  A fluent plugin that instruments metrics from records and exposes them via web interface. Intended to be used together with a [Prometheus server](https://github.com/prometheus/prometheus).
6
6
 
7
- If you are using Fluentd v0.10, you have to explicitly install [fluent-plugin-record-reformer](https://github.com/sonots/fluent-plugin-record-reformer) together. With Fluentd v0.12 or v0.14, there is no additional dependency.
8
-
9
7
  ## Requirements
10
8
 
11
9
  | fluent-plugin-prometheus | fluentd | ruby |
@@ -61,6 +59,8 @@ More configuration parameters:
61
59
  - `port`: listen port (defaut: 24231)
62
60
  - `metrics_path`: metrics HTTP endpoint (default: /metrics)
63
61
 
62
+ When using multiple workers, each worker binds to port + `fluent_worker_id`.
63
+
64
64
  ### prometheus_monitor input plugin
65
65
 
66
66
  This plugin collects internal metrics in Fluentd. The metrics are similar to/part of [monitor_agent](http://docs.fluentd.org/articles/monitoring#monitoring-agent).
@@ -86,7 +86,7 @@ More configuration parameters:
86
86
 
87
87
  **experimental**
88
88
 
89
- This plugin collects internal metrics for output plugin in Fluentd. This is similar to `prometheus_monitor` plugin, but specialized for input plugin. There are Many metrics `prometheus_monitor` does not include, such as `num_errors`, `retry_wait` and so on.
89
+ This plugin collects internal metrics for output plugin in Fluentd. This is similar to `prometheus_monitor` plugin, but specialized for output plugin. There are Many metrics `prometheus_monitor` does not include, such as `num_errors`, `retry_wait` and so on.
90
90
 
91
91
  Current exposed metrics:
92
92
 
@@ -338,6 +338,7 @@ You can use placeholder for label values. The placeholders will be expanded from
338
338
  Reserved placeholders are:
339
339
 
340
340
  - `${hostname}`: hostname
341
+ - `${worker_id}`: fluent worker id
341
342
  - `${tag}`: tag name
342
343
 
343
344
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "fluent-plugin-prometheus"
3
- spec.version = "1.0.0"
3
+ spec.version = "1.0.1"
4
4
  spec.authors = ["Masahiro Sano"]
5
5
  spec.email = ["sabottenda@gmail.com"]
6
6
  spec.summary = %q{A fluent plugin that collects metrics and exposes for Prometheus.}
@@ -19,8 +19,19 @@ module Fluent::Plugin
19
19
  @registry = ::Prometheus::Client.registry
20
20
  end
21
21
 
22
+ def configure(conf)
23
+ super
24
+ @port += fluentd_worker_id
25
+ end
26
+
27
+ def multi_workers_ready?
28
+ true
29
+ end
30
+
22
31
  def start
23
32
  super
33
+
34
+ log.debug "listening prometheus http server on http://#{@bind}:#{@port}/#{@metrics_path} for worker#{fluentd_worker_id}"
24
35
  @server = WEBrick::HTTPServer.new(
25
36
  BindAddress: @bind,
26
37
  Port: @port,
@@ -16,11 +16,15 @@ module Fluent::Plugin
16
16
  @registry = ::Prometheus::Client.registry
17
17
  end
18
18
 
19
+ def multi_workers_ready?
20
+ true
21
+ end
22
+
19
23
  def configure(conf)
20
24
  super
21
25
  hostname = Socket.gethostname
22
26
  expander = Fluent::Plugin::Prometheus.placeholder_expander(log)
23
- placeholders = expander.prepare_placeholders({'hostname' => hostname})
27
+ placeholders = expander.prepare_placeholders({'hostname' => hostname, 'worker_id' => fluentd_worker_id})
24
28
  @base_labels = Fluent::Plugin::Prometheus.parse_labels_elements(conf)
25
29
  @base_labels.each do |key, value|
26
30
  @base_labels[key] = expander.expand(value, placeholders)
@@ -31,11 +31,15 @@ module Fluent::Plugin
31
31
  @registry = ::Prometheus::Client.registry
32
32
  end
33
33
 
34
+ def multi_workers_ready?
35
+ true
36
+ end
37
+
34
38
  def configure(conf)
35
39
  super
36
40
  hostname = Socket.gethostname
37
41
  expander = Fluent::Plugin::Prometheus.placeholder_expander(log)
38
- placeholders = expander.prepare_placeholders({'hostname' => hostname})
42
+ placeholders = expander.prepare_placeholders({'hostname' => hostname, 'worker_id' => fluentd_worker_id})
39
43
  @base_labels = Fluent::Plugin::Prometheus.parse_labels_elements(conf)
40
44
  @base_labels.each do |key, value|
41
45
  @base_labels[key] = expander.expand(value, placeholders)
@@ -20,11 +20,15 @@ module Fluent::Plugin
20
20
  @registry = ::Prometheus::Client.registry
21
21
  end
22
22
 
23
+ def multi_workers_ready?
24
+ true
25
+ end
26
+
23
27
  def configure(conf)
24
28
  super
25
29
  hostname = Socket.gethostname
26
30
  expander = Fluent::Plugin::Prometheus.placeholder_expander(log)
27
- placeholders = expander.prepare_placeholders({'hostname' => hostname})
31
+ placeholders = expander.prepare_placeholders({'hostname' => hostname, 'worker_id' => fluentd_worker_id})
28
32
  @base_labels = Fluent::Plugin::Prometheus.parse_labels_elements(conf)
29
33
  @base_labels.each do |key, value|
30
34
  @base_labels[key] = expander.expand(value, placeholders)
@@ -74,4 +74,28 @@ describe Fluent::Plugin::PrometheusInput do
74
74
  end
75
75
  end
76
76
  end
77
+
78
+ describe '#run_multi_workers' do
79
+ context '/metrics' do
80
+ Fluent::SystemConfig.overwrite_system_config('workers' => 4) do
81
+ let(:config) { CONFIG + %[
82
+ port #{port - 2}
83
+ ] }
84
+
85
+ it 'should configure port using sequential number' do
86
+ driver = Fluent::Test::Driver::Input.new(Fluent::Plugin::PrometheusInput)
87
+ driver.instance.instance_eval{ @_fluentd_worker_id = 2 }
88
+ driver.configure(config)
89
+ expect(driver.instance.port).to eq(port)
90
+ driver.run(timeout: 1) do
91
+ Net::HTTP.start("127.0.0.1", port) do |http|
92
+ req = Net::HTTP::Get.new("/metrics")
93
+ res = http.request(req)
94
+ expect(res.code).to eq('200')
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
77
101
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-prometheus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Sano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-18 00:00:00.000000000 Z
11
+ date: 2018-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd