fluent-plugin-prometheus 1.0.1 → 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 +5 -5
 - data/.travis.yml +3 -2
 - data/README.md +8 -1
 - data/fluent-plugin-prometheus.gemspec +1 -1
 - data/lib/fluent/plugin/in_prometheus.rb +45 -3
 - data/lib/fluent/plugin/in_prometheus_tail_monitor.rb +1 -1
 - data/lib/fluent/plugin/prometheus.rb +1 -0
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: bc058ef050bbdee33044783899fc6af14b731d974cb5f2b827997683a82ddb85
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: aef907fc671770e55a4fb1cad4de41b09c6a0b053b6fbcc5fbde8193d71faa0d
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 4888508f00beb7f8654e7139f1d26962e1f3a2193b81a97b4f874a61d82ea759bde7f14558fba123565a01758478d6e30aad46937e7715bed8489099424579de
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: ea29389ae6b63bf8a8f20124d7cd8651f88dbe45db66e40a74eecc2ce73762f400385ae73adf8074a2e8733cb132340233f282cb1d27aecfb627fbdd7e9bd468
         
     | 
    
        data/.travis.yml
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -73,9 +73,11 @@ Current exposed metrics: 
     | 
|
| 
       73 
73 
     | 
    
         | 
| 
       74 
74 
     | 
    
         
             
            With following configuration, those metrics are collected.
         
     | 
| 
       75 
75 
     | 
    
         | 
| 
      
 76 
     | 
    
         
            +
            ```
         
     | 
| 
       76 
77 
     | 
    
         
             
            <source>
         
     | 
| 
       77 
78 
     | 
    
         
             
              @type prometheus_monitor
         
     | 
| 
       78 
79 
     | 
    
         
             
            </source>
         
     | 
| 
      
 80 
     | 
    
         
            +
            ```
         
     | 
| 
       79 
81 
     | 
    
         | 
| 
       80 
82 
     | 
    
         
             
            More configuration parameters:
         
     | 
| 
       81 
83 
     | 
    
         | 
| 
         @@ -107,9 +109,11 @@ Current exposed metrics: 
     | 
|
| 
       107 
109 
     | 
    
         | 
| 
       108 
110 
     | 
    
         
             
            With following configuration, those metrics are collected.
         
     | 
| 
       109 
111 
     | 
    
         | 
| 
      
 112 
     | 
    
         
            +
            ```
         
     | 
| 
       110 
113 
     | 
    
         
             
            <source>
         
     | 
| 
       111 
114 
     | 
    
         
             
              @type prometheus_output_monitor
         
     | 
| 
       112 
115 
     | 
    
         
             
            </source>
         
     | 
| 
      
 116 
     | 
    
         
            +
            ```
         
     | 
| 
       113 
117 
     | 
    
         | 
| 
       114 
118 
     | 
    
         
             
            More configuration parameters:
         
     | 
| 
       115 
119 
     | 
    
         | 
| 
         @@ -139,9 +143,11 @@ Default labels: 
     | 
|
| 
       139 
143 
     | 
    
         | 
| 
       140 
144 
     | 
    
         
             
            With following configuration, those metrics are collected.
         
     | 
| 
       141 
145 
     | 
    
         | 
| 
      
 146 
     | 
    
         
            +
            ```
         
     | 
| 
       142 
147 
     | 
    
         
             
            <source>
         
     | 
| 
       143 
148 
     | 
    
         
             
              @type prometheus_tail_monitor
         
     | 
| 
       144 
149 
     | 
    
         
             
            </source>
         
     | 
| 
      
 150 
     | 
    
         
            +
            ```
         
     | 
| 
       145 
151 
     | 
    
         | 
| 
       146 
152 
     | 
    
         
             
            More configuration parameters:
         
     | 
| 
       147 
153 
     | 
    
         | 
| 
         @@ -340,9 +346,10 @@ Reserved placeholders are: 
     | 
|
| 
       340 
346 
     | 
    
         
             
            - `${hostname}`: hostname
         
     | 
| 
       341 
347 
     | 
    
         
             
            - `${worker_id}`: fluent worker id
         
     | 
| 
       342 
348 
     | 
    
         
             
            - `${tag}`: tag name
         
     | 
| 
      
 349 
     | 
    
         
            +
              - only availabe in prometheus output/filter plugin
         
     | 
| 
       343 
350 
     | 
    
         | 
