prometheus-config-builder 0.0.40 → 0.0.41
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
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 3574ad59107c1c4fc456b503ff1bc457910fc03726415ac13a6e2c0758dff438
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 46a9834fa8b808557b034494509af311492beb3b187f253fe6f6bc285e3d5058
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 758050db5fa1ae8674fce4edeb778024f33e345240359b9ca8de5cb5b04a30b12a3c96fb6f35469425fcb22204523841e52f1d6e263531d9e6546f1f395c72b3
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 1114ab1112acfeac569b950c939b1c9627783aeb3222380e88aa02b0fb3591d5d0dab4ef928acb4fb606d188063cdae30563403319b5f1fe915d41e8fb985096
         
     | 
| 
         @@ -19,6 +19,7 @@ require 'prometheus-config-builder' 
     | 
|
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
            config = {}
         
     | 
| 
       21 
21 
     | 
    
         
             
            config[:paths] ||= []
         
     | 
| 
      
 22 
     | 
    
         
            +
            config[:bucket_region] ||= ''
         
     | 
| 
       22 
23 
     | 
    
         
             
            config[:root] ||= 'test/data'
         
     | 
| 
       23 
24 
     | 
    
         
             
            config[:every] = 60
         
     | 
| 
       24 
25 
     | 
    
         
             
            config[:pgrep] = nil
         
     | 
| 
         @@ -35,6 +36,9 @@ op = OptionParser.new do |o| 
     | 
|
| 
       35 
36 
     | 
    
         
             
              o.on('--path=[PATH]', 'Directory or S3 location for individual config yaml files. Can be set multiple times') do |arg|
         
     | 
| 
       36 
37 
     | 
    
         
             
                config[:paths] << arg
         
     | 
| 
       37 
38 
     | 
    
         
             
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
              o.on('--bucket_region=[BUCKET_REGION]', 'Ther region where the s3 bucket exists') do |arg|
         
     | 
| 
      
 40 
     | 
    
         
            +
                config[:bucket_region] << arg
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
       38 
42 
     | 
    
         
             
              o.on('--http PORT', Integer,
         
     | 
| 
       39 
43 
     | 
    
         
             
                'Port to listen on for http for Prometheus /metrics api') do |port|
         
     | 
| 
       40 
44 
     | 
    
         
             
                abort 'Invalid port' if port < 1 || port > 65535
         
     | 
| 
         @@ -103,7 +107,7 @@ config[:paths].each do |path| 
     | 
|
| 
       103 
107 
     | 
    
         
             
              log.info("Adding path #{path} to config discovery list")
         
     | 
| 
       104 
108 
     | 
    
         
             
              builder.add_path(path)
         
     | 
| 
       105 
109 
     | 
    
         
             
            end
         
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
      
 110 
     | 
    
         
            +
            builder.add_bucket_region(config[:bucket_region])
         
     | 
| 
       107 
111 
     | 
    
         | 
| 
       108 
112 
     | 
    
         
             
            loop do
         
     | 
| 
       109 
113 
     | 
    
         
             
              starting = Time.now
         
     | 
| 
         @@ -108,7 +108,7 @@ module PrometheusConfigBuilder 
     | 
|
| 
       108 
108 
     | 
    
         | 
| 
       109 
109 
     | 
    
         
             
              class ConfigDiscover
         
     | 
| 
       110 
110 
     | 
    
         
             
                include PrometheusConfigBuilderLogger
         
     | 
| 
       111 
     | 
    
         
            -
                def discover(glob)
         
     | 
| 
      
 111 
     | 
    
         
            +
                def discover(glob, bucket_region)
         
     | 
| 
       112 
112 
     | 
    
         | 
| 
       113 
113 
     | 
    
         
             
                  files = []
         
     | 
| 
       114 
114 
     | 
    
         
             
                  if m = glob.match(/s3:\/\/([^\/]+)\/(.*)/)
         
     | 
| 
         @@ -118,7 +118,13 @@ module PrometheusConfigBuilder 
     | 
|
| 
       118 
