Giter VIP home page Giter VIP logo

voxpupuli / puppet-telegraf Goto Github PK

View Code? Open in Web Editor NEW
24.0 43.0 99.0 399 KB

A Puppet module for installing and configuring InfluxData's Telegraf

Home Page: https://forge.puppet.com/puppet/telegraf

License: GNU General Public License v3.0

Ruby 56.31% Puppet 43.07% Shell 0.61%
puppet telegraf influxdata-telegraf linux-puppet-module windows-puppet-module hacktoberfest bsd-puppet-module centos-puppet-module debian-puppet-module freebsd-puppet-module

puppet-telegraf's Introduction

telegraf puppet module

Build Status Release Puppet Forge Puppet Forge - downloads Puppet Forge - endorsement Puppet Forge - scores puppetmodule.info docs GPL v3 License

Table of Contents

  1. Overview
  2. Setup
  3. Usage
  4. Limitations
  5. Development

Overview

A reasonably simple yet flexible Puppet module to manage configuration of InfluxData's Telegraf metrics collection agent.

Setup

This module has the following dependencies:

NB: On some apt-based distributions you'll need to ensure you have support for TLS-enabled repos in place. This can be achieved by installing the apt-transport-https package.

Up to version v4.3.1 this module requires the toml-rb gem. Either install the gem using puppet's native gem provider, puppetserver_gem, pe_gem, pe_puppetserver_gem, or manually using one of the following methods:

  # apply or puppet-master
  gem install toml-rb
  # PE apply
  /opt/puppetlabs/puppet/bin/gem install toml-rb
  # AIO or PE puppetserver
  /opt/puppet/bin/puppetserver gem install toml-rb

The toml-rb gem got replaced with stdlib::to_toml. This requires puppetlabs/stdlib 9.

In addition, for Windows, the following dependencies must be met:

Usage

Telegraf's configuration is split into four main sections - global tags, options specific to the agent, input plugins, and output plugins. The documentation for these sections is here, and this module aims to be flexible enough to handle configuration of any of these stanzas.

To get started, Telegraf can be installed with a very basic configuration by just including the class:

include telegraf

However, to customise your configuration you'll want to do something like the following:

class { 'telegraf':
    hostname => $facts['hostname'],
    outputs  => {
        'influxdb' => [
            {
                'urls'     => [ "http://influxdb0.${facts['domain']}:8086", "http://influxdb1.${facts['domain']}:8086" ],
                'database' => 'telegraf',
                'username' => 'telegraf',
                'password' => 'metricsmetricsmetrics',
            }
        ]
    },
    inputs   => {
        'cpu' => [
            {
                'percpu'   => true,
                'totalcpu' => true,
            }
        ]
    }
}

Or here's a Hiera-based example (which is the recommended approach):

---
telegraf::global_tags:
  role: "%{::role}"
  hostgroup: "%{::hostgroup}"
  domain: "%{::domain}"
telegraf::inputs:
  cpu:
    - percpu: true
      totalcpu: true
  exec:
    - commands:
        - who | wc -l
    - commands:
        - cat /proc/uptime | awk '{print $1}'
  mem: [{}]
  io: [{}]
  net: [{}]
  disk: [{}]
  swap: [{}]
  system: [{}]
telegraf::outputs:
  influxdb:
    - urls:
        - "http://influxdb0.%{::domain}:8086"
        - "http://influxdb1.%{::domain}:8086"
      database: 'influxdb'
      username: 'telegraf'
      password: 'telegraf'
telegraf::processors:
  replace_disk_type:
    plugin_type: regex
    options:
      - namepass: ['diskio']
        order: 1
        tags:
          - key: 'disk_type'
            pattern: '^dos$'
            replacement: 'FAT'

telegraf::inputs accepts a hash of any inputs that you'd like to configure. However, you can also optionally define individual inputs using the telegraf::input type - this suits installations where, for example, a core module sets the defaults and other modules import it.

Example 1:

telegraf::input { 'my_exec':
  plugin_type => 'exec',
  options     => [
    {
      'commands'    => ['/usr/local/bin/my_input.py',],
      'name_suffix' => '_my_input',
      'data_format' => 'json',
    }
  ],
  require     => File['/usr/local/bin/my_input.py'],
}

Will create the file /etc/telegraf/telegraf.d/my_exec.conf:

[[inputs.exec]]
commands = ["/usr/local/bin/my_input.py"]
data_format = "json"
name_suffix = "_my_input"

Example 2:

telegraf::input { 'influxdb-dc':
  plugin_type => 'influxdb',
  options     => [
    {
      'urls' => ['http://remote-dc:8086',],
    }
  ],
}

Will create the file /etc/telegraf/telegraf.d/influxdb-dc.conf:

[[inputs.influxdb]]
urls = ["http://remote-dc:8086"]

Example 3:

telegraf::input { 'my_snmp':
  plugin_type    => 'snmp',
  options        => [
    {
      'interval' => '60s',
      'host' => [
        {
          'address'   => 'snmp_host1:161',
          'community' => 'read_only',
          'version'   => 2,
          'get_oids'  => ['1.3.6.1.2.1.1.5',],
        }
      ],
      'tags' => {
        'environment' => 'development',
      },
    }
  ],
}

