-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
datadog integration for twemproxy, options for haproxy #326
Merged
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
21ad403
add instances parameter
swwolf 4a7ba23
building config from instances
swwolf 580fbfe
spec test for instances set
swwolf 41b1334
Merge remote-tracking branch 'upstream/master'
swwolf c8ae322
Merge branch 'master' of github.com:swwolf/puppet-datadog-agent
swwolf 68df3e3
adding datadog integration for twemproxy
swwolf 48210c4
add options to haproxy integration
swwolf 0040520
Merge remote-tracking branch 'upstream/master'
swwolf 5a70b44
following instances pattern for twemproxy integration
swwolf 18f285f
fix twemproxy template typo
swwolf 5b650c1
fix twemproxy template typo
swwolf d9dd979
fix twemproxy param error
swwolf 9a54cfe
fix spec test
swwolf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Class: datadog_agent::integrations::twemproxy | ||
# | ||
# This class will install the necessary configuration for the twemproxy aka nutcracker integration | ||
# | ||
# Parameters: | ||
# $host: | ||
# The host twemproxy is running on. Defaults to '127.0.0.1' | ||
# $port | ||
# The twemproxy password for the datadog user. Defaults to 22222 | ||
# | ||
# Sample Usage: | ||
# | ||
# class { 'datadog_agent::integrations::twemproxy' : | ||
# servers => [ | ||
# { | ||
# 'host' => 'localhost', | ||
# 'port' => '22222', | ||
# }, | ||
# { | ||
# 'host' => 'localhost', | ||
# 'port' => '22223', | ||
# }, | ||
# ] | ||
# } | ||
# | ||
class datadog_agent::integrations::twemproxy( | ||
$servers = [{'host' => 'localhost', 'port' => '22222'}] | ||
) inherits datadog_agent::params { | ||
include datadog_agent | ||
|
||
validate_array($servers) | ||
|
||
file { "${datadog_agent::params::conf_dir}/twemproxy.yaml": | ||
ensure => file, | ||
owner => $datadog_agent::params::dd_user, | ||
group => $datadog_agent::params::dd_group, | ||
mode => '0600', | ||
content => template('datadog_agent/agent-conf.d/twemproxy.yaml.erb'), | ||
require => Package[$datadog_agent::params::package_name], | ||
notify => Service[$datadog_agent::params::service_name] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'spec_helper' | ||
|
||
describe 'datadog_agent::integrations::twemproxy' do | ||
let(:facts) {{ | ||
operatingsystem: 'Ubuntu', | ||
}} | ||
let(:conf_dir) { '/etc/dd-agent/conf.d' } | ||
let(:dd_user) { 'dd-agent' } | ||
let(:dd_group) { 'root' } | ||
let(:dd_package) { 'datadog-agent' } | ||
let(:dd_service) { 'datadog-agent' } | ||
let(:conf_file) { "#{conf_dir}/twemproxy.yaml" } | ||
|
||
it { should compile.with_all_deps } | ||
it { should contain_file(conf_file).with( | ||
owner: dd_user, | ||
group: dd_group, | ||
mode: '0600', | ||
)} | ||
it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } | ||
it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } | ||
|
||
context 'with default parameters' do | ||
it { should contain_file(conf_file).with_content(%r{host: localhost}) } | ||
it { should contain_file(conf_file).with_content(%r{port: 22222}) } | ||
end | ||
|
||
context 'with parameters set' do | ||
let(:params) {{ | ||
servers: [ | ||
{ | ||
'host' => 'twemproxy1', | ||
'port' => '1234', | ||
}, | ||
{ | ||
'host' => 'twemproxy2', | ||
'port' => '4567', | ||
} | ||
] | ||
}} | ||
it { should contain_file(conf_file).with_content(%r{host: twemproxy1}) } | ||
it { should contain_file(conf_file).with_content(%r{port: 1234}) } | ||
it { should contain_file(conf_file).with_content(%r{host: twemproxy2}) } | ||
it { should contain_file(conf_file).with_content(%r{port: 4567}) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# | ||
# MANAGED BY PUPPET | ||
# | ||
|
||
init_config: | ||
|
||
instances: | ||
<% @servers.each do |server| -%> | ||
- host: <%= server['host'] %> | ||
port: <%= server['port'] %> | ||
<% end -%> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather respect the pattern we have in similar checks where we have arguments
host
andport
and maybe some basic options (for single instance) and then aninstances
argument for users who wish to specify multiple instances for the check. Don't get me wrong, this is perfectly fine, but it breaks a pattern used widely across the check.I am aware that
mongo
andzk
both follow this approach you have here, but I'd rather have that be the exception. Most integrations follow the pattern you can seehaproxy
. If you could fix that up, and theerb
, which should be easy, that would be great.