Skip to content

Commit

Permalink
Only glob *.conf by default in conf.d folder
Browse files Browse the repository at this point in the history
Fixes #6979, Fixes #1831
  • Loading branch information
suyograo committed May 17, 2017
1 parent f6c89ae commit 252976b
Show file tree
Hide file tree
Showing 6 changed files with 560 additions and 37 deletions.
572 changes: 542 additions & 30 deletions NOTICE.TXT

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/static/setting-up-logstash.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ pipeline, and _settings files_, which specify options that control Logstash star
==== Pipeline Configuration Files

You create pipeline configuration files when you define the stages of your Logstash processing pipeline. On deb and
rpm, you place the pipeline configuration files in the `/etc/logstash/conf.d` directory. Logstash tries to load all
files in the `/etc/logstash/conf.d directory`, so don't store any non-config files or backup files in this directory.
rpm, you place the pipeline configuration files in the `/etc/logstash/conf.d` directory. Logstash tries to load only
files with `.conf` extension in the `/etc/logstash/conf.d directory` and ignores all other files.

See <<configuration>> for more info.

Expand Down
15 changes: 13 additions & 2 deletions logstash-core/lib/logstash/config/source/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ def read
config_parts = []
encoding_issue_files = []

get_files.each do |file|
if logger.debug?
logger.debug("Skipping following files while reading config since they doesn't match the glob", :files => get_unmatched_files)
end

get_matched_files.each do |file|
next unless ::File.file?(file) # skip directory

logger.debug("Reading config file", :config_file => file)
Expand Down Expand Up @@ -78,7 +82,7 @@ def normalize_path(path)
::File.expand_path(path)
end

def get_files
def get_matched_files
Dir.glob(path).sort
end

Expand All @@ -90,6 +94,13 @@ def path
end
end

def get_unmatched_files
# transform "/var/lib/*.conf" => /var/lib/*
t = File.split(@path)
all_files = Dir.glob(File.join(t.first, "*")).sort
all_files - get_matched_files
end

def valid_encoding?(content)
content.ascii_only? && content.valid_encoding?
end
Expand Down
2 changes: 1 addition & 1 deletion pkg/centos/after-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ chown -R logstash:logstash /usr/share/logstash
chown -R logstash /var/log/logstash
chown logstash:logstash /var/lib/logstash
sed -i \
-e 's|# path.config:|path.config: /etc/logstash/conf.d|' \
-e 's|# path.config:|path.config: /etc/logstash/conf.d/*.conf|' \
-e 's|# path.logs:|path.logs: /var/log/logstash|' \
-e 's|# path.data:|path.data: /var/lib/logstash|' \
/etc/logstash/logstash.yml
Expand Down
2 changes: 1 addition & 1 deletion pkg/debian/after-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ chown -R logstash /var/log/logstash
chown logstash:logstash /var/lib/logstash
chmod 755 /etc/logstash
sed -i \
-e 's|# path.config:|path.config: /etc/logstash/conf.d|' \
-e 's|# path.config:|path.config: /etc/logstash/conf.d/*.conf|' \
-e 's|# path.logs:|path.logs: /var/log/logstash|' \
-e 's|# path.data:|path.data: /var/lib/logstash|' \
/etc/logstash/logstash.yml
Expand Down
2 changes: 1 addition & 1 deletion pkg/ubuntu/after-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ chown -R logstash:logstash /usr/share/logstash
chown -R logstash /var/log/logstash
chown logstash:logstash /var/lib/logstash
sed -i \
-e 's|# path.config:|path.config: /etc/logstash/conf.d|' \
-e 's|# path.config:|path.config: /etc/logstash/conf.d/*.conf|' \
-e 's|# path.logs:|path.logs: /var/log/logstash|' \
-e 's|# path.data:|path.data: /var/lib/logstash|' \
/etc/logstash/logstash.yml
Expand Down

0 comments on commit 252976b

Please sign in to comment.