Method: Fluentd::Setting::Config#group_by_label

Defined in:
app/models/fluentd/setting/config.rb

#group_by_labelObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/models/fluentd/setting/config.rb', line 42

def group_by_label
  hash = Hash.new{|h, k| h[k] = {} }
  sources.each do |source|
    label = source["@label"] || source["label"]
    if label
      hash[label][:sources] = [source]
    else
      hash["ROOT"][:sources] = [source]
    end
  end
  hash["ROOT"][:filters] = filters unless filters.empty?
  hash["ROOT"][:matches] = matches unless matches.empty?

  labels.each do |label|
    hash[label.arg][:filters] = label.elements.find_all do |e|
      e.name == "filter"
    end
    hash[label.arg][:matches] = label.elements.find_all do |e|
      e.name == "match"
    end
  end
  hash
end