Will create the file /etc/telegraf/telegraf.d/snmp.conf:

[[inputs.snmp]]
interval = "60s"
[inputs.snmp.tags]
environment = "development"
[[inputs.snmp.host]]
address = "snmp_host1:161"
community = "read_only"
get_oids = ["1.3.6.1.2.1.1.5"]
version = 2

Example 4:

Outputs, Processors and Aggregators are available in the same way:

telegraf::output { 'my_influxdb':
  plugin_type => 'influxdb',
  options     => [
    {
      'urls'     => [ "http://influxdb.example.come:8086"],
      'database' => 'telegraf',
      'username' => 'telegraf',
      'password' => 'metricsmetricsmetrics',
    }
  ],
}

telegraf::processor { 'my_regex':
  plugin_type => 'regex',
  options     => [
    {
      tags => [
        {
          key         => 'foo',
          pattern     => String(/^a*b+\d$/),
          replacement => 'c${1}d',
        }
      ],
    }
  ],
}

telegraf::aggregator { 'my_basicstats':
  plugin_type => 'basicstats',
  options     => [
    {
      period        => '30s',
      drop_original => false,
    }
  ],
}

Example 5:

class { 'telegraf':
    ensure              => '1.0.1',
    hostname            => $facts['hostname'],
    windows_package_url => 'http://internal_repo:8080/chocolatey',
}

Will install telegraf version 1.0.1 on Windows using an internal chocolatey repo

Hierarchical configuration from multiple files

Hiera YAML and JSON backends support deep hash merging which is needed for inheriting configuration from multiple files.

First of all, make sure that the deep_merge gem is installed on your Puppet Master.

An example of hiera.yaml:

---
:hierarchy:
    - "roles/%{role}"
    - "type/%{virtual}"
    - "domain/%{domain}"
    - "os/%{osfamily}"
    - "common"
:backends:
    - yaml
:yaml:
    :datadir: /etc/puppet/hiera
:merge_behavior: deeper

Then you can define configuration shared for all physical servers and place it into type/physical.yaml:

telegraf::inputs:
  cpu:
    - percpu: true
      totalcpu: true
  mem: [{}]
  io: [{}]
  net: [{}]
  disk: [{}]

Specific roles will include some extra plugins, e.g. role/frontend.yaml:

telegraf::inputs:
  nginx:
    - urls: ["http://localhost/server_status"]

Limitations

The latest version (2.0) of this module requires Puppet 4 or newer. If you're looking for support under Puppet 3.x, then you'll want to make use of an older release.

Furthermore, the introduction of toml-rb means that Ruby 1.9 or newer is also a requirement.

This module has been developed and tested against the operating systems and their version in metadata.json

Support for other distributions / operating systems is planned. Feel free to assist with development in this regard!

The configuration generated with this module is only compatible with newer releases of Telegraf, i.e 0.11.x. It won't work with the 0.2.x series.

Development

Please fork this repository, hack away on your branch, run the tests:

$ bundle exec rake beaker

And then submit a pull request. Succinct, well-described and atomic commits preferred.

puppet-telegraf's People

Contributors

alexjfisher avatar amlestrange avatar bastelfreak avatar cosmopetrich avatar deric avatar dhoppe avatar ekohl avatar fe80 avatar genebean avatar jkkitakita avatar joshua-snapp avatar kenyon avatar lswith avatar m0dular avatar martyewings avatar mattqm avatar mj avatar mxjessie avatar nrdmn avatar philomory avatar rvstaveren avatar simonhoenscheid avatar smortex avatar snahelou avatar strongoose avatar stuartbfox avatar tuxmea avatar yachub avatar yankcrime avatar zilchms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

puppet-telegraf's Issues

Merge problem: "^telegraf::outputs(.*)$": merge: strategy: first

Hello,

I defined a global output for all hosts, except the DMZ host. My problem is, that I get two output URL in my outputs, the first one is the global (not needed), the second is the one, I need. I use also the changes from: #99

I tried to use:

lookup_options:
  "^telegraf::outputs(.*)$":
    merge:
      strategy: first

but it does not work. I get always both URLs, instead of only this one, if defined in my host.yaml.

We use the same for the "apt" class, and this works as expected. What I have done wrong ?

Any suggestions ?

Influxdb changed their repo structure for RHEL?

baseurl=https://repos.influxdata.com/rhel/$releasever/$basearch/stable
python -c 'import yum, pprint; yb = yum.YumBase(); pprint.pprint(yb.conf.yumvar, width=1)'
Loaded plugins: kernel-module, priorities, protectbase, versionlock
{'arch': 'ia32e',
'basearch': 'x86_64',
'releasever': '6.7',
}

