fluent-plugin-grafana-loki 1.2.16 → 1.2.17
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 +7 -4
- data/bin/setup +6 -4
- data/bin/test +5 -0
- data/lib/fluent/plugin/out_loki.rb +7 -6
- metadata +4 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 7314140e15cf44c0150b92442687304a8ce1f90470ddf9527a10d75603840e19
         | 
| 4 | 
            +
              data.tar.gz: 911185ef9e06820f156a763bc7ce562ff476982190b4a63658b505c278490892
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: db08e94fc3b4b3bf5ca23df7488adad1d2ed2ca9ebd6bda6da2e7119594270efe02d8c3ee6a4dbc40b478eae120fb37565ac60ea0cd9b04ebf3c73f3b507a7a2
         | 
| 7 | 
            +
              data.tar.gz: 0ceee039f2801221495c67ea1e052e92d5da5795791af218d9d5ceb3c73e8aca661cac4dba75de5c635f6ff012ac58094aecb809f77e6d6649db250d2eb91b41
         | 
    
        data/README.md
    CHANGED
    
    | @@ -6,14 +6,17 @@ See [docs/client/fluentd/README.md](../../docs/sources/clients/fluentd/_index.md | |
| 6 6 |  | 
| 7 7 | 
             
            ## Development
         | 
| 8 8 |  | 
| 9 | 
            -
            After checking out the repo, run `bin/setup` to install dependencies. Then, run ` | 
| 9 | 
            +
            After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
         | 
| 10 10 |  | 
| 11 | 
            -
            To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `fluent-plugin-grafana-loki.gemspec`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
         | 
| 11 | 
            +
            To install this gem onto your local machine, run `ruby -S bundle exec rake install`. To release a new version, update the version number in `fluent-plugin-grafana-loki.gemspec`, and then run `ruby -S bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
         | 
| 12 12 |  | 
| 13 | 
            -
            To create the gem: `gem build fluent-plugin-grafana-loki.gemspec`
         | 
| 13 | 
            +
            To create the gem: `ruby -S gem build fluent-plugin-grafana-loki.gemspec`
         | 
| 14 14 |  | 
| 15 15 | 
             
            Useful additions:
         | 
| 16 | 
            -
             | 
| 16 | 
            +
             | 
| 17 | 
            +
            ```bash
         | 
| 18 | 
            +
            ruby -S gem install rubocop
         | 
| 19 | 
            +
            ```
         | 
| 17 20 |  | 
| 18 21 | 
             
            ## Testing
         | 
| 19 22 |  | 
    
        data/bin/setup
    CHANGED
    
    | @@ -1,7 +1,9 @@ | |
| 1 1 | 
             
            #!/usr/bin/env bash
         | 
| 2 | 
            +
             | 
| 2 3 | 
             
            set -euo pipefail
         | 
| 3 | 
            -
            IFS=$'\n\t'
         | 
| 4 | 
            -
            set -vx
         | 
| 5 4 |  | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 5 | 
            +
            ruby --version
         | 
| 6 | 
            +
            echo ""
         | 
| 7 | 
            +
            ruby -S gem install bundler --version 2.3.4
         | 
| 8 | 
            +
            ruby -S bundle config set --local path $(pwd)/vendor/bundle
         | 
| 9 | 
            +
            ruby -S bundle install
         | 
    
        data/bin/test
    ADDED
    
    
| @@ -278,6 +278,8 @@ module Fluent | |
| 278 278 | 
             
                      when :key_value
         | 
| 279 279 | 
             
                        formatted_labels = []
         | 
| 280 280 | 
             
                        record.each do |k, v|
         | 
| 281 | 
            +
                          # Remove non UTF-8 characters by force-encoding the string
         | 
| 282 | 
            +
                          v = v.encode('utf-8', invalid: :replace)
         | 
| 281 283 | 
             
                          # Escape double quotes and backslashes by prefixing them with a backslash
         | 
| 282 284 | 
             
                          v = v.to_s.gsub(%r{(["\\])}, '\\\\\1')
         | 
| 283 285 | 
             
                          if v.include?(' ') || v.include?('=')
         | 
| @@ -292,7 +294,6 @@ module Fluent | |
| 292 294 | 
             
                    line
         | 
| 293 295 | 
             
                  end
         | 
| 294 296 |  | 
| 295 | 
            -
                  #
         | 
| 296 297 | 
             
                  # convert a line to loki line with labels
         | 
| 297 298 | 
             
                  def line_to_loki(record)
         | 
| 298 299 | 
             
                    chunk_labels = {}
         | 
| @@ -306,9 +307,11 @@ module Fluent | |
| 306 307 |  | 
| 307 308 | 
             
                      if @extract_kubernetes_labels && record.key?('kubernetes')
         | 
| 308 309 | 
             
                        kubernetes_labels = record['kubernetes']['labels']
         | 
| 309 | 
            -
                        kubernetes_labels. | 
| 310 | 
            -
                           | 
| 311 | 
            -
             | 
| 310 | 
            +
                        if !kubernetes_labels.nil?
         | 
| 311 | 
            +
                          kubernetes_labels.each_key do |l|
         | 
| 312 | 
            +
                            new_key = l.gsub(%r{[.\-\/]}, '_')
         | 
| 313 | 
            +
                            chunk_labels[new_key] = kubernetes_labels[l]
         | 
| 314 | 
            +
                          end
         | 
| 312 315 | 
             
                        end
         | 
| 313 316 | 
             
                      end
         | 
| 314 317 |  | 
| @@ -341,10 +344,8 @@ module Fluent | |
| 341 344 | 
             
                  # iterate through each chunk and create a loki stream entry
         | 
| 342 345 | 
             
                  def chunk_to_loki(chunk)
         | 
| 343 346 | 
             
                    streams = {}
         | 
| 344 | 
            -
                    last_time = nil
         | 
| 345 347 | 
             
                    chunk.each do |time, record|
         | 
| 346 348 | 
             
                      # each chunk has a unique set of labels
         | 
| 347 | 
            -
                      last_time = time if last_time.nil?
         | 
| 348 349 | 
             
                      result = line_to_loki(record)
         | 
| 349 350 | 
             
                      chunk_labels = result[:labels]
         | 
| 350 351 | 
             
                      # initialize a new stream with the chunk_labels if it does not exist
         | 
    
        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.2. | 
| 4 | 
            +
              version: 1.2.17
         | 
| 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: 2022-01-12 00:00:00.000000000 Z
         | 
| 14 14 | 
             
            dependencies:
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 16 16 | 
             
              name: fluentd
         | 
| @@ -129,6 +129,7 @@ files: | |
| 129 129 | 
             
            - README.md
         | 
| 130 130 | 
             
            - bin/console
         | 
| 131 131 | 
             
            - bin/setup
         | 
| 132 | 
            +
            - bin/test
         | 
| 132 133 | 
             
            - lib/fluent/plugin/out_loki.rb
         | 
| 133 134 | 
             
            homepage: https://github.com/grafana/loki/
         | 
| 134 135 | 
             
            licenses:
         | 
| @@ -149,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 149 150 | 
             
                - !ruby/object:Gem::Version
         | 
| 150 151 | 
             
                  version: '0'
         | 
| 151 152 | 
             
            requirements: []
         | 
| 152 | 
            -
            rubygems_version: 3.0.3
         | 
| 153 | 
            +
            rubygems_version: 3.0.3.1
         | 
| 153 154 | 
             
            signing_key: 
         | 
| 154 155 | 
             
            specification_version: 4
         | 
| 155 156 | 
             
            summary: Output plugin to ship logs to a Grafana Loki server
         |