| 
       344 
351 
     | 
    
         | 
| 
       345 
     | 
    
         
            -
            ### top- 
     | 
| 
      
 352 
     | 
    
         
            +
            ### top-level labels and labels inside metric
         
     | 
| 
       346 
353 
     | 
    
         | 
| 
       347 
354 
     | 
    
         
             
            Prometheus output/filter plugin can have multiple metric section. Top-level labels section spcifies labels for all metrics. Labels section insede metric section specifis labels for the metric. Both are specified, labels are merged.
         
     | 
| 
       348 
355 
     | 
    
         | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            Gem::Specification.new do |spec|
         
     | 
| 
       2 
2 
     | 
    
         
             
              spec.name          = "fluent-plugin-prometheus"
         
     | 
| 
       3 
     | 
    
         
            -
              spec.version       = "1.0 
     | 
| 
      
 3 
     | 
    
         
            +
              spec.version       = "1.1.0"
         
     | 
| 
       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.}
         
     | 
| 
         @@ -12,6 +12,23 @@ module Fluent::Plugin 
     | 
|
| 
       12 
12 
     | 
    
         
             
                config_param :port, :integer, default: 24231
         
     | 
| 
       13 
13 
     | 
    
         
             
                config_param :metrics_path, :string, default: '/metrics'
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
      
 15 
     | 
    
         
            +
                desc 'Enable ssl configuration for the server'
         
     | 
| 
      
 16 
     | 
    
         
            +
                config_section :ssl, required: false, multi: false do
         
     | 
| 
      
 17 
     | 
    
         
            +
                  config_param :enable, :bool, default: false
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                  desc 'Path to the ssl certificate in PEM format.  Read from file and added to conf as "SSLCertificate"'
         
     | 
| 
      
 20 
     | 
    
         
            +
                  config_param :certificate_path, :string, default: nil
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  desc 'Path to the ssl private key in PEM format.  Read from file and added to conf as "SSLPrivateKey"'
         
     | 
| 
      
 23 
     | 
    
         
            +
                  config_param :private_key_path, :string, default: nil
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  desc 'Path to CA in PEM format.  Read from file and added to conf as "SSLCACertificateFile"'
         
     | 
| 
      
 26 
     | 
    
         
            +
                  config_param :ca_path, :string, default: nil
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  desc 'Additional ssl conf for the server.  Ref: https://github.com/ruby/webrick/blob/master/lib/webrick/ssl.rb'
         
     | 
| 
      
 29 
     | 
    
         
            +
                  config_param :extra_conf, :hash, default: {:SSLCertName => [['CN','nobody'],['DC','example']]}, symbolize_keys: true
         
     | 
| 
      
 30 
     | 
    
         
            +
                end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
       15 
32 
     | 
    
         
             
                attr_reader :registry
         
     | 
| 
       16 
33 
     | 
    
         | 
| 
       17 
34 
     | 
    
         
             
                def initialize
         
     | 
| 
         @@ -30,15 +47,40 @@ module Fluent::Plugin 
     | 
|
| 
       30 
47 
     | 
    
         | 
| 
       31 
48 
     | 
    
         
             
                def start
         
     | 
| 
       32 
49 
     | 
    
         
             
                  super
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
50 
     | 
    
         
             
                  log.debug "listening prometheus http server on http://#{@bind}:#{@port}/#{@metrics_path} for worker#{fluentd_worker_id}"
         
     | 
| 
       35 
     | 
    
         
            -
                   
     | 
| 
      
 51 
     | 
    
         
            +
                  config = {
         
     | 
| 
       36 
52 
     | 
    
         
             
                    BindAddress: @bind,
         
     | 
| 
       37 
53 
     | 
    
         
             
                    Port: @port,
         
     | 
| 
       38 
54 
     | 
    
         
             
                    MaxClients: 5,
         
     | 
| 
       39 
55 
     | 
    
         
             
                    Logger: WEBrick::Log.new(STDERR, WEBrick::Log::FATAL),
         
     | 
| 
       40 
56 
     | 
    
         
             
                    AccessLog: [],
         
     | 
| 
       41 
     | 
    
         
            -
                   
     | 
| 
      
 57 
     | 
    
         
            +
                  }
         
     | 
| 
      
 58 
     | 
    
         
            +
                  unless @ssl.nil? || !@ssl['enable']
         
     | 
