Skip to content

rplessl/puppet-telegraf

Repository files navigation

Overview

Build Status rplessl-telegraf

This puppet module installs and manages the configuration of InfluxData's Telegraf. A metrics collection agent.

Use this puppet module with Telegraf version 0.13.1 and newer.

This puppet module was designed and tested with Puppet 3.8.

Table of Contents

  1. Overview
  2. Module Description - What the module does and why it is useful
  3. Setup - The basics of getting started with telegraf
  4. Development - Guide for contributing to the module
  5. Testing - Guide to test the module
  6. License

Module Description

The module installs the telegraf package from the provided repositories and installs the basic configuration file and reconfigures this setup based on your whishes.

Supported Linux distributions are Debian based (Ubuntu, Debian) and RedHat based (CentOS, RHEL).

Tests have also be run on an raspberry pi 2 with raspbian (jessie).

Setup

Setup Requirements

puppet-telegraf requires these third party puppet modules

  • puppet-stdlibs
  • wget module when the parameter download_package is set to true.
  • apt module when the parameter manage_repo is set to true on Debian or Ubuntu.

Beginning with telegraf

Include the class and set the necessary Telegraf and InfluxDB parameters.

class { '::telegraf':
    version                   => '0.13.1',
    manage_repo               => true,
    config_template           => 'telegraf/telegraf.conf.erb',
    # [[outputs.influxdb]] section of telegraf.conf
    outputs_influxdb_enabled  => true,
    outputs_influxdb_urls     => ['http://influxdb-01.mydomain.com:8086', 'http://influxdb-02.mydomain.com:8086'],
    outputs_influxdb_database => 'telegraf',
    outputs_influxdb_username => 'telegraf',
    outputs_influxdb_password => 'metricsmetricsmetricsmetrics',
}

This puppet-telegraf module supports the following configuration options:

class { '::telegraf':
    ensure                    => 'installed',
    version                   => '0.13.1',
    download_package          => false,
    manage_repo               => false,
    config_template           => 'telegraf/telegraf.conf.erb',
    config_base_file          => '/etc/telegraf/telegraf.conf',
    config_directory          => '/etc/telegraf/telegraf.d',

    # [[outputs.influxdb]] section of telegraf.conf
    outputs_influxdb_enabled  => true,
    outputs_influxdb_urls     => ['http://localhost:8086'],
    outputs_influxdb_database => 'telegraf',
    outputs_influxdb_username => 'telegraf',
    outputs_influxdb_password => 'metricsmetricsmetricsmetrics',

    # [tags] section of telegraf.conf
    tags                      => {
      virtual            => $::virtual,
      lsbdistdescription => $::lsbdistdescription,
      environment        => $::my_own_facter_environment,
      location           => $::my_own_facter_location,
    }

    # [agent]
    agent_hostname            => $::hostname,
    agent_interval            => '10s',

    # [[plugins.cpu]]
    cpu_percpu                => true,
    cpu_totalcpu              => true,
    cpu_drop                  => ["cpu_time"],

    # [[plugins.disk]]
    disk_mountpoints          => ["/","/home"],
}

Plugins

The following plugins have been prepared for input / output configuration of Telegraf.

  1. OpenTSDB
class { '::telegraf::plugins::outputs::opentsdb':
  opentsdb_server => 'my.opentsdb.server.domain.com',
  opentsdb_port   => 4242,
  opentsdb_prefix => 'my.metrics.telegraf.',
}
  1. MySQL
include '::telegraf::plugins::inputs::mysql'
  1. PostgreSQL
include '::telegraf::plugins::inputs::postgresql'
  1. PuppetAgent
include '::telegraf::plugins::inputs::puppetagent'
  1. Elasticsearch
class { '::telegraf::plugins::inputs::elasticsearch': }
  1. Procstats
class { '::telegraf::plugins::inputs::procstats': }
  1. PowerDNS
class { '::telegraf::plugins::inputs::powerdns': }

Development

  1. Fork it (https://github.com/rplessl/puppet-telegraf/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Wish: Make sure your Pull Requests passes the Rspec tests.

Testing

Testing Code Enhancement (rspec)

Testing is done with rspec.

Testing Setup with Vagrant

Install and setup vagrant [https://docs.vagrantup.com/v2/installation/index.html](as described here).

Fetch virtual machines:

vagrant box add puppetlabs/ubuntu-16.04-64-puppet --insecure
vagrant box add puppetlabs/ubuntu-14.04-64-puppet --insecure
vagrant box add puppetlabs/debian-7.8-64-puppet   --insecure
vagrant box add puppetlabs/debian-8.2-64-puppet   --insecure
vagrant box add puppetlabs/centos-7.2-64-puppet   --insecure
vagrant box add puppetlabs/centos-6.6-64-puppet   --insecure

Add vagrant puppet support and run tests:

bundle install
bundle exec librarian-puppet install
vagrant up

License

Licensed under the MIT License.

Copyright (c) 2015-2016 Roman Plessl (@rplessl), Nine Internet Solutions AG and

Copyright (c) 2015-2016 Roman Plessl (@rplessl), Plessl + Burkhardt GmbH

See LICENSE File