Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[elasticsearch] Restricts 1.x specific stats to v1.x #2232

Merged
merged 3 commits into from
Apr 8, 2016
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
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ env:
- TRAVIS_FLAVOR=elasticsearch FLAVOR_VERSION=1.5.2
- TRAVIS_FLAVOR=elasticsearch FLAVOR_VERSION=1.6.2
- TRAVIS_FLAVOR=elasticsearch FLAVOR_VERSION=1.7.4
- TRAVIS_FLAVOR=elasticsearch FLAVOR_VERSION=2.0.2
- TRAVIS_FLAVOR=elasticsearch FLAVOR_VERSION=2.1.1
- TRAVIS_FLAVOR=etcd
- TRAVIS_FLAVOR=fluentd
- TRAVIS_FLAVOR=go_expvar
Expand Down
26 changes: 21 additions & 5 deletions checks.d/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ class ESCheck(AgentCheck):
"elasticsearch.thread_pool.management.active": ("gauge", "thread_pool.management.active"),
"elasticsearch.thread_pool.management.threads": ("gauge", "thread_pool.management.threads"),
"elasticsearch.thread_pool.management.queue": ("gauge", "thread_pool.management.queue"),
"elasticsearch.thread_pool.merge.active": ("gauge", "thread_pool.merge.active"),
"elasticsearch.thread_pool.merge.threads": ("gauge", "thread_pool.merge.threads"),
"elasticsearch.thread_pool.merge.queue": ("gauge", "thread_pool.merge.queue"),
"elasticsearch.thread_pool.percolate.active": ("gauge", "thread_pool.percolate.active"),
"elasticsearch.thread_pool.percolate.threads": ("gauge", "thread_pool.percolate.threads"),
"elasticsearch.thread_pool.percolate.queue": ("gauge", "thread_pool.percolate.queue"),
Expand Down Expand Up @@ -183,11 +180,14 @@ class ESCheck(AgentCheck):

ADDITIONAL_METRICS_POST_0_90_5 = {
"elasticsearch.search.fetch.open_contexts": ("gauge", "indices.search.open_contexts"),
"elasticsearch.fielddata.size": ("gauge", "indices.fielddata.memory_size_in_bytes"),
"elasticsearch.fielddata.evictions": ("gauge", "indices.fielddata.evictions"),
}

ADDITIONAL_METRICS_POST_0_90_5_PRE_2_0 = {
"elasticsearch.cache.filter.evictions": ("gauge", "indices.filter_cache.evictions"),
"elasticsearch.cache.filter.size": ("gauge", "indices.filter_cache.memory_size_in_bytes"),
"elasticsearch.id_cache.size": ("gauge", "indices.id_cache.memory_size_in_bytes"),
"elasticsearch.fielddata.size": ("gauge", "indices.fielddata.memory_size_in_bytes"),
"elasticsearch.fielddata.evictions": ("gauge", "indices.fielddata.evictions"),
}

