Skip to content

Commit

Permalink
Merge pull request DataDog#235 from mubi/add-etcd
Browse files Browse the repository at this point in the history
Adding recipe and template for etcd integration.
  • Loading branch information
miketheman committed Oct 15, 2015
2 parents 0687ddf + eb74a40 commit 0bdb73a
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,21 @@ suites:
user: someuser
password: somepass

- name: datadog_etcd
run_list:
- recipe[datadog::etcd]
attributes:
datadog:
<<: *DATADOG
etcd:
instances:
- url: http://localhost:2379
timeout: 5
ssl_keyfile: /etc/etcd/ssl.key
ssl_certfile: /etc/etcd/ssl.crt
ssl_cert_validation: true
ssl_ca_certs: /etc/etcd/ca-certs.crt

- name: datadog_docker
run_list:
- recipe[datadog::docker]
Expand Down
24 changes: 24 additions & 0 deletions recipes/etcd.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
include_recipe 'datadog::dd-agent'

# Monitor etcd
#
# API endpoint of your etcd instance
# - url: "https://server:port"
# Change the time to wait on an etcd API request
# timeout: 5
#
# If certificate-based authentication of clients is enabled on your etcd server,
# specify the key file and the certificate file that the check should use.
# ssl_keyfile: /path/to/key/file
# ssl_certfile: /path/to/certificate/file
#
# Set to `false` to disable the validation of the server's SSL certificates (default: true).
# ssl_cert_validation: true
#
# If ssl_cert_validation is enabled, you can provide a custom file
# that lists trusted CA certificates (optional).
# ssl_ca_certs: /path/to/CA/certificate/file

datadog_monitor 'etcd' do
instances node['datadog']['etcd']['instances']
end
12 changes: 12 additions & 0 deletions templates/default/etcd.yaml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
instances:
<% @instances.each do |i| -%>
- url: <%= i['url'] %>
<% if i['timeout'] -%>timeout: <%= i['timeout'] %><% end -%>
<% if i['ssl_keyfile'] -%>ssl_keyfile: <%= i['ssl_keyfile'] %><% end -%>
<% if i['ssl_certfile'] -%>ssl_certfile: <%= i['ssl_certfile'] %><% end -%>
<% if i['ssl_cert_validation'] -%>ssl_cert_validation: <%= i['ssl_cert_validation'] %><% end -%>
<% if i['ssl_ca_certs'] -%>ssl_ca_certs: <%= i['ssl_ca_certs'] %><% end -%>
<% end -%>

# Nothing to configure here
init_config:
3 changes: 3 additions & 0 deletions test/integration/datadog_etcd/serverspec/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gem 'json_spec', '~> 1.1'
37 changes: 37 additions & 0 deletions test/integration/datadog_etcd/serverspec/etcd_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Encoding: utf-8
require 'json_spec'
require 'serverspec'
require 'yaml'

set :backend, :exec
set :path, '/sbin:/usr/local/sbin:$PATH'

AGENT_CONFIG = '/etc/dd-agent/conf.d/etcd.yaml'

describe service('datadog-agent') do
it { should be_running }
end

describe file(AGENT_CONFIG) do
it { should be_a_file }

it 'is valid yaml matching input values' do
generated = YAML.load_file(AGENT_CONFIG)

expected = {
'instances' => [
{
'url' => 'http://localhost:2379',
'timeout' => 5,
'ssl_keyfile' => '/etc/etcd/ssl.key',
'ssl_certfile' => '/etc/etcd/ssl.crt',
'ssl_cert_validation' => true,
'ssl_ca_certs' => '/etc/etcd/ca-certs.crt'
}
],
'init_config' => nil
}

expect(generated.to_json).to be_json_eql expected.to_json
end
end

0 comments on commit 0bdb73a

Please sign in to comment.