Skip to content
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

Add couchbase recipe. #487

Merged
merged 2 commits into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions recipes/couchbase.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
include_recipe 'datadog::dd-agent'

# Monitor couchbase
#
# Assuming you have 2 instances on the same host
# you need to set up the following attributes.
# Each instance's metric will be tagged with "instance:server_url".
# to help you differentiate between instances.
#
# node['datadog']['couchbase']['instances'] = [
# {
# server: 'http://localhost:1234'
# },
# {
# server: 'http://localhost:4567'
# }
# ]

datadog_monitor 'couchbase' do
instances node['datadog']['couchbase']['instances']
end
42 changes: 42 additions & 0 deletions spec/integrations/couchbase_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
describe 'datadog::couchbase' do
expected_yaml = <<-EOF
init_config:

instances:
- server: http://localhost:8091
user: Administrator
password: default
EOF

cached(:chef_run) do
ChefSpec::SoloRunner.new(step_into: ['datadog_monitor']) do |node|
node.automatic['languages'] = { 'python' => { 'version' => '2.7.2' } }
node.set['datadog'] = {
api_key: 'someapikey',
couchbase: {
instances: [
{
server: 'http://localhost:8091',
username: 'Administrator',
password: 'default'
}
]
}
}
end.converge(described_recipe)
end

subject { chef_run }

it_behaves_like 'datadog-agent'

it { is_expected.to include_recipe('datadog::dd-agent') }

it { is_expected.to add_datadog_monitor('couchbase') }

it 'renders expected YAML config file' do
expect(chef_run).to(render_file('/etc/dd-agent/conf.d/couchbase.yaml').with_content { |content|
expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json)
})
end
end
7 changes: 7 additions & 0 deletions templates/default/couchbase.yaml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
instances:
<% @instances.each do |i| -%>
- server: <%= i['server'] %>
user: <%= @node.fetch('couchbase', {}).fetch('server', {}).fetch('username', i.fetch('username', 'Administrator')) %>
password: <%= @node.fetch('couchbase', {}).fetch('server', {}).fetch('password', i.fetch('password', '')) %>
<% end %>
init_config: