Skip to content

Commit 570288b

Browse files
committed
Added Cassandra integration support
1 parent 71d0987 commit 570288b

3 files changed

Lines changed: 216 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Class: datadog_agent::integrations::cassandra
2+
#
3+
# This class will install the necessary configuration for the Cassandra
4+
# integration
5+
#
6+
# Parameters:
7+
# $host:
8+
# The hostname Cassandra is running on
9+
# $port:
10+
# The port to connect on
11+
# $user
12+
# The user for the datadog user
13+
# $password
14+
# The password for the datadog user
15+
# $tags
16+
# Optional array of tags
17+
#
18+
# Sample Usage:
19+
#
20+
# class { 'datadog_agent::integrations::cassandra' :
21+
# host => 'localhost',
22+
# }
23+
#
24+
#
25+
class datadog_agent::integrations::cassandra(
26+
$host = 'localhost',
27+
$port = 7199,
28+
$user = undef,
29+
$password = undef,
30+
$tags = [],
31+
) inherits datadog_agent::params {
32+
require ::datadog_agent
33+
validate_array($tags)
34+
35+
file { "${datadog_agent::params::conf_dir}/cassandra.yaml":
36+
ensure => file,
37+
owner => $datadog_agent::params::dd_user,
38+
group => $datadog_agent::params::dd_group,
39+
mode => '0600',
40+
content => template('datadog_agent/agent-conf.d/cassandra.yaml.erb'),
41+
require => Package[$datadog_agent::params::package_name],
42+
notify => Service[$datadog_agent::params::service_name],
43+
}
44+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
require 'spec_helper'
2+
3+
describe 'datadog_agent::integrations::cassandra' do
4+
let(:facts) {{
5+
operatingsystem: 'Ubuntu',
6+
}}
7+
let(:conf_dir) { '/etc/dd-agent/conf.d' }
8+
let(:dd_user) { 'dd-agent' }
9+
let(:dd_group) { 'root' }
10+
let(:dd_package) { 'datadog-agent' }
11+
let(:dd_service) { 'datadog-agent' }
12+
let(:conf_file) { "#{conf_dir}/cassandra.yaml" }
13+
14+
context 'with password set' do
15+
let(:params) {{
16+
user: 'datadog',
17+
password: 'foobar',
18+
}}
19+
20+
it { should compile.with_all_deps }
21+
it { should contain_file(conf_file).with(
22+
owner: dd_user,
23+
group: dd_group,
24+
mode: '0600',
25+
)}
26+
it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") }
27+
it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") }
28+
29+
it { should contain_file(conf_file).with_content(%r{password: foobar}) }
30+
it { should contain_file(conf_file).without_content(%r{tags: }) }
31+
32+
context 'with defaults' do
33+
it { should contain_file(conf_file).with_content(%r{host: localhost}) }
34+
it { should contain_file(conf_file).with_content(%r{user: datadog}) }
35+
end
36+
37+
context 'with parameters set' do
38+
let(:params) {{
39+
password: 'foobar',
40+
host: 'cassandra1',
41+
user: 'baz',
42+
}}
43+
44+
it { should contain_file(conf_file).with_content(%r{password: foobar}) }
45+
it { should contain_file(conf_file).with_content(%r{host: cassandra1}) }
46+
it { should contain_file(conf_file).with_content(%r{user: baz}) }
47+
end
48+
49+
context 'with tags parameter array' do
50+
let(:params) {{
51+
password: 'foobar',
52+
tags: %w{ foo bar baz },
53+
}}
54+
it { should contain_file(conf_file).with_content(/tags:[^-]+- foo\s+- bar\s+- baz\s*?[^-]/m) }
55+
end
56+
57+
context 'tags not array' do
58+
let(:params) {{
59+
password: 'foobar',
60+
tags: 'aoeu',
61+
}}
62+
63+
it { should_not compile }
64+
end
65+
end
66+
end
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#
2+
# MANAGED BY PUPPET
3+
#
4+
5+
instances:
6+
- host: <%= @host %>
7+
port: <%= @port %>
8+
cassandra_aliasing: true
9+
<% if @user -%>
10+
user: <%= @user %>
11+
password: <%= @password %>
12+
<% end -%>
13+
<% if @tags.length > 0 -%>
14+
tags:
15+
<% @tags.each do |tag| -%>
16+
- <%= tag %>
17+
<% end -%>
18+
<% end -%>
19+
20+
init_config:
21+
# List of metrics to be collected by the integration
22+
# Read http://docs.datadoghq.com/integrations/java/ to learn how to customize it
23+
conf:
24+
- include:
25+
domain: org.apache.cassandra.metrics
26+
type: ClientRequest
27+
scope:
28+
- Read
29+
- Write
30+
name:
31+
- Latency
32+
- Timeouts
33+
- Unavailables
34+
attribute:
35+
- Count
36+
- OneMinuteRate
37+
- include:
38+
domain: org.apache.cassandra.metrics
39+
type: ClientRequest
40+
scope:
41+
- Read
42+
- Write
43+
name:
44+
- TotalLatency
45+
- include:
46+
domain: org.apache.cassandra.metrics
47+
type: Storage
48+
name:
49+
- Load
50+
- Exceptions
51+
- include:
52+
domain: org.apache.cassandra.metrics
53+
type: ColumnFamily
54+
bean_regex:
55+
- .*keyspace=.*
56+
name:
57+
- TotalDiskSpaceUsed
58+
- BloomFilterDiskSpaceUsed
59+
- BloomFilterFalsePositives
60+
- BloomFilterFalseRatio
61+
- CompressionRatio
62+
- LiveDiskSpaceUsed
63+
- LiveSSTableCount
64+
- MaxRowSize
65+
- MeanRowSize
66+
- MemtableColumnsCount
67+
- MemtableLiveDataSize
68+
- MemtableSwitchCount
69+
- MinRowSize
70+
exclude:
71+
keyspace:
72+
- OpsCenter
73+
- system
74+
- system_auth
75+
- system_distributed
76+
- system_schema
77+
- system_traces
78+
- include:
79+
domain: org.apache.cassandra.metrics
80+
type: Cache
81+
name:
82+
- Capacity
83+
- Size
84+
attribute:
85+
- Value
86+
- include:
87+
domain: org.apache.cassandra.metrics
88+
type: Cache
89+
name:
90+
- Hits
91+
- Requests
92+
attribute:
93+
- Count
94+
- include:
95+
domain: org.apache.cassandra.metrics
96+
type: ThreadPools
97+
path: request
98+
name:
99+
- ActiveTasks
100+
- CompletedTasks
101+
- PendingTasks
102+
- CurrentlyBlockedTasks
103+
- include:
104+
domain: org.apache.cassandra.db
105+
attribute:
106+
- UpdateInterval

0 commit comments

Comments
 (0)