cookbook 'telegraf', '= 0.11.0'
telegraf
(26) Versions
0.11.0
-
Follow11
Installs/Configures telegraf
cookbook 'telegraf', '= 0.11.0', :supermarket
knife supermarket install telegraf
knife supermarket download telegraf
telegraf
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.
Dependent cookbooks
apt >= 0.0.0 |
windows >= 0.0.0 |
yum >= 0.0.0 |
Contingent cookbooks
There are no cookbooks that are contingent upon this one.
Changelog
0.11.0
PR#68 - CI tests/linter fixes
PR#69 - change chocolatey and homebrew cookbooks to recommends
PR#71 - add possibility for chocolatey options
0.10.0
- PR#67 - Add support for non
amd64
architectures
0.9.2
- PR#66 - Fix Chef-13 warning for https://docs.chef.io/deprecations_namespace_collisions.html
- Cleanup all foodcritic warnings
0.9.1
- PR#65 - Chef-13 amazon compatibility fix
0.9.0
- PR#57 - Add Mac OS X install support
- PR#59 - Parameterize InfluxDB Package Repo URL
0.8.1
- PR#58 - Fixing :delete action for resource 'telegraf_outputs'
- PR#60 - Reverse CHANGELOG.md order so the newest releases are at the top
0.8.0
- PR#49 - Enumerate supported operating systems in metadata.rb
- PR#50 - Feature/windows support
0.7.0
- PR#48 - Removing default influxDB output
0.6.0
- PR#44 - Add tests for input file
- PR#47 - Change back to toml-rb gem
0.5.0
- Rename sensitive resource to rootonly as it will raise an exception in Chef13
- PR#37 - Add delete action to input/output LWRPs
- PR#40 - Add support for install_type=file
- PR#43 - Switch from toml-rb to toml gem
0.4.1
- PR#34 - Allow specifying gem source for toml-rb
0.4.0
- PR#21 - Fix incorrect config if 'toml-rb' > 0.3.12
- PR#27 - Default to latest telegraf; only use stable apt repo
- PR#30 - Add service restart retries
- Pin toml-rb to '~> 0.3.0'
0.3.5
- Pin toml-rb to v0.3.12
0.3.4
- PR#16 - fix installation on Amazon Linux; add tests for ubuntu 15.04 and amazon linux
- PR#19 - enforce permissions on config files, optionally suppress logging file updates
0.3.3
- Default to telegraf 0.10.2
0.3.2
- Bugfix telegraf_inputs chefspec matcher
0.3.1
- Default to telegraf 0.10.1
0.3.0
- Add initial support for telegraf 0.10.x
0.2.3
- Add LICENSE file
0.2.2
- Merge #12 Allow specifying whether or not to bring in external repository (don-code)
0.2.1
- Update matchers for chefspec testing
0.2.0
- Change format for output/plugins to not require a top level name
0.1.5
- Add sane defaults for plugins/outputs path
0.1.4
- Add install_version property to install resource to enforce specific telegraf version
0.1.3
- Add support for multiple outputs/plugins config files
0.1.2
- Add support for restarting the service when config changes
0.1.1
- Add source URL to metadata
0.1.0
- Initial release
Collaborator Number Metric
0.11.0 failed this metric
Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.
Contributing File Metric
0.11.0 passed this metric
Foodcritic Metric
0.11.0 failed this metric
FC007: Ensure recipe dependencies are reflected in cookbook metadata: telegraf/resources/install.rb:71
FC007: Ensure recipe dependencies are reflected in cookbook metadata: telegraf/resources/install.rb:73
FC053: Metadata uses the deprecated "recommends" keyword: telegraf/metadata.rb:18
FC053: Metadata uses the deprecated "recommends" keyword: telegraf/metadata.rb:19
Run with Foodcritic Version 14.0.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
No Binaries Metric
0.11.0 passed this metric
Testing File Metric
0.11.0 passed this metric
Version Tag Metric
0.11.0 passed this metric
0.11.0 failed this metric
0.11.0 passed this metric
Foodcritic Metric
0.11.0 failed this metric
FC007: Ensure recipe dependencies are reflected in cookbook metadata: telegraf/resources/install.rb:71
FC007: Ensure recipe dependencies are reflected in cookbook metadata: telegraf/resources/install.rb:73
FC053: Metadata uses the deprecated "recommends" keyword: telegraf/metadata.rb:18
FC053: Metadata uses the deprecated "recommends" keyword: telegraf/metadata.rb:19
Run with Foodcritic Version 14.0.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
No Binaries Metric
0.11.0 passed this metric
Testing File Metric
0.11.0 passed this metric
Version Tag Metric
0.11.0 passed this metric
0.11.0 failed this metric
FC007: Ensure recipe dependencies are reflected in cookbook metadata: telegraf/resources/install.rb:73
FC053: Metadata uses the deprecated "recommends" keyword: telegraf/metadata.rb:18
FC053: Metadata uses the deprecated "recommends" keyword: telegraf/metadata.rb:19
Run with Foodcritic Version 14.0.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any
0.11.0 passed this metric
Testing File Metric
0.11.0 passed this metric
Version Tag Metric
0.11.0 passed this metric
0.11.0 passed this metric
0.11.0 passed this metric