fluent-plugin-grafana-loki 1.2.16 → 1.2.17

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
  SHA256:
3
- metadata.gz: d69446470f9b77ceaf43e03d15948de4afbf0573a0a1be6ca1825aaa43075a90
4
- data.tar.gz: dbc6e1481ee9b55a236f5316f00f92631970fd5ed990c3f7e2c595d25e90bac1
3
+ metadata.gz: 7314140e15cf44c0150b92442687304a8ce1f90470ddf9527a10d75603840e19
4
+ data.tar.gz: 911185ef9e06820f156a763bc7ce562ff476982190b4a63658b505c278490892
5
5
  SHA512:
6
- metadata.gz: 05165c783cf297c4e2cb64f5e421ea5b6c8aae41894269c06500177b722d82250cf8a78040c6e7389dab840e463a65f78e8ce4e07ae04dcd8fb7f66a4f90fe19
7
- data.tar.gz: 0e8b7dab804916783771976c39eb3a9e1edbd3ed54438c72119ba9b0aef79e490af47e626c044084d80b0273d3eb22cfc71b345a0c01a22299da6b83c73d697f
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 `bundle exec rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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
- `gem install rubocop`
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
- gem install bundler
7
- bundle install
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
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+
5
+ ruby -S bundle exec rspec
@@ -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.each_key do |l|
310
- new_key = l.gsub(%r{[.\-\/]}, '_')
311
- chunk_labels[new_key] = kubernetes_labels[l]
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.16
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: 2020-10-27 00:00:00.000000000 Z
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