Merge "logging: fluentd add multi log files on sources"
This commit is contained in:
@@ -26,33 +26,27 @@ define tripleo::profile::base::logging::fluentd::fluentd_service (
|
|||||||
type => 'tail',
|
type => 'tail',
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check that we have something to configure to avoid creating
|
|
||||||
# stub config files.
|
|
||||||
if !empty($sources) or !empty($filters) or !empty($matches) {
|
if !empty($sources) or !empty($filters) or !empty($matches) {
|
||||||
if $fluentd_transform and !empty($sources) {
|
if !empty($sources) {
|
||||||
$new_source = {} + map($sources) |$source| {
|
$all = map($sources) |$values| {
|
||||||
if $source['path'] {
|
{ 'pos_file' => "${pos_file_path}/${values['tag']}.pos" }
|
||||||
$newpath = {
|
+ $default_source
|
||||||
'path' => regsubst($source['path'],
|
+ $values
|
||||||
$fluentd_transform[0],
|
|
||||||
$fluentd_transform[1])
|
|
||||||
}
|
|
||||||
|
|
||||||
$source + $newpath
|
|
||||||
} else {
|
|
||||||
$source
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}else{
|
if $fluentd_transform {
|
||||||
|
$new_source = map($all) |$values| { $values.filter|$index,$value| {$index != 'path'} +
|
||||||
|
$values.filter|$index,$value|
|
||||||
|
{$index == 'path'}.reduce({})|$memo,$x| {$memo + {'path' => regsubst($x[1], $fluentd_transform[0], $fluentd_transform[1]) } } }
|
||||||
|
} else{
|
||||||
|
$new_source = {} + $all
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$new_source = {} + $sources
|
$new_source = {} + $sources
|
||||||
}
|
}
|
||||||
# Insert default values into list of sources.
|
|
||||||
$_sources = { 'pos_file' => "${pos_file_path}/${new_source['tag']}.pos" }
|
|
||||||
+ $default_source + $new_source
|
|
||||||
|
|
||||||
::fluentd::config { "100-openstack-${title}.conf":
|
::fluentd::config { "100-openstack-${title}.conf":
|
||||||
config => {
|
config => {
|
||||||
'source' => $_sources,
|
'source' => $new_source,
|
||||||
'filter' => $filters,
|
'filter' => $filters,
|
||||||
'match' => $matches,
|
'match' => $matches,
|
||||||
}
|
}
|
||||||
|
@@ -190,6 +190,39 @@ describe 'tripleo::profile::base::logging::fluentd' do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'Multifiles -- horizon' do
|
||||||
|
let(:params) { {
|
||||||
|
:step => 4,
|
||||||
|
:fluentd_default_format => '/(?<time>\\d{4}-\\d{2}-\\d{2} \\d{2} =>\\d{2}:\\d{2}.\\d+) (?<pid>\\d+) (?<priority>\\S+) (?<message>.*)$/',
|
||||||
|
:fluentd_manage_groups => false,
|
||||||
|
:fluentd_pos_file_path => '/var/cache/fluentd/',
|
||||||
|
:service_names => [ 'horizon' ],
|
||||||
|
:fluentd_path_transform => [
|
||||||
|
'/var/log/',
|
||||||
|
'/var/log/containers/'
|
||||||
|
]
|
||||||
|
} }
|
||||||
|
it { is_expected.to contain_file('/etc/fluentd/config.d/100-openstack-horizon.conf').with_content (
|
||||||
|
"# This file is managed by Puppet, do not edit manually.
|
||||||
|
<source>
|
||||||
|
format /(?<time>\\d{4}-\\d{2}-\\d{2} \\d{2} =>\\d{2}:\\d{2}.\\d+) (?<pid>\\d+) (?<priority>\\S+) (?<message>.*)$/
|
||||||
|
path /var/log/containers/horizon/test.log
|
||||||
|
pos_file /var/cache/fluentd/horizon-test.pos
|
||||||
|
tag openstack.horizon.test
|
||||||
|
@type tail
|
||||||
|
</source>
|
||||||
|
<source>
|
||||||
|
format /(?<time>\\d{4}-\\d{2}-\\d{2} \\d{2} =>\\d{2}:\\d{2}.\\d+) (?<pid>\\d+) (?<priority>\\S+) (?<message>.*)$/
|
||||||
|
path /var/log/containers/horizon/access.log
|
||||||
|
pos_file /var/cache/fluentd//openstack.horizon.access.pos
|
||||||
|
tag openstack.horizon.access
|
||||||
|
@type tail
|
||||||
|
</source>
|
||||||
|
"
|
||||||
|
) }
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
context 'Groups by service -- ceilometer_agent_central added ceilometer' do
|
context 'Groups by service -- ceilometer_agent_central added ceilometer' do
|
||||||
let(:params) { {
|
let(:params) { {
|
||||||
:step => 4,
|
:step => 4,
|
||||||
@@ -199,7 +232,7 @@ describe 'tripleo::profile::base::logging::fluentd' do
|
|||||||
it { is_expected.to contain_class('fluentd') }
|
it { is_expected.to contain_class('fluentd') }
|
||||||
it { is_expected.to contain_user('fluentd').with(
|
it { is_expected.to contain_user('fluentd').with(
|
||||||
:ensure =>'present',
|
:ensure =>'present',
|
||||||
:groups => [ 'fluentd', 'ceilometer' ],
|
:groups => [ 'fluentd', 'ceilometer', 'horizon' ],
|
||||||
:membership => 'minimum'
|
:membership => 'minimum'
|
||||||
) }
|
) }
|
||||||
end
|
end
|
||||||
@@ -224,7 +257,7 @@ describe 'tripleo::profile::base::logging::fluentd' do
|
|||||||
|
|
||||||
it { is_expected.to contain_user('fluentd').with(
|
it { is_expected.to contain_user('fluentd').with(
|
||||||
:ensure =>'present',
|
:ensure =>'present',
|
||||||
:groups => [ 'fluentd','ceilometer' ],
|
:groups => [ 'fluentd','ceilometer','horizon' ],
|
||||||
:membership => 'minimum'
|
:membership => 'minimum'
|
||||||
) }
|
) }
|
||||||
end
|
end
|
||||||
|
10
spec/fixtures/hieradata/step4.yaml
vendored
10
spec/fixtures/hieradata/step4.yaml
vendored
@@ -10,12 +10,20 @@ cinder::backend::eqlx::eqlx_chap_login: 'user'
|
|||||||
cinder::backend::eqlx::eqlx_chap_password: 'user'
|
cinder::backend::eqlx::eqlx_chap_password: 'user'
|
||||||
service_names:
|
service_names:
|
||||||
- 'ceilometer_agent_central'
|
- 'ceilometer_agent_central'
|
||||||
|
- 'horizon'
|
||||||
tripleo_fluentd_groups_ceilometer_agent_central:
|
tripleo_fluentd_groups_ceilometer_agent_central:
|
||||||
- 'ceilometer'
|
- 'ceilometer'
|
||||||
tripleo_fluentd_sources_ceilometer_agent_central:
|
tripleo_fluentd_sources_ceilometer_agent_central:
|
||||||
- 'path': '/var/log/ceilometer/central.log'
|
- 'path': '/var/log/ceilometer/central.log'
|
||||||
'tag': 'openstack.ceilometer.agent.central'
|
'tag': 'openstack.ceilometer.agent.central'
|
||||||
|
tripleo_fluentd_groups_horizon:
|
||||||
|
- 'horizon'
|
||||||
|
tripleo_fluentd_sources_horizon:
|
||||||
|
- 'path': '/var/log/horizon/test.log'
|
||||||
|
'tag': 'openstack.horizon.test'
|
||||||
|
'pos_file' : '/var/cache/fluentd/horizon-test.pos'
|
||||||
|
- 'path': '/var/log/horizon/access.log'
|
||||||
|
'tag': 'openstack.horizon.access'
|
||||||
fluentd::config_file: "/etc/fluentd/fluent.conf"
|
fluentd::config_file: "/etc/fluentd/fluent.conf"
|
||||||
fluentd::config_group: "fluentd"
|
fluentd::config_group: "fluentd"
|
||||||
fluentd::config_owner: "fluentd"
|
fluentd::config_owner: "fluentd"
|
||||||
|
Reference in New Issue
Block a user