Skip to content

Commit

Permalink
Adds support for collecting elasticsearch index_stats (#666)
Browse files Browse the repository at this point in the history
* Adds support for collecting elasticsearch index_stats

Datadog integration now supports collecting index_stats. This PR adds
support to include those stats.

* Update spec/classes/datadog_agent_integrations_elasticsearch_spec.rb

Co-authored-by: Pablo Baeyens <[email protected]>

Co-authored-by: Pablo Baeyens <[email protected]>
  • Loading branch information
Charles Ferguson and mx-psi authored Oct 26, 2020
1 parent dd544b7 commit 92d5db5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions manifests/integrations/elasticsearch.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#
class datadog_agent::integrations::elasticsearch(
Boolean $cluster_stats = false,
Boolean $index_stats = false,
Optional[String] $password = undef,
Boolean$pending_task_stats = true,
Boolean $pshard_stats = false,
Expand All @@ -47,6 +48,7 @@
if !$instances and $url {
$_instances = [{
'cluster_stats' => $cluster_stats,
'index_stats' => $index_stats,
'password' => $password,
'pending_task_stats' => $pending_task_stats,
'pshard_stats' => $pshard_stats,
Expand Down
5 changes: 5 additions & 0 deletions spec/classes/datadog_agent_integrations_elasticsearch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
context 'with default parameters' do
it { is_expected.to contain_file(conf_file).with_content(%r{ - url: http://localhost:9200}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ cluster_stats: false}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ index_stats: false}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ pending_task_stats: true}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ pshard_stats: false}) }
it { is_expected.not_to contain_file(conf_file).with_content(%r{ username}) }
Expand Down Expand Up @@ -66,6 +67,7 @@
instances: [
{
'cluster_stats' => true,
'index_stats' => false,
'password' => 'password',
'pending_task_stats' => false,
'pshard_stats' => true,
Expand All @@ -78,6 +80,7 @@
},
{
'cluster_stats' => false,
'index_stats' => true,
'password' => 'password_2',
'pending_task_stats' => true,
'pshard_stats' => false,
Expand All @@ -93,6 +96,7 @@
it { is_expected.to contain_file(conf_file).with_content(%r{instances:}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ - url: https://foo:4242}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ cluster_stats: true}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ index_stats: false}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ pending_task_stats: false}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ username: username}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ password: password}) }
Expand All @@ -103,6 +107,7 @@
it { is_expected.to contain_file(conf_file).with_content(%r{ tags:\n - tag1:key1}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ - url: https://bar:2424}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ cluster_stats: false}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ index_stats: true}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ pending_task_stats: true}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ username: username_2}) }
it { is_expected.to contain_file(conf_file).with_content(%r{ password: password_2}) }
Expand Down
1 change: 1 addition & 0 deletions templates/agent-conf.d/elastic.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ instances:
password: <%= instance['password'] %>
<%- end -%>
cluster_stats: <%= instance['cluster_stats'] %>
index_stats: <%= instance['index_stats'] %>
pshard_stats: <%= instance['pshard_stats'] %>
pending_task_stats: <%= instance['pending_task_stats'] %>
<%- if instance['url'].match(/^https/) -%>
Expand Down

0 comments on commit 92d5db5

Please sign in to comment.