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 1a7c2fb592274..c02426684a6c1 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 @@ -135,10 +135,8 @@ def labels_to_protocol(data_labels) data_labels = {} if data_labels.nil? data_labels = data_labels.merge(@extra_labels) - unless data_labels.nil? - data_labels.each do |k, v| - formatted_labels.push("#{k}=\"#{v}\"") - end + data_labels.each do |k, v| + formatted_labels.push("#{k}=\"#{v.gsub('"','\\"')}\"") if v end '{' + formatted_labels.join(',') + '}' end