|
4 | 4 | #
|
5 | 5 | # @api private
|
6 | 6 | class puppet_metrics_dashboard::telegraf {
|
7 |
| - # Enable Telegraf if `configure_telegraf` is true. |
8 |
| - $_enable_telegraf = $puppet_metrics_dashboard::configure_telegraf ? { |
9 |
| - true => true, |
10 |
| - default => $puppet_metrics_dashboard::enable_telegraf |
11 |
| - } |
| 7 | + if $puppet_metrics_dashboard::configure_telegraf { |
| 8 | + $_puppetdb_metrics = $puppet_metrics_dashboard::puppetdb_metrics |
| 9 | + |
| 10 | + class { 'telegraf': |
| 11 | + interval => $puppet_metrics_dashboard::telegraf_agent_interval, |
| 12 | + logfile => '/var/log/telegraf/telegraf.log', |
| 13 | + hostname => '', |
| 14 | + manage_repo => false, |
| 15 | + manage_service => false, |
| 16 | + outputs => { |
| 17 | + 'influxdb' => [ |
| 18 | + { |
| 19 | + 'urls' => $puppet_metrics_dashboard::influxdb_urls, |
| 20 | + 'database' => $puppet_metrics_dashboard::telegraf_db_name, |
| 21 | + 'write_consistency' => 'any', |
| 22 | + 'timeout' => '5s', |
| 23 | + }, |
| 24 | + ], |
| 25 | + }, |
| 26 | + } |
| 27 | + |
| 28 | + file {'/etc/telegraf/telegraf.d/puppet_metrics_dashboard.conf': |
| 29 | + ensure => absent, |
| 30 | + } |
| 31 | + |
| 32 | + # Transform the host lists into arrays of "hostname:port", using a |
| 33 | + # service's default port if no alternate was specified. |
| 34 | + $_master_list = $puppet_metrics_dashboard::master_list.map |$entry| { |
| 35 | + $entry ? { |
| 36 | + Tuple[String, Integer] => { 'host' => $entry[0], 'port' => $entry[1] }, |
| 37 | + String => { 'host' => $entry, 'port' => 8140 }, |
| 38 | + } |
| 39 | + } |
| 40 | + $_puppetdb_list = $puppet_metrics_dashboard::puppetdb_list.map |$entry| { |
| 41 | + $entry ? { |
| 42 | + Tuple[String, Integer] => { 'host' => $entry[0], 'port' => $entry[1] }, |
| 43 | + String => { 'host' => $entry, 'port' => 8081 }, |
| 44 | + } |
| 45 | + } |
| 46 | + $_postgres_list = $puppet_metrics_dashboard::postgres_host_list.map |$entry| { |
| 47 | + $entry ? { |
| 48 | + Tuple[String, Integer] => { 'host' => $entry[0], 'port' => $entry[1] }, |
| 49 | + String => { 'host' => $entry, 'port' => 5432 }, |
| 50 | + } |
| 51 | + } |
12 | 52 |
|
13 |
| - if $_enable_telegraf { |
14 |
| - contain puppet_metrics_dashboard::telegraf::install |
15 |
| - contain puppet_metrics_dashboard::telegraf::config |
16 |
| - contain puppet_metrics_dashboard::telegraf::service |
| 53 | + $_master_list.each |$master| { |
| 54 | + puppet_metrics_dashboard::profile::compiler{ $master['host']: |
| 55 | + compiler => $master['host'], |
| 56 | + port => $master['port'], |
| 57 | + timeout => $puppet_metrics_dashboard::http_response_timeout, |
| 58 | + interval => $puppet_metrics_dashboard::telegraf_agent_interval, |
| 59 | + require => Class['Telegraf'], |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + $_puppetdb_list.each |$puppetdb| { |
| 64 | + puppet_metrics_dashboard::profile::puppetdb{ $puppetdb['host']: |
| 65 | + puppetdb_host => $puppetdb['host'], |
| 66 | + port => $puppetdb['port'], |
| 67 | + timeout => $puppet_metrics_dashboard::http_response_timeout, |
| 68 | + interval => $puppet_metrics_dashboard::telegraf_agent_interval, |
| 69 | + require => Class['Telegraf'], |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + $_postgres_list.each |$postgres| { |
| 74 | + puppet_metrics_dashboard::profile::master::postgres{ $postgres['host']: |
| 75 | + postgres_host => $postgres['host'], |
| 76 | + port => $postgres['port'], |
| 77 | + query_interval => $puppet_metrics_dashboard::pg_query_interval, |
| 78 | + require => Class['Telegraf'], |
| 79 | + } |
| 80 | + } |
17 | 81 |
|
18 |
| - Class['puppet_metrics_dashboard::telegraf::install'] |
19 |
| - -> Class['puppet_metrics_dashboard::telegraf::config'] |
20 |
| - -> Class['puppet_metrics_dashboard::telegraf::service'] |
21 | 82 | }
|
| 83 | + |
22 | 84 | }
|
0 commit comments