Skip to content

Commit

Permalink
Merge pull request #179 from bastelfreak/pcp
Browse files Browse the repository at this point in the history
(#74) collect local PCP metrics
  • Loading branch information
MartyEwings committed Jun 16, 2023
2 parents acd3ac3 + 066b744 commit e5c3a0b
Show file tree
Hide file tree
Showing 3 changed files with 307 additions and 252 deletions.
9 changes: 9 additions & 0 deletions REFERENCE.md
Expand Up @@ -513,6 +513,7 @@ The following parameters are available in the `puppet_operational_dashboards::te
* [`token_name`](#-puppet_operational_dashboards--telegraf--agent--token_name)
* [`influxdb_token_file`](#-puppet_operational_dashboards--telegraf--agent--influxdb_token_file)
* [`http_timeout_seconds`](#-puppet_operational_dashboards--telegraf--agent--http_timeout_seconds)
* [`include_pe_metrics`](#-puppet_operational_dashboards--telegraf--agent--include_pe_metrics)

##### <a name="-puppet_operational_dashboards--telegraf--agent--token"></a>`token`

Expand Down Expand Up @@ -770,6 +771,14 @@ Timeout for HTTP Telegraf inputs. Might be usefull in huge environments with slo

Default value: `5`

##### <a name="-puppet_operational_dashboards--telegraf--agent--include_pe_metrics"></a>`include_pe_metrics`

Data type: `Boolean`

Whether to include Filesync and Orchestrator dashboards

Default value: `$puppet_operational_dashboards::include_pe_metrics`

## Defined types

### <a name="puppet_operational_dashboards--telegraf--config"></a>`puppet_operational_dashboards::telegraf::config`
Expand Down
18 changes: 17 additions & 1 deletion manifests/telegraf/agent.pp
Expand Up @@ -79,6 +79,8 @@
# This token is used in this class in a Deferred function call to retrieve a Telegraf token if $token is unset
# @param http_timeout_seconds
# Timeout for HTTP Telegraf inputs. Might be usefull in huge environments with slower API responses
# @param include_pe_metrics
# Whether to include Filesync and Orchestrator dashboards
class puppet_operational_dashboards::telegraf::agent (
String $version,
Boolean $manage_repo,
Expand Down Expand Up @@ -114,6 +116,8 @@
Array[String] $profiles = puppet_operational_dashboards::pe_profiles_on_host(),
Array[String] $local_services = [],
Integer[1] $http_timeout_seconds = 5,
# Check for PE by looking at the compiling server's module_groups setting
Boolean $include_pe_metrics = $puppet_operational_dashboards::include_pe_metrics,
) {
unless [$puppetserver_hosts, $puppetdb_hosts, $postgres_hosts, $profiles, $local_services].any |$service| { $service } {
fail('No services detected on node.')
Expand Down Expand Up @@ -312,7 +316,7 @@
}
# The port to use for this mbean is 8143 for Orchestrator and 8140 for Puppet server
if puppet_operational_dashboards::include_pe_metrics {
if $include_pe_metrics {
$pcp_hosts = $puppetserver_hosts.map |$host| {
if $host in $orchestrator_hosts {
"${host}:8143"
Expand All @@ -334,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 @@ -350,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

0 comments on commit e5c3a0b

Please sign in to comment.