mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-14 10:17:06 +02:00
Add Fluentd::Setting::Config#{filters,labels,group_by_label}
Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
This commit is contained in:
parent
ea6c6f3765
commit
1fabed0b47
@ -21,12 +21,48 @@ class Fluentd
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def filters
|
||||||
|
elements.find_all do |elm|
|
||||||
|
elm.name == "filter"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def matches
|
def matches
|
||||||
elements.find_all do |elm|
|
elements.find_all do |elm|
|
||||||
elm.name == "match"
|
elm.name == "match"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def labels
|
||||||
|
elements.find_all do |elm|
|
||||||
|
elm.name == "label"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
def write_to_file
|
def write_to_file
|
||||||
return unless Fluentd.instance
|
return unless Fluentd.instance
|
||||||
Fluentd.instance.agent.config_write formatted
|
Fluentd.instance.agent.config_write formatted
|
||||||
|
Loading…
Reference in New Issue
Block a user