From 7b2fde3e580958aa235fa9df2619cb18a5ce054a Mon Sep 17 00:00:00 2001 From: Johannes Staffans Date: Fri, 6 Dec 2019 00:13:21 +0200 Subject: [PATCH] Fluentd: guard against nil values when sanitizing labels (#1376) * Guard against nil values when sanitizing labels * Gem version bump --- .../fluent-plugin-grafana-loki.gemspec | 2 +- .../fluent-plugin-grafana-loki/lib/fluent/plugin/out_loki.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fluentd/fluent-plugin-grafana-loki/fluent-plugin-grafana-loki.gemspec b/fluentd/fluent-plugin-grafana-loki/fluent-plugin-grafana-loki.gemspec index dc15c6ed4379c..601b5c317e87e 100644 --- a/fluentd/fluent-plugin-grafana-loki/fluent-plugin-grafana-loki.gemspec +++ b/fluentd/fluent-plugin-grafana-loki/fluent-plugin-grafana-loki.gemspec @@ -4,7 +4,7 @@ $LOAD_PATH.push File.expand_path('lib', __dir__) Gem::Specification.new do |spec| spec.name = 'fluent-plugin-grafana-loki' - spec.version = '1.2.4' + spec.version = '1.2.5' spec.authors = %w[woodsaj briangann cyriltovena] spec.email = ['awoods@grafana.com', 'brian@grafana.com' , 'cyril.tovena@grafana.com'] diff --git a/fluentd/fluent-plugin-grafana-loki/lib/fluent/plugin/out_loki.rb b/fluentd/fluent-plugin-grafana-loki/lib/fluent/plugin/out_loki.rb index a5033729f9355..f92ab515043f8 100644 --- a/fluentd/fluent-plugin-grafana-loki/lib/fluent/plugin/out_loki.rb +++ b/fluentd/fluent-plugin-grafana-loki/lib/fluent/plugin/out_loki.rb @@ -195,7 +195,7 @@ def format_labels(data_labels) data_labels = {} if data_labels.nil? data_labels = data_labels.merge(@extra_labels) # sanitize label values - data_labels.each { |k, v| formatted_labels[k] = v.gsub('"', '\\"') } + data_labels.each { |k, v| formatted_labels[k] = v.gsub('"', '\\"') if v } formatted_labels end