ADDITIONAL_METRICS_PRE_0_90_5 = {
Expand All @@ -201,6 +201,9 @@ class ESCheck(AgentCheck):
ADDITIONAL_METRICS_POST_1_0_0 = {
"elasticsearch.indices.translog.size_in_bytes": ("gauge", "indices.translog.size_in_bytes"),
"elasticsearch.indices.translog.operations": ("gauge", "indices.translog.operations"),
}

ADDITIONAL_METRICS_1_x = { # Stats are only valid for v1.x
"elasticsearch.fs.total.disk_reads": ("rate", "fs.total.disk_reads"),
"elasticsearch.fs.total.disk_writes": ("rate", "fs.total.disk_writes"),
"elasticsearch.fs.total.disk_io_op": ("rate", "fs.total.disk_io_op"),
Expand All @@ -219,6 +222,12 @@ class ESCheck(AgentCheck):
"elasticsearch.indices.segments.fixed_bit_set_memory_in_bytes": ("gauge", "indices.segments.fixed_bit_set_memory_in_bytes"),
}

ADDITIONAL_METRICS_PRE_2_0 = {
"elasticsearch.thread_pool.merge.active": ("gauge", "thread_pool.merge.active"),
"elasticsearch.thread_pool.merge.threads": ("gauge", "thread_pool.merge.threads"),
"elasticsearch.thread_pool.merge.queue": ("gauge", "thread_pool.merge.queue"),
}

CLUSTER_HEALTH_METRICS = {
"elasticsearch.number_of_nodes": ("gauge", "number_of_nodes"),
"elasticsearch.number_of_data_nodes": ("gauge", "number_of_data_nodes"),
Expand Down Expand Up @@ -393,6 +402,13 @@ def _define_params(self, version, cluster_stats):
if version >= [1, 0, 0]:
stats_metrics.update(self.ADDITIONAL_METRICS_POST_1_0_0)

if version < [2, 0, 0]:
stats_metrics.update(self.ADDITIONAL_METRICS_PRE_2_0)
if version >= [0, 90, 5]:
stats_metrics.update(self.ADDITIONAL_METRICS_POST_0_90_5_PRE_2_0)
if version >= [1, 0, 0]:
stats_metrics.update(self.ADDITIONAL_METRICS_1_x)

if version >= [1, 3, 0]:
stats_metrics.update(self.ADDITIONAL_METRICS_POST_1_3_0)

Expand Down
31 changes: 24 additions & 7 deletions tests/checks/integration/test_elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@
"elasticsearch.thread_pool.management.active": ("gauge", "thread_pool.management.active"),
"elasticsearch.thread_pool.management.threads": ("gauge", "thread_pool.management.threads"),
"elasticsearch.thread_pool.management.queue": ("gauge", "thread_pool.management.queue"),
"elasticsearch.thread_pool.merge.active": ("gauge", "thread_pool.merge.active"),
"elasticsearch.thread_pool.merge.threads": ("gauge", "thread_pool.merge.threads"),
"elasticsearch.thread_pool.merge.queue": ("gauge", "thread_pool.merge.queue"),
"elasticsearch.thread_pool.percolate.active": ("gauge", "thread_pool.percolate.active"),
"elasticsearch.thread_pool.percolate.threads": ("gauge", "thread_pool.percolate.threads"),
"elasticsearch.thread_pool.percolate.queue": ("gauge", "thread_pool.percolate.queue"),
Expand Down Expand Up @@ -159,11 +156,14 @@

ADDITIONAL_METRICS_POST_0_90_5 = {
"elasticsearch.search.fetch.open_contexts": ("gauge", "indices.search.open_contexts"),
"elasticsearch.fielddata.size": ("gauge", "indices.fielddata.memory_size_in_bytes"),
"elasticsearch.fielddata.evictions": ("gauge", "indices.fielddata.evictions"),
}

ADDITIONAL_METRICS_POST_0_90_5_PRE_2_0 = {
"elasticsearch.cache.filter.evictions": ("gauge", "indices.filter_cache.evictions"),
"elasticsearch.cache.filter.size": ("gauge", "indices.filter_cache.memory_size_in_bytes"),
"elasticsearch.id_cache.size": ("gauge", "indices.id_cache.memory_size_in_bytes"),
"elasticsearch.fielddata.size": ("gauge", "indices.fielddata.memory_size_in_bytes"),
"elasticsearch.fielddata.evictions": ("gauge", "indices.fielddata.evictions"),
}

ADDITIONAL_METRICS_PRE_0_90_5 = {
Expand All @@ -177,6 +177,9 @@
ADDITIONAL_METRICS_POST_1_0_0 = {
"elasticsearch.indices.translog.size_in_bytes": ("gauge", "indices.translog.size_in_bytes"),
"elasticsearch.indices.translog.operations": ("gauge", "indices.translog.operations"),
}

ADDITIONAL_METRICS_1_x = {
# Currently has issues in test framework:
# "elasticsearch.fs.total.disk_reads": ("rate", "fs.total.disk_reads"),
# "elasticsearch.fs.total.disk_writes": ("rate", "fs.total.disk_writes"),
Expand All @@ -196,6 +199,12 @@
"elasticsearch.indices.segments.fixed_bit_set_memory_in_bytes": ("gauge", "indices.segments.fixed_bit_set_memory_in_bytes"),
}

ADDITIONAL_METRICS_PRE_2_0 = {
"elasticsearch.thread_pool.merge.active": ("gauge", "thread_pool.merge.active"),
"elasticsearch.thread_pool.merge.threads": ("gauge", "thread_pool.merge.threads"),
"elasticsearch.thread_pool.merge.queue": ("gauge", "thread_pool.merge.queue"),
}

CLUSTER_HEALTH_METRICS = {
"elasticsearch.number_of_nodes": ("gauge", "number_of_nodes"),
"elasticsearch.number_of_data_nodes": ("gauge", "number_of_data_nodes"),
Expand Down Expand Up @@ -274,21 +283,29 @@ def test_check(self):
if es_version >= [1, 0, 0]:
expected_metrics.update(ADDITIONAL_METRICS_POST_1_0_0)

if es_version < [2, 0, 0]:
expected_metrics.update(ADDITIONAL_METRICS_PRE_2_0)
if es_version >= [0, 90, 5]:
expected_metrics.update(ADDITIONAL_METRICS_POST_0_90_5_PRE_2_0)
if es_version >= [1, 0, 0]:
expected_metrics.update(ADDITIONAL_METRICS_1_x)

if es_version >= [1, 3, 0]:
expected_metrics.update(ADDITIONAL_METRICS_POST_1_3_0)

if es_version >= [1, 4, 0]:
expected_metrics.update(ADDITIONAL_METRICS_POST_1_4_0)

local_hostname = socket.gethostname() if es_version < [2, 0, 0] else '127.0.0.1'
contexts = [
(conf_hostname, default_tags + tags),
(socket.gethostname(), default_tags)
(local_hostname, default_tags)
]

for m_name, desc in expected_metrics.iteritems():
for hostname, m_tags in contexts:
if (m_name in CLUSTER_HEALTH_METRICS
and hostname == socket.gethostname()):
and hostname == local_hostname):
hostname = conf_hostname

if desc[0] == "gauge":
Expand Down