118 
     | 
    
         
             
                    x = $VERBOSE
         
     | 
| 
       119 
119 
     | 
    
         
             
                    $VERBOSE = nil
         
     | 
| 
       120 
120 
     | 
    
         
             
                    require 'aws-sdk'
         
     | 
| 
       121 
     | 
    
         
            -
                    s3 =  
     | 
| 
      
 121 
     | 
    
         
            +
                    s3 = nil
         
     | 
| 
      
 122 
     | 
    
         
            +
                    if !bucket_region.empty?
         
     | 
| 
      
 123 
     | 
    
         
            +
                      logger.debug("bucket_region set as >#{bucket_region}<")
         
     | 
| 
      
 124 
     | 
    
         
            +
                      s3 = Aws::S3::Client.new(region: bucket_region)
         
     | 
| 
      
 125 
     | 
    
         
            +
                    else
         
     | 
| 
      
 126 
     | 
    
         
            +
                      s3 = Aws::S3::Client.new
         
     | 
| 
      
 127 
     | 
    
         
            +
                    end
         
     | 
| 
       122 
128 
     | 
    
         
             
                    $VERBOSE = x
         
     | 
| 
       123 
129 
     | 
    
         
             
                    key = []
         
     | 
| 
       124 
130 
     | 
    
         
             
                    resp = s3.list_objects_v2({
         
     | 
| 
         @@ -260,6 +266,7 @@ module PrometheusConfigBuilder 
     | 
|
| 
       260 
266 
     | 
    
         | 
| 
       261 
267 
     | 
    
         
             
                  @discoverer = ConfigDiscover.new
         
     | 
| 
       262 
268 
     | 
    
         
             
                  @paths = []
         
     | 
| 
      
 269 
     | 
    
         
            +
                  @bucket_region = ""
         
     | 
| 
       263 
270 
     | 
    
         
             
                  @last_hash = ""
         
     | 
| 
       264 
271 
     | 
    
         | 
| 
       265 
272 
     | 
    
         
             
                  @@config_files = PrometheusExporter::Client.default.register(:gauge, "prometheusconfigbuilder_config_files", "Number of found config files")
         
     | 
| 
         @@ -270,12 +277,17 @@ module PrometheusConfigBuilder 
     | 
|
| 
       270 
277 
     | 
    
         
             
                  @paths << path
         
     | 
| 
       271 
278 
     | 
    
         
             
                end
         
     | 
| 
       272 
279 
     | 
    
         | 
| 
      
 280 
     | 
    
         
            +
                def add_bucket_region(bucket_region)
         
     | 
| 
      
 281 
     | 
    
         
            +
                  @bucket_region << bucket_region
         
     | 
| 
      
 282 
     | 
    
         
            +
                end
         
     | 
| 
      
 283 
     | 
    
         
            +
             
     | 
| 
       273 
284 
     | 
    
         
             
                def write_out
         
     | 
| 
       274 
285 
     | 
    
         
             
                  hash = ""
         
     | 
| 
       275 
286 
     | 
    
         
             
                  cfs = ConfigFiles.new(@prometheus_src)
         
     | 
| 
      
 287 
     | 
    
         
            +
                  bucket_region = @bucket_region
         
     | 
| 
       276 
288 
     | 
    
         
             
                  files = []
         
     | 
| 
       277 
289 
     | 
    
         
             
                  @paths.each do |path|
         
     | 
| 
       278 
     | 
    
         
            -
                    found_files = @discoverer.discover(path)
         
     | 
| 
      
 290 
     | 
    
         
            +
                    found_files = @discoverer.discover(path, bucket_region)
         
     | 
| 
       279 
291 
     | 
    
         
             
                    logger.info("Found #{found_files.length} files from path #{path}")
         
     | 
| 
       280 
292 
     | 
    
         
             
                    files.push(*found_files)
         
     | 
| 
       281 
293 
     | 
    
         
             
                  end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: prometheus-config-builder
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.41
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Juho Mäkinen juho.makinen@gmail.com
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2024-05-08 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: aws-sdk
         
     |