Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 34fda2c

Browse files
authored
Merge pull request #62 from suckatrash/add_profiles
Add profiles, move puppetdb metric defaults (part 2)
2 parents 32e1986 + ebf644d commit 34fda2c

23 files changed

+635
-430
lines changed

.fixtures.yml

+3
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ fixtures:
1515
yumrepo:
1616
repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git
1717
ref: 1.0.2
18+
telegraf:
19+
repo: https://github.com/voxpupuli/puppet-telegraf.git
20+
ref: v2.1.0
1821
forge_modules:

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ group :development do
2323
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
2424
gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
2525
gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
26+
gem "toml-rb", '= 1.1.2', require: false, platforms: [:ruby]
2627
gem "puppet-module-posix-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby]
2728
gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby]
2829
gem "puppet-module-win-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw]

README.md

+82-32
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,44 @@
1313

1414
## Description
1515

16-
This module is used to configure grafana, telegraf, and influxdb to consume metrics from Puppet service.
16+
This module is used to configure grafana and influxdb to consume metrics from Puppet services.
17+
By default the metrics collection is done by another service called telegraf.
1718

18-
You have the option of getting metrics from any or all of three of these methods:
19+
These services can all run on a single server by applying the base class. You also have the option
20+
to use the [included defined types](#profile-defined-types) to configure telegraf on each of your Puppet infrastructure components
21+
(master,compilers, puppetdb, postgres server) and the metrics will be stored on another server
22+
running grafana and influxdb. In environments where there is an existing grafana / influxdb
23+
instance, the later option is recommended. See [Determining where telegraf runs](#determining-where-telegraf-runs) for further
24+
details.
1925

26+
You have the option of collecting metrics using any or all of these methods:
27+
28+
* Through telegraf, which polls several of Puppet's metrics endpoints (recommended)
2029
* Through Archive files from the [puppetlabs/puppet_metrics_collector](https://forge.puppet.com/puppetlabs/puppet_metrics_collector) module
2130
* Natively, via Puppetserver's [built-in graphite support](https://puppet.com/docs/pe/2019.0/getting_started_with_graphite.html#task-7933)
22-
* Through telegraf, which polls several of Puppet's metrics endpoints
2331

2432
## Setup
2533

26-
### Upgrade note
34+
### Upgrade notes, breaking changes in v2
35+
36+
The `puppet_metrics_dashboard::profile::postgres` class is now deprecated and you should use the `puppet_metrics_dashboard::profile::Master::postgres_access` class instead.
37+
38+
Parameters `telegraf_agent_interval` and `http_response_timeout` were previously integers but are now strings. The value should match a time interval, such as `5s`, `10m`, or `1h`.
39+
40+
`influxdb_urls` was previously a string, it should now be an array.
2741

2842
Previous versions of this module put several `[[inputs.httpjson]]` entries in
2943
`/etc/telegraf/telegraf.conf`. These entries should be removed now as all
30-
module-specific settings now reside in
31-
`/etc/telegraf/telegraf.d/puppet_metrics_dashboard.conf`. Telegraf will
32-
continue to work if you do not remove them, however, the old
44+
module-specific settings now reside in individual files within
45+
`/etc/telegraf/telegraf.d/`. Telegraf will continue to work if you do not remove them, however, the old
3346
`[[inputs.httpjson]]` will not be updated going forward.
3447

48+
### Determining where telegraf runs
49+
50+
Telegraf can run on the grafana server or on each Puppet infrastructure node. To configure telegraf to run on the same host that
51+
grafana runs on, use the `puppet_metrics_dashboard` class and the parameters: `master_list`, `puppetdb_list` and `postgres_host_list`. These parameters determine which hosts that telegraf polls.
52+
53+
To configure telegraf to run on each Puppet infrastructure node, use the corresponding profiles for those hosts. See [Profile defined types](#profile-defined-types). The `puppet_metrics_dashboard` class is still applied to a separate host to setup grafana and influxdb and the profile classes configure telegraf when applied to your Puppet infrastructure hosts.
3554

3655
### Beginning with puppet_metrics_dashboard
3756

@@ -45,12 +64,11 @@ include puppet_metrics_dashboard
4564

4665
## Usage
4766

48-
### To install example dashboards for all of the collection methods:
67+
### To install example dashboards and use the telegraf collection method (default):
4968

5069
```
5170
class { 'puppet_metrics_dashboard':
5271
add_dashboard_examples => true,
53-
influxdb_database_name => ['puppet_metrics','telegraf','graphite'],
5472
}
5573
```
5674

@@ -59,7 +77,6 @@ class { 'puppet_metrics_dashboard':
5977
```
6078
class { 'puppet_metrics_dashboard':
6179
add_dashboard_examples => true,
62-
influxdb_database_name => ['puppet_metrics','telegraf','graphite'],
6380
overwrite_dashboards => false,
6481
}
6582
```
@@ -68,8 +85,6 @@ class { 'puppet_metrics_dashboard':
6885

6986
```
7087
class { 'puppet_metrics_dashboard':
71-
configure_telegraf => true,
72-
enable_telegraf => true,
7388
master_list => ['master1.com',
7489
# Alternate ports may be configured using
7590
# a pair of: [hostname, port_number]
@@ -79,18 +94,6 @@ class { 'puppet_metrics_dashboard':
7994
}
8095
```
8196

82-
### Allow access to PE-managed postgres nodes with the following class:
83-
84-
This is required for collection of postgres metrics.
85-
86-
```
87-
class { 'puppet_metrics_dashboard::profile::postgres':
88-
grafana_host => 'postgres01',
89-
}
90-
```
91-
92-
`grafana_host` is optional. If you do not specify it, the class will look for a node with the `puppet_metrics_dashboard` class applied in PuppetDB and use the `certname` of the first host returned. If the PuppetDB lookup fails and you do not specify `grafana_host` then the class outputs a warning.
93-
9497
### Enable Graphite support
9598

9699
```
@@ -102,17 +105,15 @@ class { 'puppet_metrics_dashboard':
102105
}
103106
```
104107

105-
* This method requires enabling on the master side as described [here](https://puppet.com/docs/pe/2017.3/puppet_server_metrics/getting_started_with_graphite.html#enabling-puppet-server-graphite-support). The hostname(s) that you use in `master_list` should match the value(s) that you used for `metrics_server_id` in the `puppet_enterprise::profile::master` class.
108+
* This method requires enabling on the master side as described [here](https://puppet.com/docs/pe/latest/puppet_server_metrics/getting_started_with_graphite.html#enabling-puppet-server-graphite-support). The hostname(s) that you use in `master_list` should match the value(s) that you used for `metrics_server_id` in the `puppet_enterprise::profile::master` class.
106109

107-
### Enable Telegraf, Graphite, and Archive
110+
### Enable Telegraf, Graphite, and Archive (puppet_metrics)
108111

109112
```
110113
class { 'puppet_metrics_dashboard':
111114
add_dashboard_examples => true,
112115
influxdb_database_name => ['puppet_metrics','telegraf','graphite'],
113116
consume_graphite => true,
114-
configure_telegraf => true,
115-
enable_telegraf => true,
116117
}
117118
```
118119

@@ -130,14 +131,63 @@ By default, this will create a set of certificates in `/etc/grafana` that are ba
130131

131132
_Note:_ Enabling SSL on Grafana will not allow for running on privileged ports such as `443`. To enable this capability you can use the suggestions documented in [this Grafana documentation](http://docs.grafana.org/installation/configuration/#http-port)
132133

134+
### Allow access to PE-managed postgres nodes with the following class:
135+
136+
This is required for collection of postgres metrics. The class should be applied to the master (or postgres server if using external postgres).
137+
138+
```
139+
class { 'puppet_metrics_dashboard::profile::master::postgres_access':
140+
telegraf_host => 'grafana-server.example.com',
141+
}
142+
```
143+
144+
`telegraf_host` is optional. If you do not specify it, the class will look for a node with the `puppet_metrics_dashboard` class applied in PuppetDB and use the `certname` of the first host returned. If the PuppetDB lookup fails and you do not specify `telegraf_host` then the class outputs a warning.
145+
146+
### Profile defined types
147+
148+
The module includes defined types that you can use with an existing grafana implementation. For example:
149+
150+
#### Add telegraf to a master / compiler
151+
152+
```
153+
puppet_metrics_dashboard::profile::compiler{ $facts['networking']['fqdn']:
154+
timeout => '5s',
155+
}
156+
```
157+
158+
#### Add telegraf to a puppetdb node (see params.pp for `puppetdb_metrics` examples)
159+
160+
```
161+
puppet_metrics_dashboard::profile::puppetdb{ $facts['networking']['fqdn']:
162+
timeout => '5s',
163+
puppetdb_metrics => [
164+
{ 'name' => 'global_command-parse-time',
165+
'url' => 'puppetlabs.puppetdb.mq:name=global.command-parse-time' },
166+
{ 'name' => 'global_discarded',
167+
'url' => 'puppetlabs.puppetdb.mq:name=global.discarded' },
168+
]
169+
}
170+
```
171+
172+
#### Add telegraf to a postgres server
173+
174+
```
175+
puppet_metrics_dashboard::profile::master::postgres{ $facts['networking']['fqdn']:
176+
query_interval => '10m',
177+
}
178+
```
179+
180+
#### Note on using the defined types
181+
182+
Because of the way that the telegraf module works, these examples will overwrite any configuration in telegraf.config if it is *not* already puppet-managed. See the [puppet-telegraf documentation](https://forge.puppet.com/puppet/telegraf#usage) on how to manage this file and add important settings.
183+
133184
### Other possibilities
134185

135-
Configure the passwords for the InfluxDB and Grafana administrator users and enable additional [TICK Stack](https://www.influxdata.com/time-series-platform/) components.
186+
Configure the passwords for the InfluxDB and enable additional [TICK Stack](https://www.influxdata.com/time-series-platform/) components.
136187

137188
```
138189
class { 'puppet_metrics_dashboard':
139190
influx_db_password => 'secret',
140-
grafana_password => 'secret',
141191
grafana_http_port => 8080,
142192
grafana_version => '4.5.2',
143193
enable_chronograf => true,
@@ -147,7 +197,7 @@ class { 'puppet_metrics_dashboard':
147197

148198
## Reference
149199

150-
**Note** This section is no longer maintained. Please see the REFERENCE.MD file for current listings.
200+
**Note** This section is no longer maintained. Please see the REFERENCE.MD file for current listings.
151201

152202
## Limitations
153203

@@ -159,7 +209,7 @@ Error: Execution of '/usr/bin/yum -d 0 -e 0 -y install telegraf' returned 1: Err
159209
Error: /Stage[main]/Pe_metrics_dashboard::Telegraf/Package[telegraf]/ensure: change from purged to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y install telegraf' returned 1: Error: Cannot retrieve repository metadata (repomd.xml) for repository: influxdb. Please verify its path and try again
160210
```
161211

162-
To recify the issue, please update `nss` and `curl` on the affected system.
212+
To rectify the issue, please update `nss` and `curl` on the affected system.
163213

164214
```
165215
yum install curl nss --disablerepo influxdb

REFERENCE.md

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
* `puppet_metrics_dashboard::service`: Manages services
2424
* `puppet_metrics_dashboard::telegraf`: Install and configure Telegraf
2525
* `puppet_metrics_dashboard::telegraf::config`: Configures Telegraf
26-
* `puppet_metrics_dashboard::telegraf::install`: Installs Telegraf
2726
* `puppet_metrics_dashboard::telegraf::service`: Manages the Telegraf service
2827

2928
## Defined types

manifests/init.pp

+18-13
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# @param consume_graphite
3333
# Whether to enable the InfluxDB Graphite plugin.
3434
# Valid values are `true`, `false`. Defaults to `false`
35-
# This parameter enables the Graphite plugin for InfluxDB to allow for injesting Graphite metrics. Ensure `influxdb_database_name`
35+
# This parameter enables the Graphite plugin for InfluxDB to allow for injesting Graphite metrics. Ensure `influxdb_database_name`
3636
# contains `graphite` when using this parameter.
3737
# _Note:_ If using Graphite metrics from the Puppet Master, this needs to be set to `true`.
3838
#
@@ -52,8 +52,8 @@
5252
# @param influxdb_database_name
5353
# An array of databases that should be created in InfluxDB.
5454
# Valid values are 'puppet_metrics','telegraf', 'graphite', and any other string. Defaults to `['puppet_metrics']`
55-
# Each database in the array will be created in InfluxDB. 'puppet_metrics','telegraf', and 'graphite' are specially named and will
56-
# be used with their associated metric collection method. Any other database name will be created, but not utilized with
55+
# Each database in the array will be created in InfluxDB. 'puppet_metrics','telegraf', and 'graphite' are specially named and will
56+
# be used with their associated metric collection method. Any other database name will be created, but not utilized with
5757
# components in this module.
5858
#
5959
# @param influx_db_password
@@ -86,16 +86,19 @@
8686
# Defaults to `[$trusted['certname']]`
8787
#
8888
# @param influxdb_urls
89-
# The string for telegraf's config defining where influxdb is
89+
# An array for telegraf's config defining where influxdb instances are
9090
#
9191
# @param telegraf_db_name
9292
# The database in influxdb where telefraf metrics are stored
9393
#
9494
# @param telegraf_agent_interval
95-
# How often the telefraf agent queries for metrics
95+
# How often the telefraf agent queries for metrics. Defaults to "5s"
9696
#
9797
# @param http_response_timeout
98-
# How long to wait for the queries by telegraf to finish before giving up
98+
# How long to wait for the queries by telegraf to finish before giving up. Defaults to "5s"
99+
#
100+
# @param pg_query_interval
101+
# How often postgres queries will run when monitoring a postgres host. Defaults to "10m"
99102
#
100103
# @param overwrite_dashboards
101104
# Whether to overwrite the example Grafana dashboards.
@@ -113,7 +116,7 @@
113116
# integer that specifies the port number.
114117
# Defaults to `[$trusted['certname']]`
115118
#
116-
# @param puppetdb_list
119+
# @param postgres_host_list
117120
# A list of PostgreSQL servers that Telegraf will be configured to
118121
# collect metrics from. Entries in the list may be:
119122
# - A single string that contains a hostname or IP address.
@@ -203,13 +206,15 @@
203206
Boolean $enable_telegraf = $puppet_metrics_dashboard::params::enable_telegraf,
204207
Boolean $configure_telegraf = $puppet_metrics_dashboard::params::configure_telegraf,
205208
Boolean $consume_graphite = $puppet_metrics_dashboard::params::consume_graphite,
206-
Puppet_metrics_dashboard::HostList $master_list = $puppet_metrics_dashboard::params::master_list,
207-
Puppet_metrics_dashboard::HostList $puppetdb_list = $puppet_metrics_dashboard::params::puppetdb_list,
208-
Puppet_metrics_dashboard::HostList $postgres_host_list = $puppet_metrics_dashboard::params::postgres_host_list,
209-
String $influxdb_urls = $puppet_metrics_dashboard::params::influxdb_urls,
209+
Puppet_metrics_dashboard::HostList $master_list = $puppet_metrics_dashboard::params::master_list,
210+
Puppet_metrics_dashboard::HostList $puppetdb_list = $puppet_metrics_dashboard::params::puppetdb_list,
211+
Puppet_metrics_dashboard::HostList $postgres_host_list = $puppet_metrics_dashboard::params::postgres_host_list,
212+
Puppet_metrics_dashboard::Puppetdb_metric $puppetdb_metrics = $puppet_metrics_dashboard::params::puppetdb_metrics,
213+
Array[String] $influxdb_urls = $puppet_metrics_dashboard::params::influxdb_urls,
210214
String $telegraf_db_name = $puppet_metrics_dashboard::params::telegraf_db_name,
211-
Integer[1] $telegraf_agent_interval = $puppet_metrics_dashboard::params::telegraf_agent_interval,
212-
Integer[1] $http_response_timeout = $puppet_metrics_dashboard::params::http_response_timeout,
215+
String[2] $telegraf_agent_interval = $puppet_metrics_dashboard::params::telegraf_agent_interval,
216+
String[2] $http_response_timeout = $puppet_metrics_dashboard::params::http_response_timeout,
217+
String[2] $pg_query_interval = $puppet_metrics_dashboard::params::pg_query_interval,
213218
) inherits puppet_metrics_dashboard::params {
214219
if $manage_repos {
215220
contain puppet_metrics_dashboard::repos

0 commit comments

Comments
 (0)