Elasticsearch: configuring log rotation

Before this change Elasticsearch logs were only printed to the console.
Now, every log is also stored in a file named the same as the hostName
of the instance, for example elasticsearch-data-0 pod prints its logs to
/var/lib/elasticsearch/data/elasticsearch-data-0.log file. This is done
due to the fact that logs from elastichsearch-data instances are stored
in the same persistent volume. When multiple instances were writing to the
same file, synchronization issues would appear (multiple processes
logging to the same file using RollingFile appender is not supported).

Rotation configuration:
- maximum number of 5 archived log files
- each log file can take up to 100MB
- when log file exceeds 100MB, it's renamed by adding an integer to the
end of the file, for example file.log is renamed to file.log.1

Change-Id: I4689661c72084ad2f9af94dc574208ae8e1856d7
Signed-off-by: Mateusz Blaszkowski <mateusz.blaszkowski@intel.com>
This commit is contained in:
Michał Dulko 2017-07-25 12:27:51 +02:00 committed by Mateusz Blaszkowski
parent 56e6beed47
commit 966ee087f2
4 changed files with 17 additions and 20 deletions

View File

@ -104,7 +104,7 @@ spec:
mountPath: /usr/share/elasticsearch/config/log4j2.properties
subPath: log4j2.properties
readOnly: true
- mountPath: /var/lib/elasticsearch/data
- mountPath: {{ .Values.conf.elasticsearch.path.data }}
name: storage
volumes:
- name: elastic-bin

View File

@ -100,15 +100,11 @@ spec:
mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
subPath: elasticsearch.yml
readOnly: true
- name: elastic-etc
mountPath: /usr/share/elasticsearch/config/logging.yml
subPath: logging.yml
readOnly: true
- name: elastic-etc
mountPath: /usr/share/elasticsearch/config/log4j2.properties
subPath: log4j2.properties
readOnly: true
- mountPath: /var/lib/elasticsearch/data
- mountPath: {{ .Values.conf.elasticsearch.path.data }}
name: storage
volumes:
- name: elastic-bin

View File

@ -12,23 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.
appender.rolling.type = RollingFile
appender.rolling.name = rolling
appender.rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}.log
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %.10000m%n
appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}.log
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = true
status = error
appender.console.type = Console
appender.console.name = console
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n
appender.rolling.type = RollingFile
appender.rolling.name = rolling
appender.rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${hostName}.log
appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${hostName}.log.%i
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%d{DEFAULT}][%-5p][%-25c] %.10000m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling.policies.size.size=100MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.max = 5
appender.rolling.strategy.fileIndex = min
rootLogger.level = info
rootLogger.appenderRef.console.ref = console
rootLogger.appenderRef.rolling.ref = rolling

View File

@ -100,7 +100,7 @@ spec:
subPath: log4j2.properties
readOnly: true
- name: storage
mountPath: /var/lib/elasticsearch/data
mountPath: {{ .Values.conf.elasticsearch.path.data }}
volumes:
- name: elastic-bin
configMap: