Giter Site home page Giter Site logo

alexdahlman / telegraf-cookbook Goto Github PK

View Code? Open in Web Editor NEW

This project forked from northpage/telegraf-cookbook

0.0 2.0 0.0 103 KB

Cookbook to install and manage telegraf

Home Page: https://supermarket.chef.io/cookbooks/telegraf

License: Apache License 2.0

Ruby 100.00%

telegraf-cookbook's Introduction

telegraf

Build Status

Cookbook to install and configure telegraf

This was influenced by SimpleFinanace/chef-influxdb

Note: Some inputs will require other packages be installed and that is out of scope for this cookbook. ie. [netstat] requires lsof

Tested Platforms

  • CentOS 6.8 and 7.3
  • Ubuntu 15.04 and 16.04
  • Amazon Linux
  • Windows 2012R2
  • Mac OSX 10.12.x and 10.13.x

Requirements

  • Chef 12.5+

Usage

This cookbook can be used by including telegraf::default in your run list and settings attributes
as needed. Alternatively, you can use the custom resources directly.

Attributes

Key Type Description Default
node['telegraf']['version'] String Version of telegraf to install, nil = latest '0.10.0-1'
node['telegraf']['config_file_path'] String Location of the telgraf main config file '/etc/telegraf/telegraf.conf'
node['telegraf']['config'] Hash Config variables to be written to the telegraf config {'tags' => {},'agent' => {'interval' => '10s','round_interval' => true,'flush_interval' => '10s','flush_jitter' => '5s'}
node['telegraf']['outputs'] Hash telegraf outputs {'influxdb' => {'urls' => ['http://localhost:8086'],'database' => 'telegraf','precision' => 's'}}
node['telegraf']['include_repository'] [TrueClass, FalseClass] Whether or not to pull in the InfluxDB repository to install from. true
node['telegraf']['inputs'] Hash telegraf inputs {'cpu' => {'percpu' => true,'totalcpu' => true,'drop' => ['cpu_time'],},'disk' => {},'io' => {},'mem' => {},'net' => {},'swap' => {},'system' => {}}
node['telegraf']['perf_counters'] Hash telegraf performance counters {{ 'Processor' => { 'Instances' => ['*'] 'Counters' => ['% Idle Time','% Interrupt Time','% Privileged Time','% User Time','% Processor Time','% DPC Time',],'Measurement' => 'win_cpu','IncludeTotal' => true}}

Custom Resources

telegraf_install

Installs telegraf and configures the service. Optionally specifies a version, otherwise the latest available is installed. The default installation type is package. For windows this defaults to chocolatey_package. If Chocolatey is not installed the resource will install this for you. Alternatively you can use the installation type file which will download and install the package.

telegraf_install 'default' do
  install_version '0.10.0-1'
  install_type 'package'
  action :create
end

telegraf_config

Writes out the telegraf configuration file. Optionally includes outputs and inputs.

telegraf_config 'default' do
  path node['telegraf']['config_file_path']
  config node['telegraf']['config']
  outputs node['telegraf']['outputs']
  inputs node['telegraf']['inputs']
  perf_counters node['telegraf']['perf_counters']  
end

telegraf_outputs

Writes out telegraf outputs configuration file. You can call this several times to create multiple outputs config files.

telegraf_outputs 'default' do
  outputs node['telegraf']['outputs']
end

telegraf_inputs

Writes out telegraf inputs configuration file.

telegraf_inputs 'default' do
  inputs node['telegraf']['inputs']
end

You can call this several times to create multiple inputs config files. You'll need to specify different names for each telegraf_inputs resource, so they'll create separate config files.

For example, to add the nginx input:

node.default['telegraf']['nginx'] = {
  'nginx' => {
    'urls' => ['http://localhost/status']
  }
}

telegraf_inputs 'nginx' do
  inputs node['telegraf']['nginx']
  service_name 'default'
  reload true
  rootonly false
end

Note that there are three optional parameters for this resource that could've been left out in this case:

  • service_name [default: 'default'] if you need to override which service should be restarted when the config changes;
  • reload [default: true] whether to restart the service when the config changes;
  • rootonly [default: false] whether to restrict access to the config file so it's not world readable;

telegraf_perf_counters

Writes out telegraf performance counters configuration file for windows hosts only.

telegraf_perf_counters 'default' do
  perf_counters node['telegraf']['perf_counters']
end

You can call this several times to create multiple performance counter config files. You'll need to specify different names for each telegraf_perf_counters resource, so they'll create separate config files.

For example, to add a network interface performance counter:

node.default['telegraf']['network_interface'] = {
  'Network Interface' => {
    'Instances' => ['*'],
    'Counters' => [
      "Bytes Received/sec",
      "Bytes Sent/sec",
      "Packets Received/sec",
      "Packets Sent/sec",
    ],
    'Measurement' => 'win_net',
  },
}

telegraf_perf_counters 'network_interface' do
  perf_counters node['telegraf']['network_interface']
  service_name 'default'
  reload true
end

For more examples visit influxdata/telegraf/plugins/inputs/win_perf_counters

Note that there are three optional parameters for this resource that could've been left out in this case:

  • service_name [default: 'default'] if you need to override which service should be restarted when the config changes;
  • reload [default: true] whether to restart the service when the config changes;

License and Authors

Copyright (C) 2015-2017 NorthPage

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

telegraf-cookbook's People

Contributors

fishnix avatar tenyo avatar sauraus avatar plork avatar codylewandowski avatar kjschnei001 avatar snkutlu avatar brennentsmith avatar frank-m avatar greglu avatar thesas avatar scottmlikens avatar bli111 avatar don-code avatar phromo avatar

Watchers

James Cloos avatar Alex Dahlman avatar

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.