Skip to content
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
44 changes: 44 additions & 0 deletions manifests/integrations/cassandra.pp
Original file line number Diff line number Diff line change
@@ -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],
}
}
66 changes: 66 additions & 0 deletions spec/classes/datadog_agent_integrations_cassandra_spec.rb
Original file line number Diff line number Diff line change
@@ -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
106 changes: 106 additions & 0 deletions templates/agent-conf.d/cassandra.yaml.erb
Original file line number Diff line number Diff line change
@@ -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