diff --git a/manifests/integrations/cassandra.pp b/manifests/integrations/cassandra.pp new file mode 100644 index 00000000..27bb0e0d --- /dev/null +++ b/manifests/integrations/cassandra.pp @@ -0,0 +1,44 @@ +# Class: datadog_agent::integrations::cassandra +# +# This class will install the necessary configuration for the Cassandra +# integration +# +# Parameters: +# $host: +# The hostname Cassandra is running on +# $port: +# The port to connect on +# $user +# The user for the datadog user +# $password +# The password for the datadog user +# $tags +# Optional array of tags +# +# Sample Usage: +# +# class { 'datadog_agent::integrations::cassandra' : +# host => 'localhost', +# } +# +# +class datadog_agent::integrations::cassandra( + $host = 'localhost', + $port = 7199, + $user = undef, + $password = undef, + $tags = [], +) inherits datadog_agent::params { + require ::datadog_agent + validate_array($tags) + + file { "${datadog_agent::params::conf_dir}/cassandra.yaml": + ensure => file, + owner => $datadog_agent::params::dd_user, + group => $datadog_agent::params::dd_group, + mode => '0600', + content => template('datadog_agent/agent-conf.d/cassandra.yaml.erb'), + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], + } +} diff --git a/spec/classes/datadog_agent_integrations_cassandra_spec.rb b/spec/classes/datadog_agent_integrations_cassandra_spec.rb new file mode 100644 index 00000000..52eb2dd8 --- /dev/null +++ b/spec/classes/datadog_agent_integrations_cassandra_spec.rb @@ -0,0 +1,66 @@ +require 'spec_helper' + +describe 'datadog_agent::integrations::cassandra' 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}/cassandra.yaml" } + + context 'with password set' do + let(:params) {{ + user: 'datadog', + password: 'foobar', + }} + + 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}]") } + + it { should contain_file(conf_file).with_content(%r{password: foobar}) } + it { should contain_file(conf_file).without_content(%r{tags: }) } + + context 'with defaults' do + it { should contain_file(conf_file).with_content(%r{host: localhost}) } + it { should contain_file(conf_file).with_content(%r{user: datadog}) } + end + + context 'with parameters set' do + let(:params) {{ + password: 'foobar', + host: 'cassandra1', + user: 'baz', + }} + + it { should contain_file(conf_file).with_content(%r{password: foobar}) } + it { should contain_file(conf_file).with_content(%r{host: cassandra1}) } + it { should contain_file(conf_file).with_content(%r{user: baz}) } + end + + context 'with tags parameter array' do + let(:params) {{ + password: 'foobar', + tags: %w{ foo bar baz }, + }} + it { should contain_file(conf_file).with_content(/tags:[^-]+- foo\s+- bar\s+- baz\s*?[^-]/m) } + end + + context 'tags not array' do + let(:params) {{ + password: 'foobar', + tags: 'aoeu', + }} + + it { should_not compile } + end + end +end diff --git a/templates/agent-conf.d/cassandra.yaml.erb b/templates/agent-conf.d/cassandra.yaml.erb new file mode 100644 index 00000000..c72b925b --- /dev/null +++ b/templates/agent-conf.d/cassandra.yaml.erb @@ -0,0 +1,106 @@ +# +# MANAGED BY PUPPET +# + +instances: + - host: <%= @host %> + port: <%= @port %> + cassandra_aliasing: true +<% if @user -%> + user: <%= @user %> + password: <%= @password %> +<% end -%> +<% if @tags.length > 0 -%> + tags: +<% @tags.each do |tag| -%> + - <%= tag %> +<% end -%> +<% end -%> + +init_config: + # List of metrics to be collected by the integration + # Read http://docs.datadoghq.com/integrations/java/ to learn how to customize it + conf: + - include: + domain: org.apache.cassandra.metrics + type: ClientRequest + scope: + - Read + - Write + name: + - Latency + - Timeouts + - Unavailables + attribute: + - Count + - OneMinuteRate + - include: + domain: org.apache.cassandra.metrics + type: ClientRequest + scope: + - Read + - Write + name: + - TotalLatency + - include: + domain: org.apache.cassandra.metrics + type: Storage + name: + - Load + - Exceptions + - include: + domain: org.apache.cassandra.metrics + type: ColumnFamily + bean_regex: + - .*keyspace=.* + name: + - TotalDiskSpaceUsed + - BloomFilterDiskSpaceUsed + - BloomFilterFalsePositives + - BloomFilterFalseRatio + - CompressionRatio + - LiveDiskSpaceUsed + - LiveSSTableCount + - MaxRowSize + - MeanRowSize + - MemtableColumnsCount + - MemtableLiveDataSize + - MemtableSwitchCount + - MinRowSize + exclude: + keyspace: + - OpsCenter + - system + - system_auth + - system_distributed + - system_schema + - system_traces + - include: + domain: org.apache.cassandra.metrics + type: Cache + name: + - Capacity + - Size + attribute: + - Value + - include: + domain: org.apache.cassandra.metrics + type: Cache + name: + - Hits + - Requests + attribute: + - Count + - include: + domain: org.apache.cassandra.metrics + type: ThreadPools + path: request + name: + - ActiveTasks + - CompletedTasks + - PendingTasks + - CurrentlyBlockedTasks + - include: + domain: org.apache.cassandra.db + attribute: + - UpdateInterval