Skip to content

Commit

Permalink
[elastic] Add config flags for shard level metrics
Browse files Browse the repository at this point in the history
Tested with test-kitchen.

Closes #221

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
  • Loading branch information
Etienne LAFARGE authored and miketheman committed Oct 15, 2015
1 parent 62158b8 commit a6c2256
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ suites:
username: someuser
password: somepass
is_external: false
pshard_stats: true
shard_level_metrics: true
tags:
- kitchen
- sink
Expand Down
37 changes: 37 additions & 0 deletions recipes/elasticsearch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,43 @@
# :tags => ['env:prod']
# }
# ]
#
# Additional flags:
#
# If you enable the "pshard_stats" flag, statistics over primary shards
# will be collected by the check and sent to the backend with the
# 'elasticsearch.primary' prefix. It is particularly useful if you want to
# get certain metrics without taking replicas into account. For instance,
# 'elasticsearch.primaries.docs.count` will give you the total number of
# documents in your indexes WITHOUT counting duplicates due to the existence
# of replica shards in your ES cluster
#
# The "shard_level_metrics" flag enables metrics and service checks on a per-
# shard basis (all the information is fetched under the /_stats?level=shards
# endpoint). The metrics and service check sent for each shard are named as
# such: elasticsearch.shard.metric.name .
# The shard name is computed according to elasticsearch's documentation. Each
# primary shard is named Pi (ex: P0, P1, P2...) and every replica shards will
# be named Ri (R0, R1, R2). In case the number of replicas is superior to 1,
# we stick to the following convention for shard names : Rx_y where x is the
# number of the associated primary shard while y is the replica number.
#
# Plase note that shard-level metrics will get the following extra tags:
# es_node:<node_name>, es_shard:<shard_name>, es_index:<index_name> and
# es_role:(primary|replica). They will also carry a "shard_specific" tag. It
# should enable you to slice and dice as you please in your DatadogHQ.
#
# Example:
#
# node['datadog']['elasticsearch']['instances'] = [
# {
# :url => 'http://localhost:9200',
# :tags => ['env:test'],
# :pshard_stats => true,
# :shard_level_metrics: true
# }
# ]
#

datadog_monitor 'elastic' do
instances node['datadog']['elasticsearch']['instances']
Expand Down
6 changes: 6 additions & 0 deletions templates/default/elastic.yaml.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
instances:
<% @instances.each do |i| -%>
- url: <%= i["url"] %>
<% unless i["shard_level_metrics"].nil? %>
shard_level_metrics: <%= i["shard_level_metrics"] %>
<% end %>
<% unless i["pshard_stats"].nil? %>
pshard_stats: <%= i["pshard_stats"] %>
<% end %>
<% unless i["is_external"].nil? %>
is_external: <%= i["is_external"] %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
'username' => 'someuser',
'password' => 'somepass',
'is_external' => false,
'pshard_stats' => true,
'shard_level_metrics' => true,
'tags' => ['kitchen', 'sink']
}
],
Expand Down

0 comments on commit a6c2256

Please sign in to comment.