Skip to content

Commit e7a4603

Browse files
committed
Lint and release prep
1 parent 4ffbe79 commit e7a4603

File tree

7 files changed

+154
-11
lines changed

7 files changed

+154
-11
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).
44

5+
## [v2.4.0](https://github.com/puppetlabs/puppet_operational_dashboards/tree/v2.3.0)
6+
7+
[Full Changelog](https://github.com/puppetlabs/puppet_operational_dashboards/compare/v2.3.0...v2.4.0)
8+
9+
### Added
10+
11+
- Add new management params
12+
- Add support for InfluxDB 1 in Telegraf outputs
13+
- Make file-sync metrics configurable
14+
- Add parameter for extra options to Telegraf inputs
15+
516
## [v2.3.0](https://github.com/puppetlabs/puppet_operational_dashboards/tree/v2.3.0) (2024-02-05)
617

718
[Full Changelog](https://github.com/puppetlabs/puppet_operational_dashboards/compare/v2.2.0...v2.3.0)

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [Beginning with puppet_operational_dashboards](#beginning-with-puppet_operational_dashboards)
1212
- [Installing on Puppet Enterprise](#installing-on-puppet-enterprise)
1313
- [Installing on Puppet Open Source](#installing-on-puppet-open-source)
14+
- [Advanced Telegraf Configuration](#advanced-telegraf-configuration)
1415
- [What puppet_operational_dashboards affects](#what-puppet_operational_dashboards-affects)
1516
- [Usage](#usage)
1617
- [Evaluation order](#evaluation-order)
@@ -221,6 +222,72 @@ The easiest way to get started using this module is by including the `puppet_ope
221222
include puppet_operational_dashboards
222223
```
223224
225+
#### Advanced Telegraf Configuration
226+
227+
If you already have an existing setup and defined configuration for Telegraf and InfluxDB, it is possible to only configure the Telegraf inputs needed for collection of Puppet metrics via the `puppet_operational_dashboards::telegraf::agent` class. The main use case for this is if you already manage Telegraf and InfluxDB in Puppet code, and you only want to use this module to collect and ship Puppet metrics to your existing InfluxDB. To do so, you may apply the `puppet_operational_dashboards::telegraf::agent` class to either:
228+
229+
* Each Puppet infrastructure node to collect metrics locally
230+
* A single node to remotely collect metrics from all infrastructure nodes
231+
232+
For the first case of local collection, set `collection_method: 'local'` and `local_services` to an array of Puppet services to collect from, for example `local_services: ['puppetserver', 'puppetdb']`.
233+
234+
For the second case of remote collection, use `collection_method: 'all'` and set each of the following as needed:
235+
236+
* puppetserver_hosts
237+
* orchestrator_hosts
238+
* puppetdb_hosts
239+
* postgres_hosts
240+
241+
In either case, you can control whether this class will manage the Telegraf class and service with:
242+
243+
```bash
244+
puppet_operational_dashboards::telegraf::agent::manage_class
245+
```
246+
247+
Whether to manage Telegraf outputs with:
248+
249+
```bash
250+
puppet_operational_dashboards::telegraf::agent::manage_outputs
251+
```
252+
253+
And whether to configure token authentication in the inputs with:
254+
```bash
255+
puppet_operational_dashboards::telegraf::agent::use_token_auth
256+
```
257+
258+
You may also pass additional options to the Telegraf inputs, for example, if you need to add a tag. The following hiera data will add an additional `[inputs.http.tags]` element with a key/value pair of `foo = bar`:
259+
260+
```bash
261+
puppet_operational_dashboards::telegraf::agent::extra_input_options:
262+
tags:
263+
foo: 'bar'
264+
```
265+
266+
The following is a complete example to configure a Telegraf input for collecting Puppet server metrics locally with an additional tag:
267+
268+
```bash
269+
puppet_operational_dashboards::telegraf::agent::local_services:
270+
- 'puppetserver'
271+
puppet_operational_dashboards::telegraf::agent::token_name: 'puppetlabs'
272+
puppet_operational_dashboards::telegraf::agent::influxdb_token_file: '/root/.influxdb_token'
273+
puppet_operational_dashboards::telegraf::agent::influxdb_bucket: 'puppet_data'
274+
puppet_operational_dashboards::telegraf::agent::influxdb_org: 'puppetlabs'
275+
puppet_operational_dashboards::telegraf::agent::include_pe_metrics: false
276+
puppet_operational_dashboards::telegraf::agent::manage_repo: false
277+
puppet_operational_dashboards::telegraf::agent::manage_class: false
278+
puppet_operational_dashboards::telegraf::agent::influxdb_host: 'foo.bar.com'
279+
puppet_operational_dashboards::telegraf::agent::influxdb_port: 8086
280+
puppet_operational_dashboards::telegraf::agent::use_token_auth: false
281+
puppet_operational_dashboards::telegraf::agent::manage_outputs: false
282+
puppet_operational_dashboards::telegraf::agent::collection_method: 'local'
283+
puppet_operational_dashboards::telegraf::agent::use_ssl: true
284+
puppet_operational_dashboards::telegraf::agent::use_system_store: false
285+
puppet_operational_dashboards::telegraf::agent::template_format: 'yaml'
286+
puppet_operational_dashboards::telegraf::agent::extra_input_options:
287+
tags:
288+
foo: 'bar'
289+
```
290+
224291
#### What puppet_operational_dashboards affects
225292
Installing the module will:
226293

REFERENCE.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,11 @@ The following parameters are available in the `puppet_operational_dashboards::te
620620
* [`use_system_store`](#-puppet_operational_dashboards--telegraf--agent--use_system_store)
621621
* [`manage_ssl`](#-puppet_operational_dashboards--telegraf--agent--manage_ssl)
622622
* [`manage_repo`](#-puppet_operational_dashboards--telegraf--agent--manage_repo)
623+
* [`manage_class`](#-puppet_operational_dashboards--telegraf--agent--manage_class)
624+
* [`use_token_auth`](#-puppet_operational_dashboards--telegraf--agent--use_token_auth)
623625
* [`manage_archive`](#-puppet_operational_dashboards--telegraf--agent--manage_archive)
624626
* [`manage_user`](#-puppet_operational_dashboards--telegraf--agent--manage_user)
627+
* [`manage_outputs`](#-puppet_operational_dashboards--telegraf--agent--manage_outputs)
625628
* [`ssl_cert_file`](#-puppet_operational_dashboards--telegraf--agent--ssl_cert_file)
626629
* [`ssl_key_file`](#-puppet_operational_dashboards--telegraf--agent--ssl_key_file)
627630
* [`ssl_ca_file`](#-puppet_operational_dashboards--telegraf--agent--ssl_ca_file)
@@ -630,6 +633,7 @@ The following parameters are available in the `puppet_operational_dashboards::te
630633
* [`puppet_ssl_ca_file`](#-puppet_operational_dashboards--telegraf--agent--puppet_ssl_ca_file)
631634
* [`insecure_skip_verify`](#-puppet_operational_dashboards--telegraf--agent--insecure_skip_verify)
632635
* [`version`](#-puppet_operational_dashboards--telegraf--agent--version)
636+
* [`influxdb_version`](#-puppet_operational_dashboards--telegraf--agent--influxdb_version)
633637
* [`archive_location`](#-puppet_operational_dashboards--telegraf--agent--archive_location)
634638
* [`archive_install_dir`](#-puppet_operational_dashboards--telegraf--agent--archive_install_dir)
635639
* [`collection_method`](#-puppet_operational_dashboards--telegraf--agent--collection_method)
@@ -648,6 +652,7 @@ The following parameters are available in the `puppet_operational_dashboards::te
648652
* [`telegraf_postgres_password`](#-puppet_operational_dashboards--telegraf--agent--telegraf_postgres_password)
649653
* [`postgres_port`](#-puppet_operational_dashboards--telegraf--agent--postgres_port)
650654
* [`postgres_options`](#-puppet_operational_dashboards--telegraf--agent--postgres_options)
655+
* [`extra_input_options`](#-puppet_operational_dashboards--telegraf--agent--extra_input_options)
651656
* [`template_format`](#-puppet_operational_dashboards--telegraf--agent--template_format)
652657

653658
##### <a name="-puppet_operational_dashboards--telegraf--agent--token"></a>`token`
@@ -720,6 +725,18 @@ Data type: `Boolean`
720725

721726
Whether to install Telegraf from a repository.
722727

728+
##### <a name="-puppet_operational_dashboards--telegraf--agent--manage_class"></a>`manage_class`
729+
730+
Data type: `Boolean`
731+
732+
Whether to manage the Telegraf class and related resources
733+
734+
##### <a name="-puppet_operational_dashboards--telegraf--agent--use_token_auth"></a>`use_token_auth`
735+
736+
Data type: `Boolean`
737+
738+
Whether to set up and use token based auth to InfluxDB
739+
723740
##### <a name="-puppet_operational_dashboards--telegraf--agent--manage_archive"></a>`manage_archive`
724741

725742
Data type: `Boolean`
@@ -736,6 +753,14 @@ Whether to manage the telegraf user when installing from archive.
736753

737754
Default value: `true`
738755

756+
##### <a name="-puppet_operational_dashboards--telegraf--agent--manage_outputs"></a>`manage_outputs`
757+
758+
Data type: `Boolean`
759+
760+
Whether to manage the telegraf outputs
761+
762+
Default value: `true`
763+
739764
##### <a name="-puppet_operational_dashboards--telegraf--agent--ssl_cert_file"></a>`ssl_cert_file`
740765

741766
Data type: `Stdlib::Absolutepath`
@@ -798,6 +823,14 @@ Data type: `String`
798823

799824
Version of the Telegraf package to install.
800825

826+
##### <a name="-puppet_operational_dashboards--telegraf--agent--influxdb_version"></a>`influxdb_version`
827+
828+
Data type: `Enum['v1', 'v2']`
829+
830+
Which version of InfluxDB to use in the inputs. Currently supports versions 1 and 2
831+
832+
Default value: `'v2'`
833+
801834
##### <a name="-puppet_operational_dashboards--telegraf--agent--archive_location"></a>`archive_location`
802835

803836
Data type: `String`
@@ -956,6 +989,14 @@ Default value:
956989
}
957990
```
958991

992+
##### <a name="-puppet_operational_dashboards--telegraf--agent--extra_input_options"></a>`extra_input_options`
993+
994+
Data type: `Optional[Hash]`
995+
996+
Optional hash of extra values to pass to each telegraf::input declared in this module
997+
998+
Default value: `undef`
999+
9591000
##### <a name="-puppet_operational_dashboards--telegraf--agent--template_format"></a>`template_format`
9601001

9611002
Data type: `Enum['yaml','toml']`
@@ -980,6 +1021,8 @@ The following parameters are available in the `puppet_operational_dashboards::te
9801021
* [`ensure`](#-puppet_operational_dashboards--telegraf--config--ensure)
9811022
* [`http_timeout_seconds`](#-puppet_operational_dashboards--telegraf--config--http_timeout_seconds)
9821023
* [`template_format`](#-puppet_operational_dashboards--telegraf--config--template_format)
1024+
* [`include_pe_metrics`](#-puppet_operational_dashboards--telegraf--config--include_pe_metrics)
1025+
* [`extra_input_options`](#-puppet_operational_dashboards--telegraf--config--extra_input_options)
9831026

9841027
##### <a name="-puppet_operational_dashboards--telegraf--config--service"></a>`service`
9851028

@@ -1023,6 +1066,20 @@ Template format to use for puppet template toml or yaml config
10231066

10241067
Default value: `'toml'`
10251068

1069+
##### <a name="-puppet_operational_dashboards--telegraf--config--include_pe_metrics"></a>`include_pe_metrics`
1070+
1071+
Data type: `Boolean`
1072+
1073+
Whether to include Filesync metrics in Puppetserver
1074+
1075+
##### <a name="-puppet_operational_dashboards--telegraf--config--extra_input_options"></a>`extra_input_options`
1076+
1077+
Data type: `Optional[Hash]`
1078+
1079+
Optional hash of extra values to pass to each telegraf::input declared in this module
1080+
1081+
Default value: `undef`
1082+
10261083
## Functions
10271084

10281085
### <a name="puppet_operational_dashboards--hosts_with_profile"></a>`puppet_operational_dashboards::hosts_with_profile`
@@ -1194,7 +1251,7 @@ Default value:
11941251
```puppet
11951252
[{
11961253
'type' => 'expire',
1197-
'everySeconds' => 3456000,
1254+
'everySeconds' => 7776000,
11981255
'shardGroupDurationSeconds' => 604800,
11991256
}]
12001257
```

functions/pe_profiles_on_host.pp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ function puppet_operational_dashboards::pe_profiles_on_host() >> Array[String] {
1010
$hosts = puppetdb_query("resources[title] {
1111
type = 'Class' and
1212
certname = '${trusted['certname']}' and
13-
title in ['Puppet_enterprise::Profile::Puppetdb', 'Puppet_enterprise::Profile::Master', 'Puppet_enterprise::Profile::Database', 'Puppet_enterprise::Profile::Orchestrator'] and
13+
title in [
14+
'Puppet_enterprise::Profile::Puppetdb',
15+
'Puppet_enterprise::Profile::Master',
16+
'Puppet_enterprise::Profile::Database',
17+
'Puppet_enterprise::Profile::Orchestrator'
18+
] and
1419
nodes { deactivated is null and expired is null }
1520
}").map |$nodes| { $nodes['title'] }
1621
} else {

manifests/telegraf/agent.pp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,16 @@
9292
# Port for the Telegraf client to use in the postgres connection string
9393
# @param postgres_options
9494
# Hash of options for the Telegraf client to use as connection parameters in the postgres connection string
95+
# @param extra_input_options
96+
# Optional hash of extra values to pass to each telegraf::input declared in this module
9597
# @param template_format
9698
# Template format to use for puppet template toml or yaml config
9799
class puppet_operational_dashboards::telegraf::agent (
98100
String $version,
99-
Enum['v1', 'v2'] $influxdb_version = 'v2',
100101
Boolean $manage_repo,
101102
Boolean $manage_class,
102103
Boolean $use_token_auth,
104+
Enum['v1', 'v2'] $influxdb_version = 'v2',
103105
Optional[Sensitive[String]] $token = $puppet_operational_dashboards::telegraf_token,
104106
String $token_name = $puppet_operational_dashboards::telegraf_token_name,
105107
String $influxdb_token_file = $puppet_operational_dashboards::influxdb_token_file,

manifests/telegraf/config.pp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
# Template format to use for puppet template toml or yaml config
1414
# @param include_pe_metrics
1515
# Whether to include Filesync metrics in Puppetserver
16+
# @param extra_input_options
17+
# Optional hash of extra values to pass to each telegraf::input declared in this module
1618
define puppet_operational_dashboards::telegraf::config (
19+
Boolean $include_pe_metrics,
1720
Array[String[1]] $hosts,
1821
Enum['https', 'http'] $protocol,
1922
Integer[1] $http_timeout_seconds,
2023
String $service = $title,
2124
Enum['present', 'absent'] $ensure = 'present',
2225
Enum['yaml','toml'] $template_format = 'toml',
23-
Boolean $include_pe_metrics,
2426
Optional[Hash] $extra_input_options = undef,
2527
) {
2628
unless $service in ['puppetserver', 'puppetdb', 'puppetdb_jvm', 'orchestrator', 'pcp'] {
@@ -58,11 +60,11 @@
5860
telegraf::input { "${service}_metrics":
5961
plugin_type => 'http',
6062
options => if $extra_input_options {
61-
[$_inputs + $extra_input_options]
62-
}
63-
else {
64-
[$_inputs]
65-
},
63+
[$_inputs + $extra_input_options]
64+
}
65+
else {
66+
[$_inputs]
67+
},
6668
}
6769

6870
# Create processors.strings.rename entries to rename full url to hostname

spec/defines/puppet_operational_dashboards_telegraf_config_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@
189189
}
190190
}
191191
}
192-
193192
end
194193

195194
it {
@@ -198,7 +197,7 @@
198197
# Testing that the Telegraf input contains identical Ruby objects was turning out to be difficult
199198
# It was returning an error but saying the diffs were identical, so instead we just check the file
200199
is_expected.to contain_file('/etc/telegraf/telegraf.d/puppetserver_metrics.conf').with_content(
201-
%r{\[inputs\.http\.tags]\nfoo = \"bar\"}
200+
%r{\[inputs\.http\.tags\]\nfoo = \"bar\"},
202201
)
203202
}
204203
end

0 commit comments

Comments
 (0)