| 
      
 59 
     | 
    
         
            +
                    require 'webrick/https'
         
     | 
| 
      
 60 
     | 
    
         
            +
                    require 'openssl'
         
     | 
| 
      
 61 
     | 
    
         
            +
                    if (@ssl['certificate_path'] && @ssl['private_key_path'].nil?) || (@ssl['certificate_path'].nil? && @ssl['private_key_path'])
         
     | 
| 
      
 62 
     | 
    
         
            +
                        raise RuntimeError.new("certificate_path and private_key_path most both be defined")
         
     | 
| 
      
 63 
     | 
    
         
            +
                    end
         
     | 
| 
      
 64 
     | 
    
         
            +
                    ssl_config = {
         
     | 
| 
      
 65 
     | 
    
         
            +
                        SSLEnable: true
         
     | 
| 
      
 66 
     | 
    
         
            +
                    }
         
     | 
| 
      
 67 
     | 
    
         
            +
                    if @ssl['certificate_path']
         
     | 
| 
      
 68 
     | 
    
         
            +
                      cert = OpenSSL::X509::Certificate.new(File.read(@ssl['certificate_path']))
         
     | 
| 
      
 69 
     | 
    
         
            +
                      ssl_config[:SSLCertificate] = cert
         
     | 
| 
      
 70 
     | 
    
         
            +
                    end
         
     | 
| 
      
 71 
     | 
    
         
            +
                    if @ssl['private_key_path']
         
     | 
| 
      
 72 
     | 
    
         
            +
                      key = OpenSSL::PKey::RSA.new(File.read(@ssl['private_key_path']))
         
     | 
| 
      
 73 
     | 
    
         
            +
                      ssl_config[:SSLPrivateKey] = key
         
     | 
| 
      
 74 
     | 
    
         
            +
                    end
         
     | 
| 
      
 75 
     | 
    
         
            +
                    ssl_config[:SSLCACertificateFile] = @ssl['ca_path'] if @ssl['ca_path']
         
     | 
| 
      
 76 
     | 
    
         
            +
                    ssl_config = ssl_config.merge(@ssl['extra_conf'])
         
     | 
| 
      
 77 
     | 
    
         
            +
                    config = ssl_config.merge(config)
         
     | 
| 
      
 78 
     | 
    
         
            +
                  end
         
     | 
| 
      
 79 
     | 
    
         
            +
                  @log.on_debug do
         
     | 
| 
      
 80 
     | 
    
         
            +
                    @log.debug("WEBrick conf: #{config}")
         
     | 
| 
      
 81 
     | 
    
         
            +
                  end
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                  @server = WEBrick::HTTPServer.new(config)
         
     | 
| 
       42 
84 
     | 
    
         
             
                  @server.mount(@metrics_path, MonitorServlet, self)
         
     | 
| 
       43 
85 
     | 
    
         
             
                  thread_create(:in_prometheus) do
         
     | 
| 
       44 
86 
     | 
    
         
             
                    @server.start
         
     | 
| 
         @@ -69,7 +69,7 @@ module Fluent::Plugin 
     | 
|
| 
       69 
69 
     | 
    
         
             
                    tails = info['instance_variables'][:tails]
         
     | 
| 
       70 
70 
     | 
    
         
             
                    next if tails.nil?
         
     | 
| 
       71 
71 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
                    tails.each do |_, watcher|
         
     | 
| 
      
 72 
     | 
    
         
            +
                    tails.clone.each do |_, watcher|
         
     | 
| 
       73 
73 
     | 
    
         
             
                      # Access to internal variable of internal class...
         
     | 
| 
       74 
74 
     | 
    
         
             
                      # Very fragile implementation
         
     | 
| 
       75 
75 
     | 
    
         
             
                      pe = watcher.instance_variable_get(:@pe)
         
     | 
    
        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 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.1.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Masahiro Sano
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2018- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2018-09-09 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: fluentd
         
     | 
| 
         @@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       151 
151 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       152 
152 
     | 
    
         
             
            requirements: []
         
     | 
| 
       153 
153 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       154 
     | 
    
         
            -
            rubygems_version: 2.6 
     | 
| 
      
 154 
     | 
    
         
            +
            rubygems_version: 2.7.6
         
     | 
| 
       155 
155 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       156 
156 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       157 
157 
     | 
    
         
             
            summary: A fluent plugin that collects metrics and exposes for Prometheus.
         
     |