Enforce timezone setting in log processing

Change-Id: I1fc5ecf8471c2effa1dadd72cf369c64bb11ec41
Closes-Bug: #1633074
(cherry picked from commit 737336a09c)
This commit is contained in:
Simon Pasquier 2016-11-04 17:30:21 +01:00
parent 8a418d56fe
commit 20c51d5991
10 changed files with 41 additions and 3 deletions

View File

@ -18,6 +18,7 @@ define heka::encoder::es_json (
$index = undef,
$ensure = present,
$fields = undef,
$timestamp = '%Y-%m-%dT%H:%M:%S',
) {
include heka::params

View File

@ -2,6 +2,7 @@
type = "ESJsonEncoder"
index = "<%= @index %>"
es_index_from_timestamp = <%= @es_index_from_timestamp %>
timestamp = "<%= @timestamp %>"
<% if @fields -%>
fields = [ <%= @fields.sort.collect{ |x| '"%s"' % x }.join(", ") %> ]
<% end -%>

View File

@ -0,0 +1,25 @@
# Copyright 2016 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
Facter.add("canonical_timezone") do
setcode do
tz = nil
File.open('/etc/timezone').each_line do |line|
unless line.match(/^\s*#/)
tz = line.chomp()
end
end
tz
end
end

View File

@ -28,6 +28,7 @@ class lma_collector::elasticsearch (
config_dir => $lma_collector::params::log_config_dir,
index => '%{Type}-%{%Y.%m.%d}',
es_index_from_timestamp => true,
timestamp => '%Y-%m-%dT%H:%M:%S%z',
fields => $lma_collector::params::elasticsearch_fields,
notify => Class['lma_collector::service::log'],
}

View File

@ -24,7 +24,8 @@ class lma_collector::logs::mysql {
config_dir => $config_dir,
filename => "${lma_collector::params::plugins_dir}/decoders/mysql_log.lua" ,
config => {
syslog_pattern => $lma_collector::params::syslog_pattern
syslog_pattern => $lma_collector::params::syslog_pattern,
tz => $::canonical_timezone,
},
module_directory => $lua_modules_dir,
notify => Class['lma_collector::service::log'],

View File

@ -29,6 +29,9 @@ class lma_collector::logs::openstack_decoder_splitter {
config_dir => $lma_collector::params::log_config_dir,
filename => "${lma_collector::params::plugins_dir}/decoders/openstack_log.lua",
module_directory => $lua_modules_dir,
config => {
tz => $::canonical_timezone,
},
notify => Class['lma_collector::service::log'],
}

View File

@ -25,6 +25,7 @@ class lma_collector::logs::pacemaker {
filename => "${lma_collector::params::plugins_dir}/decoders/pacemaker_log.lua",
config => {
syslog_pattern => $lma_collector::params::syslog_pattern,
tz => $::canonical_timezone,
},
module_directory => $lua_modules_dir,
notify => Class['lma_collector::service::log'],

View File

@ -24,6 +24,9 @@ class lma_collector::logs::rabbitmq {
config_dir => $config_dir,
filename => "${lma_collector::params::plugins_dir}/decoders/rabbitmq.lua" ,
module_directory => $lua_modules_dir,
config => {
tz => $::canonical_timezone,
},
notify => Class['lma_collector::service::log'],
}

View File

@ -60,7 +60,8 @@ class lma_collector::logs::swift (
filename => "${lma_collector::params::plugins_dir}/decoders/generic_syslog.lua",
config => {
syslog_pattern => $lma_collector::params::syslog_pattern,
fallback_syslog_pattern => $lma_collector::params::fallback_syslog_pattern
fallback_syslog_pattern => $lma_collector::params::fallback_syslog_pattern,
tz => $::canonical_timezone,
},
module_directory => $lua_modules_dir,
notify => Class['lma_collector::service::log'],

View File

@ -25,7 +25,8 @@ class lma_collector::logs::system {
filename => "${lma_collector::params::plugins_dir}/decoders/generic_syslog.lua" ,
config => {
syslog_pattern => $lma_collector::params::syslog_pattern,
fallback_syslog_pattern => $lma_collector::params::fallback_syslog_pattern
fallback_syslog_pattern => $lma_collector::params::fallback_syslog_pattern,
tz => $::canonical_timezone,
},
module_directory => $lua_modules_dir,
notify => Class['lma_collector::service::log'],