For CC7 the releasever is 7, inspite of the release
This can be corrected if on line 32 in install.pp we change the $releasever with for example
${facts['os']['release']['major']

multiple sections - but only first rendered

Hey,
from @nrdmn 's suggestions at #96 (comment) I modified the hieradata, manifests and profiles to match 2.0 syntax.
This works now, but I do encounter an unwanted behaviour nevertheless. It seems like only the first section is rendered at all (even with some more patterns, nginx is the only one that gets written to telegraf.conf, when I change the sequence then the new first one is going to be written to conf instead):

What I did:

telegraf::inputs:
  procstat:
    - pattern: "nginx"
      pid_tag: true
    - pattern: "php.*-fpm"
      pid_tag: true

What I expected:

[[inputs.procstat]]
  pattern = "nginx"
  pid_tag = true

[[inputs.procstat]]
  pattern = "php.*-fpm"
  pid_tag = true

What I got instead:

[[inputs.procstat]]
pattern = "nginx"
pid_tag = true

Can this be a result of using the deep_merge gem?

System Specs

  • ubuntu 16.04 (all systems)
  • puppet agent 4.10.9
  • puppetserver version: 2.8.0
  • yankcrime/telegraf 2.0.0

multiple procstat sections failing

Hey,
I probably misunderstood something about the patches in #80, but I fail to implement multiple procstat sections.

What I did:

   procstat-nginx:
     - pattern: "nginx"
       pid_tag: true
       plugin_type: "procstat"
   procstat-php-fpm:
     - pattern: "php.*-fpm"
       pid_tag: true
       plugin_type: "procstat"

What I expected:

[[inputs.procstat]]
  pattern = "nginx"
  pid_tag = true
[[inputs.procstat]]
  pattern = "php.*-fpm"
  pid_tag = true

What I got instead:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Failed to parse template telegraf/telegraf.conf.erb:
  Filepath: /etc/puppetlabs/code/environments/production/modules/telegraf/templates/telegraf.conf.erb
  Line: 35
  Detail: undefined method `each' for nil:NilClass
 at /etc/puppetlabs/code/environments/production/modules/telegraf/manifests/config.pp:12:18 on node $SERVERNAME
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

System Specs

  • ubuntu 16.04 (all systems)
  • puppet agent 4.10.9
  • puppetserver version: 2.8.0
  • yankcrime/telegraf 2.0.0

Cannot install telegraf on Windows server because config_file_mode and config_folder_mode is undefined

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 6.18.0
  • Puppet Bolt: 2.30.0
  • Ruby: 2.5.0
  • Distribution: Microsoft Windows Server 2019 Datacenter(GCE)
  • Module version:3.1.0

How to reproduce (e.g Puppet code you use)

---
description: Install and configure telegraf

parameters:
  targets:
    type: TargetSpec
    description: The targets to configure

steps:
  - description: Install and configure telegraf
    name: configure
    targets: $targets
    resources:
      - class: telegraf

return: $configure
bolt plan run telegraf -t localhost

What are you seeing

  • I cannot install telegraf
  • It worked on windows as well after adding config_file_mode

What behaviour did you expect instead

  • I can install telegraf

Output log

Failed on localhost:
  Apply failed to compile for localhost: Class[Telegraf]:
    parameter 'config_file_mode' expects a match for Stdlib::Filemode = Pattern[/\A(([0-7]{1,4})|(([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+)(,([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+))*))\z/], got Undef
    parameter 'config_folder_mode' expects a match for Stdlib::Filemode = Pattern[/\A(([0-7]{1,4})|(([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+)(,([ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+))*))\z/], got Undef (line: 4, column: 5)
Failed on 1 target: localhost

Any additional information you'd like to impart

Unable to use nested configuration

I was trying to use the following Hiera configuration to create a Telegraf input:

telegraf::inputs:
  elasticsearch:
    cluster_health: true
    local: false
    servers: ['http://127.0.0.1']
    tags:
      role: 'some_role'

This resulted in the following (snippet) of configuration:

[[inputs.elasticsearch]]
  cluster_health = true
  local = false
  servers = ["http://127.0.0.1"]
  tags = {"role"=>"some_role"}

This is wrong and causes telegraf to fail:

Error parsing /etc/telegraf/telegraf.conf, toml: line 42: parse error

Rather, it should become;

[[inputs.elasticsearch]]
  cluster_health = true
  local = false
  servers = ["http://127.0.0.1"]
  [inputs.elasticsearch.tags]
    role = "some_role"

It looks like this is already supported by telegraf::input, so I think that the real issue here is that specifying inputs in $telegraf::inputs doesn't actually utilize the telegraf::input resource.

Bump to 1.5.0

Hello

Could you please bump your module to 1.5.0 ? :)

Thank you

"logfile" parameter not supported

telegraf 1.1.0 added a logfile config parameter but it doesn't appear that this puppet module yet supports it. Is there a work around available you could suggest?

I've naively tried:

class { '::telegraf':
...
  logfile => '/path/to/file',
...
}

Install doesn't work with puppetlabs-apt 4.1.0 (puppet 4)

Install breaks with newer version of apt module. The below look a bit weird as we install from .tar.gz packages with --ignore-dependencies (and not always in order).

root@citest:/home/htj# puppet module install /var/cache/cosmos/model/puppet-modules/puppetlabs-apt-4.1.0.tar.gzNotice: Preparing to install into /etc/puppetlabs/code/environments/production/modules ...
Notice: Downloading from https://forgeapi.puppet.com ...
Error: Could not install module 'puppetlabs-apt' (???)
No version of 'puppetlabs-apt' can satisfy all dependencies
Use puppet module install --ignore-dependencies to install only this module

puppet forge release contains log files

In release 2.0.0 on Puppet Forge are included log files that are certainly not needed, from checksums.json

{
  "AUTHORS": "f0fe40cb06e992d26057e516aa3e4080",
  "Gemfile": "fa251bd95355643a883051c2b86e302a",
  "LICENSE": "84dcc94da3adb52b53ae4fa38fe49e5d",
  "README.md": "9c781b49c824910c59022fb6fbe98f61",
  "Rakefile": "98ec43598e100b1fb8d6f3c032637621",
  "log/default/2017-02-28_15_51_27/sut.log": "d41d8cd98f00b204e9800998ecf8427e",
  "log/default/2017-03-01_20_08_31/sut.log": "d41d8cd98f00b204e9800998ecf8427e",
  "log/default/2017-03-01_20_13_20/sut.log": "d41d8cd98f00b204e9800998ecf8427e",
  "log/default/2017-03-01_20_18_06/sut.log": "d41d8cd98f00b204e9800998ecf8427e",
...

Allow setting groups for the `telegraph` user

We are running Varnish 4.1 and using the following Telegraf configuration in order to send Varnish stats to InfluxDB:

telegraf::inputs:
  exec:
    commands:
      - 'varnishstat -j'
    data_format: 'json'

This doesn't quite work for Varnish 4.1, however, because the telegraf user is not a member of the varnish group. I was able to work around this problem by adding the following puppet code:

user { 'telegraf':
  groups     => ['varnish'],
  home       => '/etc/telegraf',
  managehome => false,
  shell      => '/bin/false',
  system     => true,
  require    => Class['varnish::install'],
}

It would be more convenient, however, if this module exposed a $groups parameter which would allow me to do this:

class { 'telegraf':
  groups => ['varnish'],
}

Some related resources:

Problem with defining win_perf_counters input

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 6.4.2
  • Ruby: embedded version
  • Distribution: Tested on windows2012/2016
  • Module version: 3.0.0

How to reproduce (e.g Puppet code you use)

  • The NetworkInterface win_perf_counter input is defined with following resource:
telegraf::input { 'NetworkInterface':
plugin_type => 'win_perf_counters.object',
options => [{
'ObjectName' => 'NetworkInterface',
'Instances' => ['*'],
'Counters' => [
'Bytes Received/sec',
'Bytes Sent/sec',
'Packets Received/sec',
'Packets Sent/sec',
],
'Measurement' => 'win_net',
'IncludeTotal' => false,
'tags' => {
'app' => 'metrics',
},
}]
}

What are you seeing

  • The resource will produce NetworkInterface.conf file as following but the config is wrong:
[[inputs."win_perf_counters.object"]]
Counters = ["Bytes Received/sec", "Bytes Sent/sec", "Packets Received/sec", "Packets Sent/sec"]
IncludeTotal = false
Instances = ["*"]
Measurement = "win_net"
ObjectName = "NetworkInterface"
[inputs."win_perf_counters.object".tags]
app = "metrics"

What behaviour did you expect instead

  • Down below is configuration snippet I'm expecting to see. Note the removed double quotes and tags section.
[[inputs.win_perf_counters.object]]
Counters = ["Bytes Received/sec", "Bytes Sent/sec", "Packets Received/sec", "Packets Sent/sec"]
IncludeTotal = false
Instances = ["*"]
Measurement = "win_net"
ObjectName = "NetworkInterface"
[inputs.win_perf_counters.tags]
app = "metrics"

Thanks for any help

Logfile parameter error

There is an error in logfile variable.
While the params.pp and init.pp talks about the variable log_file, the template (telegraf.conf.erb) references the variable logfile.

Support repeated input types

I'd like to be able to use the same input type multiple times with different configurations. For example, I have 2 urls that I'd like to monitor with http_response inputs. I'd like to use hiera to configure the inputs. Right now given the way the hiera hash is used it will only keep 1 of the repeated inputs.

Is there a way to set up multiple discreet influxdb outputs?

I'd like to set 2 different telegraf outputs, one tagged, one default.

When using hiera

telegraf::outputs:
  influxdb:
    - urls:
        - "http://sys.home.local:8086"
      database: 'telegraf'
      skip_database_creation: false

The title is also the output type. I didn't see an easy way to change that, I'd expect

telegraf::outputs:
  influxdb:
    - urls:
        - "http://sys.home.local:8086"
      database: 'telegraf'
      skip_database_creation: false
  influxdb_other:
    plugin_type: 'influxdb'
    - urls:
        - "http://sys.home.local:8086"
      database: 'data'
      skip_database_creation: false

would work, but it doesn't (bad yaml). Do you have an example using hiera with 2 different outputs?

Optionally use `hiera_hash` on `telegraf::inputs` and `telegraf::outputs`

It would be convenient if this module could do something similar to https://forge.puppet.com/yo61/logrotate, which exposes a $hieramerge parameter:

# apply user-defined rules
class logrotate::rules{

  $hieramerge = $::logrotate::hieramerge
  $rules      = $::logrotate::rules

  if $hieramerge {
    $_rules = hiera_hash('logrotate::rules', $rules)
  } else {
    $_rules = $rules
  }

  create_resources('logrotate::rule', $_rules)

}

Currently, we are using the following workaround:

  class { 'telegraf':
    inputs  => hiera_hash('telegraf::inputs'),
    outputs => hiera_hash('telegraf::outputs'),
  }

This workaround is required because Puppet 3's automatic parameter lookup doesn't support deep merging.

Cannot use multifile plugin

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: v5.5.10
  • Ruby: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
  • Distribution: Ubuntu focal 20.04
  • Module version: unusure

How to reproduce (e.g Puppet code you use)

The following YAML

telegraf::inputs:
  multifile:
    - base_dir: "/sys/class/thermal"
  multifile.file:
    - file: "thermal_zone2/temp"
      dest: "pch_skylake"
      conversion: "float(3)"
    - file: "thermal_zone3/temp"
      dest: "x86_pkg_temp"
      conversion: "float(3)"

converts to

[[inputs.multifile]]
base_dir = "/sys/class/thermal"
[[inputs."multifile.file"]]
file = "thermal_zone2/temp"
dest = "pch_skylake"
conversion = "float(3)"
[[inputs."multifile.file"]]
file = "thermal_zone3/temp"

What are you seeing

What behaviour did you expect instead

I would expect to be able to use multifile.file in the appropriate way. Telegraf does not startup with quotes in the config. I'm unsure what has to happen on the YAML side to use this module correctly. Using inputs.temp puts too much data points and unwanted sensors that are not as easy to work with. Otherwise, I suppose I could use two file modules, though multifile seemed to fit and converts will from 1000 -> 1.000

Output log

Any additional information you'd like to impart

Telegraf installation not going through.

Find these errors while running puppet agent
Execution of '/usr/bin/yum -d 0 -e 0 -y list telegraf' returned 1: Error: Cannot retrieve repository metadata (repomd.xml) for repository: influxdata. Please verify its path and try again

Purge unmanaged files from `/etc/telegraf/telegraf.d`

Currently this module does not purge unmanaged files from /etc/telegraf/telegraf.d. Would it be possible to add this functionality? It looks like this was previously attempted in #21, but that pull request was later abandoned.

Allow input def without options defined

Some of the telegraf inputs don't have many options and have good defaults (haproxy for example.) In the case of these type of modules, it'd be nice to be able to specify an input with just a plugin_type. If options isn't passed the input template fails to apply when it tries to iterate over the empty options hash.

Ability to handle duplicate sections

Agreeably this hurts the head to ponder, but seems it is a valid use case in eg [https://github.com/influxdata/telegraf/tree/master/plugins/inputs/postgresql_extensible]

If duplicates are specified as below, only the last is affected into the final configuration file

    sections       => {
      'postgresql_extensible.query' => {
      'sqlquery'   => 'SELECT * FROM pg_stat_database where datname',
      'version'    => 901,
      'withdbname' => true,
      'tagvalue'   => 'postgres'
      },
      'postgresql_extensible.query' => {
      'sqlquery'   => 'SELECT * FROM pg_stat_bgwriter where datname',
      'version'    => 901,
      'withdbname' => true,
      'tagvalue'   => 'postgres'
      },
    }

org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- toml-rb

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: puppet-agent-5.5.14-1.el7.x86_64, puppetserver-5.3.8-1.el7.noarch
  • Ruby: ruby 2.4.5p335 (2018-10-18 revision 65137) [x86_64-linux]
  • Distribution: x86_64
  • Module version: 2.1.0

How to reproduce (e.g Puppet code you use)

include telegraf

What are you seeing

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Internal Server Error: org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- toml-rb

What behaviour did you expect instead

it should install telegraf

Output log

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Internal Server Error: org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- toml-rb

Any additional information you'd like to impart

toml-rb (1.1.2) was installed

fails on windows because of missing repo_location

On windows i get:

Error while evaluating a Resource Statement, Class[Telegraf]: parameter 'repo_location' expects a String value, got Undef

in the class params repo_location is not set for windows but is mandatory on class telegraf.
I think this was introducted by 1cce2d3, because defining type String it's a mandatory parameter by default.
You should use Optional[String] or handle it in the class itself.
As a workaround, I set it to an empty string for windows:

repo_location          => ($::kernel) ? { 'windows' => '', default => undef },

New array format for input/output definition in hiera requires polluting configs

Inputs and outputs (and aggregators if I ever get a PR ready for that) that previously had no configuration no longer work.

cpu: was previously enough to create a cpu input. Now cpu: fails because telegraf.conf.erb:80 expects it to contain an array, and cpu: [] fails because the first element of that array is expected to be a hash. I find myself having to do some nonsense like this:

cpu:
  - placeholderkey: placeholdervalue

which of course ends up polluting my actual telegraf.conf with those placeholders.

If there's a better way to make this work with the new code from #80, I would love to know. If there's not, this seems severe enough to be a bug in need of fixing, and maybe fixing it would also address the minor annoyance of old configs not working with the new code; it would be nice if the code recognized a bare hash as functionally identical to an array containing one hash.

Usage of `sections` in telegraf::input

Hi,
could it be, that the usage of "sections" is not correct? According to the docu here is the example of logparser input plugin: https://github.com/influxdata/telegraf/tree/master/plugins/inputs/logparser

So the section is starting like [inputs.logparser.grok], so only with one quote. If using your implementation the config is [[inputs.logparser.grok]] and I am getting in logs: logparser.LogParserPlugin.GrokParser' must be slice type, but ptr given

to corrected this I chnaged the template input.conf.erb like this one:

<%      unless @options == nil -%>
<%          @options.sort.each do | option, value | -%>
  <%= option -%> = <% if value.is_a?(String) %>"<%= value %>"<% elsif value.is_a?(Array) %><%= value.inspect %><% else %><%= value %><% end %>
<%          end -%>
<%      end -%>
<% if @sections -%>
<% @sections.sort.each do |section, option| -%>
 [inputs.<%= section %>]
<%      unless option == nil -%>
<%          option.sort.each do | suboption, value | -%>
  <%= suboption -%> = <% if value.is_a?(String) %>"<%= value %>"<% elsif value.is_a?(Array) %><%= value.inspect %><% else %><%= value %><% end %>
<%          end -%>
<%      end -%>
<%   end -%>
<% end -%>
~

What do you think?

[question] desired merge behavior of $input

Currently values passed as $input (and $output) are used as the default to fall back on if a valid hiera hash is not found.

My expectation was that passing $input or $output directly would override the hiera values (but I'm relatively new to puppet). Is the behavior of these parameters consistent with other puppet modules?

I came across this when looking for a way to modify the hiera data going to the telegraf module so that I don't need to set up a custom fact or implement an ENC for an "arbitrary" subset of nodes.

Hiera not merging output options correctly.

I use the graphite output of telegraf, and all configuration is done via Hiera. In my common.yaml I have defined:

telegraf::outputs:
  graphite:
    - servers:
      - "graphite:2003"
      template: "host.tags.measurement.field"

And in various other files throughout the hierarchy I also add an extra option to the output using:

telegraf::outputs:
  graphite:
    - prefix: server-role

In order for this to merge correctly, I need to use Hiera's deep-merge with the 'merge_hash_arrays' option enabled - but even after enabling it using the lookup_options in my common.yaml file it is still not merging correctly. The 'lookup' calls in init.pp both force "merge = deep" which overrides any settings I make.

I'm not sure which is the better solution - but init.pp needs to be changed to either not specify a merge behavior so that the options defined in hiera lookup_options hash take effect, or to specify {'strategy' => 'deep', 'merge_hash_arrays' => true} The first method allows users to override the behavior if the choose, but is probably broken by default if they don't have lookup_options defined - the second will work by default, but forces it on everyone.

Fix acceptance tests for Debian and CentOS-based Docker containers

Acceptance tests under Debian 8 and CentOS 7 based on containers running from official images are broken due to systemd-related problems, e.g on Debian:

  Setting up telegraf (0.12.1-1) ...
  Created symlink from /etc/systemd/system/telegraf.service to /lib/systemd/system/telegraf.service.
  Created symlink from /etc/systemd/system/multi-user.target.wants/telegraf.service to /lib/systemd/system/telegraf.service.
  Failed to get D-Bus connection: Unknown error -1
  Failed to get D-Bus connection: Unknown error -1
  dpkg: error processing package telegraf (--configure):
   subprocess installed post-installation script returned error exit status 1
  Errors were encountered while processing:
   telegraf
  E: Sub-process /usr/bin/dpkg returned an error code (1)
  Warning: /Stage[main]/Telegraf::Config/File[/etc/telegraf/telegraf.conf]: Skipping because of failed dependencies
  Warning: /Stage[main]/Telegraf::Service/Service[telegraf]: Skipping because of failed dependencies
  Info: Creating state file /var/lib/puppet/state/state.yaml
  Notice: Finished catalog run in 23.56 seconds

Tests timeout on CentOS 7 as starting SSH via service ssh start is broken, e.g:

 Attempting ssh connection to 192.168.172.236, user: root, opts: {:password=>"root", :port=>"32773", :forward_agent=>false}
  Warning: Try 1 -- Host 192.168.172.236 unreachable: Errno::ECONNREFUSED - Connection refused - connect(2)
  Warning: Trying again in 3 seconds
❯ docker logs happy_feynman
sh: service: command not found

Probably need to just run tests off more suitable images.

Hiera hash: telegraf inputs with no parameters

Hi,
I'm using your module with the following configuration:

My configuration

# site/profile/manifests/monitoring.pp
class profile::monitoring (
  $inputs = lookup('profile::monitoring::inputs', Hash, 'hash'),
  $outputs = lookup('profile::monitoring::outputs', Hash, 'hash'),
  ) {

  class { '::telegraf':
    hostname => $::hostname,
    inputs   => $inputs,
    outputs  => $outputs,
  }

}
# data/global.yml
#...
profile::monitoring::inputs:
  cpu:
    percpu: false
    totalcpu: true
    collect_cpu_time: false
  disk:
  diskio:
  kernel:
  mem:
  processes:
  swap:
  system:
  nstat:
  puppetagent:

profile::monitoring::outputs:
  influxdb:
    urls:
      - http://influx.domain.tld
#...

Problem

When I execute the agent on the monitoring node, I have an undefined method 'sort' for :undef:Symbol error:

root@monitoring-dev-1:~# puppet agent -t
Info: Using configured environment 'dev'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Failed to parse template telegraf/telegraf.conf.erb:
  Filepath: /etc/puppetlabs/code/environments/dev/modules/telegraf/templates/telegraf.conf.erb
  Line: 47
  Detail: undefined method `sort' for :undef:Symbol
 at /etc/puppetlabs/code/environments/dev/modules/telegraf/manifests/config.pp:12:18 on node monitoring-dev-1.local.tld
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

I'm pretty new to puppet but I think the problem is that an undefined value in a Hash is not nil in a template, even if the official latest documentation about template says otherwise

# case 1: this is gonna fail since the `cpu` value is undefined
profile::monitoring::inputs:
  cpu:

# case 2: this is gonna pass because the `cpu` value is defined
profile::monitoring::inputs:
  cpu:
    percpu: false
    totalcpu: true
    collect_cpu_time: false

# case 3: this is gonna pass because the `cpu` value is explicitly set to an empty hash
# https://stackoverflow.com/questions/33510094/syntax-for-empty-dictionary-in-yaml
profile::monitoring::inputs:
  cpu: {}

The error is in the modules/telegraf/templates/telegraf.conf.erb file line 47 (for inputs):

# modules/telegraf/templates/telegraf.conf.erb
#...
<% if @_inputs -%>
#
# INPUTS:
#
<%   @_inputs.sort.each do | input, options | -%>
[[inputs.<%= input %>]]
<%      unless options == nil -%> # option will not be nil in case 1
<%          options.sort.each do | option, value | -%> # gonna fail here since undefined does not have a sort function
  <%= option -%> = <% if value.is_a?(String) %>"<%= value %>"<% elsif value.is_a?(Array) %><%= value.inspect %><% else$
<%          end -%>
<%      end -%>
<%   end -%>
<% end -%>

Potential solutions

As mentioned above, if we explictly set a hash key to {} the options variable will not be nil or undefined and the template will not fail to find the sort function.

Another solution can be to explicitly check for undefined symbol in the erb template like this:

# modules/telegraf/templates/telegraf.conf.erb
#...
<% if @_inputs -%>
#
# INPUTS:
#
<%   @_inputs.sort.each do | input, options | -%>
[[inputs.<%= input %>]]
<%      unless options == nil or options == :undef -%> # explicitly check for nil or undefined values
<%          options.sort.each do | option, value | -%>
  <%= option -%> = <% if value.is_a?(String) %>"<%= value %>"<% elsif value.is_a?(Array) %><%= value.inspect %><% else$
<%          end -%>
<%      end -%>
<%   end -%>
<% end -%>

I personally choose the solution with explicit {} for empty values.
Hope I didnt miss something and this is gonna help,
Thanks for the module,
krostar

Package dependancy issues

Via @spjmurray:

When 80f0f1c was introduced it added a
dependency that the influxdata apt::source only be installed after the apt
https transport package was installed. Some installations rely on all
packages being installed after the apt::update has been executed to ensure
with a single global statement that all packages are at their latest. This
patch ensures that the prerequisite can be installed successfully regardless
of how the environment is configured.

Reverting this commit and assuming that system maintainers will be responsible for ensuring that HTTPS-enabled apt repos are usable is probably the right thing to do.

Release a new version with #160 included

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 6.x, 7.x
  • Ruby: All
  • Distribution: EL 7
  • Module version: 4.0.0

How to reproduce (e.g Puppet code you use)

Use the puppet-telegraf 4.0.0 with manage_repo=>false, which will cause catalog compilation errors.

Error 500 on SERVER: Server Error: Could not find resource 'Yumrepo[influxdata]' for relationship on 'Package[telegraf]'

This issue has been fixed in the master branch when #160 was merged, however has not been released into a version on the forge.

What behaviour did you expect instead

Please release a version that includes #160.

Broken $hostname default value when fact['networking'] is null

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 5.4.0
  • Ruby: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
  • Distribution: Server - Ubuntu Bionic, Agent - Ubuntu Trusty
  • Module version: v3.0.0

How to reproduce (e.g Puppet code you use)

I have quite specific setup - I'm running puppet in some old, long running docker containers. Probably due to that the "networking" fact is empty on such nodes which causes:

{"message":"Server Error: Evaluation Error: Operator '[]' is not applicable to an Undef Value. (file: /etc/puppet/environments/production/modules/telegraf/manifests/params.pp, line: 37, column: 29) 

This line is the problem:

$hostname               = $facts['networking']['hostname']

Even when I pass the $hostname directly when I initialize telegraf module the default value can't be fetched from facts and whole catalog fails.

What are you seeing

mon-01-59c36840-1d9d-4ec4-a4e8-317b19e83d3c:~ # facter -p networking -j
{
  "networking": null
}

What behaviour did you expect instead

That's a good question. The catalog compilation shouldn't fail when $hostname is provided and default value cannot be resolved.

Output log

mon-01-59c36840-1d9d-4ec4-a4e8-317b19e83d3c:~ # facter -p networking -j
{
  "networking": null
}

Any additional information you'd like to impart

File mode on inputs

I am running into permission issues when using inputs

  telegraf::input { 'windows1':
    plugin_type => 'win_perf_counters',
    sections     => {
        'win_perf_counters.object' => {
        'ObjectName'    => 'Network Interface',
        'Counters' => ["Bytes Received/sec","Bytes Sent/sec","Bytes Total/sec","Packets Received/sec","Packets Sent/sec"],
        'Instances' => ["*"],
        'Measurement' => "win_net",
      }
    }
  }

It would make more sense to change the mode in config.pp from 0750 to 0770 as, by default, the group manages the file.

This was tested successfully and fixed permission issues.

NO_PUBKEY on Ubuntu | Key has changed

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: Any
  • Ruby: Any
  • Distribution: Debian / Ubuntu
  • Module version: 1.5.0

How to reproduce (e.g Puppet code you use)

Apply Module to an Ubuntu 20.04 LTS node.

What are you seeing

Public Key not available for the repository.

What behaviour did you expect instead

The pubkey being available.

Output log

Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 684A14CF2582E0C5
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: Reading package lists...
Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: W: GPG error: https://repos.influxdata.com/ubuntu focal InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 684A14CF2582E0C5

Any additional information you'd like to impart

Seems the key has changed today. On the repos.influxdata.com site, the old key is now "influxdb.key.old".

Cannot differentiate string and numeric options

I am using the following Puppet code:

  telegraf::input { 'statsd':
    options => {
      service_address          => '127.0.0.1:8125',
      allowed_pending_messages => 10000,
    },
  }

This results in the following Telegraf configuration:

[[inputs.statsd]]
  allowed_pending_messages = "10000"
  service_address = "127.0.0.1:8125"
  templates = ["logstash.* namespace.sender.measurement*"]

This configuration is invalid and Telegraf reports the following error:

Error parsing /etc/telegraf/telegraf.d/statsd.conf, line 2: statsd.Statsd.AllowedPendingMessages: `string' type is not assignable to `int' type

The problem here is that Puppet doesn't differentiate between numbers and strings (at least until Puppet 4, unless using the future parser). I was able to workaround this issue with the following Puppet code:

  telegraf::input { 'statsd':
    options => {
      service_address          => '127.0.0.1:8125',
      allowed_pending_messages => 0 + 10000,
    },
  }

Ideally though, the template used by telegraf::input would check if a configuration option is numeric and remove the quotes.

Sections and win_perf_counters

I have a question regarding sections and win_perf_counters. I have browse issues and commits of this repo and can't find my answer.

How do you have multiple sections in the same telegraf::input ?

Here's an example :

  telegraf::input { 'memory':
    plugin_type => 'win_perf_counters',
    sections     => {
        'win_perf_counters.object' => {
          'ObjectName'    => 'Memory',
          'Counters' => ["Available Bytes", "Cache Faults/sec", "Demand Zero Faults/sec", "Page Faults/sec", "Pages/sec", "Transition Faults/sec", "Pool Nonpaged Bytes", "Pool Paged Bytes"],
          'Instances' => ["*"],
          'Measurement' => "win_mem",
          }
        }
   }

Let's say I want to add Network counters to this. How do you do it ? Because it's only accepting hashes and you can't have the same key twice.

Network counters :

        'win_perf_counters.object' => {
          'ObjectName'    => 'Network Interface',
          'Counters' => ["Bytes Received/sec","Bytes Sent/sec","Bytes Total/sec","Packets Received/sec","Packets Sent/sec"],
          'Instances' => ["*"],
          'Measurement' => "win_net",
        }

Thanks!

No longer possible to configure tagpass and tagdrop

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 6.19.1
  • Ruby: AIO
  • Distribution: RHEL
  • Module version: 4.0.0 (and latest master)

How to reproduce (e.g Puppet code you use)

Using this copy/pasted from the README:

telegraf::input { 'my_snmp':
  plugin_type    => 'snmp',
  options        => {
    'interval' => '60s',
    'host' => [
      {
        'address'   => 'snmp_host1:161',
        'community' => 'read_only',
        'version'   => 2,
        'get_oids'  => ['1.3.6.1.2.1.1.5',],
      }
    ],
    'tags' => {
      'environment' => 'development',
    },
  },
}

What are you seeing

Results in:

Server Error: Evaluation Error: Error while evaluating a Resource Statement, Telegraf::Input[my_snmp]: parameter 'options' expects an Array value, got Struct

What behaviour did you expect instead

I would expect options to still work as a hash, as before and as still documented. It seems like it's now mandatory to have it be an array.

Output log

Any additional information you'd like to impart

Updating from 1.5.0 to 4.0.0 has broken such code for me:

  # interrupts : waaay too much data, we only care about network
  telegraf::input { 'interrupts-tagpass':
    plugin_type => 'interrupts',
    options     => {
      'tagpass' => [
        'irq'   => [ 'NET_RX', 'NET_TX' ],
      ]
    },
  }

The above created the following configuration:

[[inputs.interrupts]]
[inputs.interrupts.tagpass]
irq = ["NET_RX", "NET_TX"]

It now seems impossible to achieve it, as enclosing the options's {} into [] creates the 2nd line with double brackets, which no longer works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.