TTL mechanism support with expirer service
Aims to support a TTL mechanism for data entering Ceilometer collector database. TTL is very useful to configure when getting a lot of meters. implement blueprint ttl-support Change-Id: I9d98e8b833ad94fd79722dee7226e7f4f03aaa2e Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>
This commit is contained in:
parent
0fb3b8f693
commit
0af224916f
@ -58,6 +58,9 @@ node default {
|
|||||||
class { 'ceilometer::alarm::evaluator':
|
class { 'ceilometer::alarm::evaluator':
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Purge 1 month old meters
|
||||||
|
class { 'ceilometer::expirer':
|
||||||
|
time_to_live => '2592000'
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
74
manifests/expirer.pp
Normal file
74
manifests/expirer.pp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||||
|
#
|
||||||
|
# Author: Emilien Macchi <emilien.macchi@enovance.com>
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# == Class: ceilometer::expirer
|
||||||
|
#
|
||||||
|
# Setups Ceilometer Expirer service to enable TTL feature.
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# [*time_to_live*]
|
||||||
|
# (optional) Number of seconds that samples are kept in the database.
|
||||||
|
# Should be a valid integer
|
||||||
|
# Defaults to '-1' to disable TTL and keep forever the datas.
|
||||||
|
#
|
||||||
|
# [*minute*]
|
||||||
|
# (optional) Defaults to '1'.
|
||||||
|
#
|
||||||
|
# [*hour*]
|
||||||
|
# (optional) Defaults to '0'.
|
||||||
|
#
|
||||||
|
# [*monthday*]
|
||||||
|
# (optional) Defaults to '*'.
|
||||||
|
#
|
||||||
|
# [*month*]
|
||||||
|
# (optional) Defaults to '*'.
|
||||||
|
#
|
||||||
|
# [*weekday*]
|
||||||
|
# (optional) Defaults to '*'.
|
||||||
|
#
|
||||||
|
|
||||||
|
class ceilometer::expirer (
|
||||||
|
$time_to_live = '-1',
|
||||||
|
$minute = 1,
|
||||||
|
$hour = 0,
|
||||||
|
$monthday = '*',
|
||||||
|
$month = '*',
|
||||||
|
$weekday = '*',
|
||||||
|
) {
|
||||||
|
|
||||||
|
include ceilometer::params
|
||||||
|
|
||||||
|
Package<| title == 'ceilometer-common' |> -> Class['ceilometer::expirer']
|
||||||
|
|
||||||
|
ceilometer_config {
|
||||||
|
'database/time_to_live': value => $time_to_live;
|
||||||
|
}
|
||||||
|
|
||||||
|
cron { 'ceilometer-expirer':
|
||||||
|
command => $ceilometer::params::expirer_command,
|
||||||
|
environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||||
|
user => 'ceilometer',
|
||||||
|
minute => $minute,
|
||||||
|
hour => $hour,
|
||||||
|
monthday => $monthday,
|
||||||
|
month => $month,
|
||||||
|
weekday => $weekday
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -2,9 +2,9 @@
|
|||||||
#
|
#
|
||||||
class ceilometer::params {
|
class ceilometer::params {
|
||||||
|
|
||||||
$dbsync_command =
|
$dbsync_command = 'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf'
|
||||||
'ceilometer-dbsync --config-file=/etc/ceilometer/ceilometer.conf'
|
|
||||||
$log_dir = '/var/log/ceilometer'
|
$log_dir = '/var/log/ceilometer'
|
||||||
|
$expirer_command = 'ceilometer-expirer'
|
||||||
|
|
||||||
case $::osfamily {
|
case $::osfamily {
|
||||||
'RedHat': {
|
'RedHat': {
|
||||||
|
87
spec/classes/ceilometer_expirer_spec.rb
Normal file
87
spec/classes/ceilometer_expirer_spec.rb
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
#
|
||||||
|
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||||
|
#
|
||||||
|
# Author: Emilien Macchi <emilien.macchi@enovance.com>
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# Unit tests for ceilometer::expirer
|
||||||
|
#
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'ceilometer::expirer' do
|
||||||
|
|
||||||
|
let :pre_condition do
|
||||||
|
"class { 'ceilometer': metering_secret => 's3cr3t' }"
|
||||||
|
end
|
||||||
|
|
||||||
|
let :params do
|
||||||
|
{ :time_to_live => '-1' }
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'ceilometer-expirer' do
|
||||||
|
|
||||||
|
it { should include_class('ceilometer::params') }
|
||||||
|
|
||||||
|
it 'installs ceilometer common package' do
|
||||||
|
should contain_package('ceilometer-common').with(
|
||||||
|
:ensure => 'present',
|
||||||
|
:name => platform_params[:common_package_name]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configures a cron' do
|
||||||
|
should contain_cron('ceilometer-expirer').with(
|
||||||
|
:command => 'ceilometer-expirer',
|
||||||
|
:environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||||
|
:user => 'ceilometer',
|
||||||
|
:minute => 1,
|
||||||
|
:hour => 0,
|
||||||
|
:monthday => '*',
|
||||||
|
:month => '*',
|
||||||
|
:weekday => '*'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configures database section in ceilometer.conf' do
|
||||||
|
should contain_ceilometer_config('database/time_to_live').with_value( params[:time_to_live] )
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on Debian platforms' do
|
||||||
|
let :facts do
|
||||||
|
{ :osfamily => 'Debian' }
|
||||||
|
end
|
||||||
|
|
||||||
|
let :platform_params do
|
||||||
|
{ :common_package_name => 'ceilometer-common' }
|
||||||
|
end
|
||||||
|
|
||||||
|
it_configures 'ceilometer-expirer'
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'on RedHat platforms' do
|
||||||
|
let :facts do
|
||||||
|
{ :osfamily => 'RedHat' }
|
||||||
|
end
|
||||||
|
|
||||||
|
let :platform_params do
|
||||||
|
{ :common_package_name => 'openstack-ceilometer-common' }
|
||||||
|
end
|
||||||
|
|
||||||
|
it_configures 'ceilometer-expirer'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user