Skip to content

Commit

Permalink
(#74) collect local PCP metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Jun 14, 2023
1 parent ced51ff commit 38acb92
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
12 changes: 12 additions & 0 deletions manifests/telegraf/agent.pp
Expand Up @@ -338,6 +338,10 @@
}
elsif $collection_method == 'local' {
$pcp_port = ('Puppet_enterprise::Profile::Orchestrator' in $profiles or 'orchestrator' in $local_services) ? {
true => 8143,
false => 8140
}
if 'Puppet_enterprise::Profile::Puppetdb' in $profiles or 'puppetdb' in $local_services {
puppet_operational_dashboards::telegraf::config { ['puppetdb', 'puppetdb_jvm']:
hosts => [$trusted['certname']],
Expand All @@ -354,6 +358,14 @@
http_timeout_seconds => $http_timeout_seconds,
require => File['/etc/systemd/system/telegraf.service.d/override.conf'],
}
if $include_pe_metrics {
puppet_operational_dashboards::telegraf::config { 'pcp':
hosts => ["${trusted['certname']}:${pcp_port}"],
protocol => $protocol,
http_timeout_seconds => $http_timeout_seconds,
require => File['/etc/systemd/system/telegraf.service.d/override.conf'],
}
}
}
if 'Puppet_enterprise::Profile::Orchestrator' in $profiles or 'orchestrator' in $local_services {
Expand Down
29 changes: 29 additions & 0 deletions spec/classes/agent_spec.rb
Expand Up @@ -284,6 +284,35 @@
is_expected.to contain_puppet_operational_dashboards__telegraf__config('puppetserver').with(hosts: ['localhost.foo.com'])
}
end
context 'when collecting local PE metrics' do
let :params do
{
collection_method: 'local',
token: RSpec::Puppet::Sensitive.new(nil),
token_name: 'puppet telegraf token',
influxdb_token_file: '/root/.influxdb_token',
influxdb_host: 'localhost.foo.com',
influxdb_port: 8086,
influxdb_bucket: 'puppet_data',
influxdb_org: 'puppetlabs',
use_ssl: true,
manage_repo: false,
manage_archive: false,
http_timeout_seconds: 120,
version: '1.26.0',
include_pe_metrics: true,
profiles: ['Puppet_enterprise::Profile::Master', 'Puppet_enterprise::Profile::Puppetdb', 'Puppet_enterprise::Profile::Orchestrator', 'Puppet_enterprise::Profile::Database'],
}
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_telegraf__processor('pcp_renames') }
it { is_expected.to contain_telegraf__processor('orchestrator_renames') }
it { is_expected.to contain_puppet_operational_dashboards__telegraf__config('pcp') }
it { is_expected.to contain_puppet_operational_dashboards__telegraf__config('orchestrator') }
it { is_expected.to contain_telegraf__input('pcp_metrics') }
it { is_expected.to contain_telegraf__input('orchestrator_metrics') }
end
end
end
end

0 comments on commit 38acb92

Please sign in to comment.