Skip to content

Commit 131ae12

Browse files
authored
Merge pull request #174 from m0dular/SUP-3881_console_metrics
(SUP-3881) Add collection for PE console services
2 parents 45327b1 + ac01ea0 commit 131ae12

File tree

6 files changed

+73
-4
lines changed

6 files changed

+73
-4
lines changed

files/json2timeseriesdb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ def influx_tag_parser(tag)
210210
tag.delete('orchestrator')
211211
end
212212

213+
if tag.include? 'console'
214+
tag_set = "#{tag_set}service=console,"
215+
tag.delete('console')
216+
end
217+
213218
if tag.include? 'puppetserver'
214219
tag_set = "#{tag_set}service=puppetserver,"
215220
tag.delete('puppetserver')

files/metrics_tidy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
#shellcheck disable=SC2317
4+
35
fail() {
46
# Restore stdout by pointing it to fd 3 and send any errors to it
57
exec >&3
@@ -43,7 +45,7 @@ done
4345

4446

4547
# Guard against deleting or archiving files outside of a Puppet service metrics directory.
46-
valid_paths=(puppetserver puppetdb orchestrator ace bolt activemq postgres system_processes system_memory system_cpu vmware)
48+
valid_paths=(puppetserver puppetdb orchestrator console ace bolt activemq postgres system_processes system_memory system_cpu vmware)
4749

4850
# Arguments and defaults.
4951
metrics_directory="${metrics_directory:-/opt/puppetlabs/puppet-metrics-collector/puppetserver}"

manifests/init.pp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@
3737
# @param orchestrator_port
3838
# Port to connect to orchestrator on. Default: '8143'
3939
#
40+
#
41+
# @param console_metrics_ensure
42+
# Whether to enable or disable the collection of PE Console metrics. Valid values are 'present', and 'absent'. Default : 'present'
43+
#
44+
# @param console_hosts
45+
# The list of console hosts to collect metrics from. Uses the hosts_with_pe_profile function to determine the list of hosts with the console profile.
46+
#
47+
# @param console_port
48+
# Port to connect to console on. Default: '4433'
49+
#
4050
# @param ace_metrics_ensure
4151
# Whether to enable or disable the collection of Ace metrics. Valid values are 'present', and 'absent'. Default : 'present'
4252
#
@@ -83,6 +93,8 @@
8393
# An Array of metrics to exclude from the puppetdb metrics collection.
8494
# @param orchestrator_excludes
8595
# An Array of metrics to exclude from the orchestrator_excludes metrics collection.
96+
# @param console_excludes
97+
# An Array of metrics to exclude from the console_excludes metrics collection.
8698
# @param ace_excludes
8799
# An Array of metrics to exclude from the ace_excludes metrics collection.
88100
# @param bolt_excludes
@@ -111,6 +123,9 @@
111123
String $orchestrator_metrics_ensure = 'present',
112124
Array[String] $orchestrator_hosts = puppet_metrics_collector::hosts_with_pe_profile('orchestrator'),
113125
Integer $orchestrator_port = 8143,
126+
String $console_metrics_ensure = 'present',
127+
Array[String] $console_hosts = puppet_metrics_collector::hosts_with_pe_profile('console'),
128+
Integer $console_port = 4433,
114129
String $ace_metrics_ensure = 'present',
115130
Array[String] $ace_hosts = puppet_metrics_collector::hosts_with_pe_profile('ace_server'),
116131
Integer $ace_port = 44633,
@@ -125,6 +140,7 @@
125140
Optional[Array[String]] $puppetserver_excludes = undef,
126141
Optional[Array[String]] $puppetdb_excludes = undef,
127142
Optional[Array[String]] $orchestrator_excludes = undef,
143+
Optional[Array[String]] $console_excludes = undef,
128144
Optional[Array[String]] $ace_excludes = undef,
129145
Optional[Array[String]] $bolt_excludes = undef,
130146
Optional[Array[String]] $activemq_excludes = undef,
@@ -194,6 +210,7 @@
194210
include puppet_metrics_collector::service::puppetserver
195211
include puppet_metrics_collector::service::puppetdb
196212
include puppet_metrics_collector::service::orchestrator
213+
include puppet_metrics_collector::service::console
197214
include puppet_metrics_collector::service::ace
198215
include puppet_metrics_collector::service::bolt
199216

manifests/service/console.pp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# @summary Collects console metrics
2+
#
3+
# @api private
4+
#
5+
class puppet_metrics_collector::service::console (
6+
String $metrics_ensure = $puppet_metrics_collector::console_metrics_ensure,
7+
Integer $collection_frequency = $puppet_metrics_collector::collection_frequency,
8+
Integer $retention_days = $puppet_metrics_collector::retention_days,
9+
Array[String] $hosts = $puppet_metrics_collector::console_hosts,
10+
Integer $port = $puppet_metrics_collector::console_port,
11+
Array[Hash] $extra_metrics = [],
12+
Optional[String] $override_metrics_command = $puppet_metrics_collector::override_metrics_command,
13+
Optional[Array[String]] $excludes = $puppet_metrics_collector::console_excludes,
14+
Optional[Enum['influxdb', 'graphite', 'splunk_hec']] $metrics_server_type = $puppet_metrics_collector::metrics_server_type,
15+
Optional[String] $metrics_server_hostname = $puppet_metrics_collector::metrics_server_hostname,
16+
Optional[Integer] $metrics_server_port = $puppet_metrics_collector::metrics_server_port,
17+
Optional[String] $metrics_server_db_name = $puppet_metrics_collector::metrics_server_db_name,
18+
) {
19+
puppet_metrics_collector::pe_metric { 'console' :
20+
metric_ensure => $metrics_ensure,
21+
cron_minute => "0/${collection_frequency}",
22+
retention_days => $retention_days,
23+
hosts => $hosts,
24+
metrics_port => $port,
25+
additional_metrics => $extra_metrics,
26+
override_metrics_command => $override_metrics_command,
27+
excludes => $excludes,
28+
metrics_server_type => $metrics_server_type,
29+
metrics_server_hostname => $metrics_server_hostname,
30+
metrics_server_port => $metrics_server_port,
31+
metrics_server_db_name => $metrics_server_db_name,
32+
}
33+
}

spec/acceptance/pe_metric_spec.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
it { expect(service('puppet_bolt-tidy.timer')).to be_running }
1717
it { expect(service('puppet_orchestrator-metrics.timer')).to be_running }
1818
it { expect(service('puppet_orchestrator-tidy.timer')).to be_running }
19+
it { expect(service('puppet_console-metrics.timer')).to be_running }
20+
it { expect(service('puppet_console-tidy.timer')).to be_running }
1921
it { expect(service('puppet_puppetdb-metrics.timer')).to be_running }
2022
it { expect(service('puppet_puppetdb-tidy.timer')).to be_running }
2123
it { expect(service('puppet_puppetserver-metrics.timer')).to be_running }
@@ -24,12 +26,12 @@
2426

2527
it 'creates tidy services files' do
2628
files = run_shell('ls /etc/systemd/system/puppet_*-tidy.service').stdout
27-
expect(files.split("\n").count).to eq(5)
29+
expect(files.split("\n").count).to eq(6)
2830
end
2931

3032
it 'creates the timer files' do
3133
files = run_shell('ls /etc/systemd/system/puppet_*-tidy.timer').stdout
32-
expect(files.split("\n").count).to eq(5)
34+
expect(files.split("\n").count).to eq(6)
3335
end
3436

3537
describe file("/opt/puppetlabs/puppet-metrics-collector/puppetserver/#{certname}") do
@@ -62,6 +64,16 @@
6264
end
6365
end
6466

67+
describe file("/opt/puppetlabs/puppet-metrics-collector/console/#{certname}") do
68+
before(:each) { run_shell('systemctl start puppet_console-metrics.service') }
69+
70+
it { is_expected.to be_directory }
71+
it 'contains metric files' do
72+
files = run_shell("ls /opt/puppetlabs/puppet-metrics-collector/console/#{certname}/*").stdout
73+
expect(files.split('\n')).not_to be_empty
74+
end
75+
end
76+
6577
describe file("/opt/puppetlabs/puppet-metrics-collector/ace/#{certname}") do
6678
before(:each) { run_shell('systemctl start puppet_ace-metrics.service') }
6779

spec/classes/init_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
context 'when customizing the collection frequency' do
3131
let(:params) { { collection_frequency: 10 } }
3232

33-
['ace', 'bolt', 'orchestrator', 'puppetdb', 'puppetserver'].each do |service|
33+
['ace', 'bolt', 'orchestrator', 'console', 'puppetdb', 'puppetserver'].each do |service|
3434
it { is_expected.to contain_file("/etc/systemd/system/puppet_#{service}-metrics.timer").with_content(%r{OnCalendar=.*0\/10}) }
3535
end
3636
end

0 commit comments

Comments
 (0)