sensu-plugins-elasticsearch 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/CHANGELOG.md +5 -0
- data/bin/check-es-query-count.rb +17 -11
- data/bin/metrics-es-cluster.rb +2 -2
- data/bin/metrics-es-node.rb +23 -5
- data/lib/sensu-plugins-elasticsearch/elasticsearch-query.rb +2 -1
- data/lib/sensu-plugins-elasticsearch/version.rb +1 -1
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7274d48632cbac489016fcc28073665e0221bd81
|
4
|
+
data.tar.gz: 3786345e742f828052e54fe80c1d2eb81c9b0cbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 660cbc6632fdc418a7dbc48525cd0b517ad7d7556ea5e8f4c87dc490993944c126ba1b74d82a99264eed7516b868726b56cf22b578be917b7e367806928a58eb
|
7
|
+
data.tar.gz: 5995bf40185ee2bb37007f918c88dd8d8cbdef86062bbf38f4d7f53ee018f20a1b026a9d6ee62d9388264251753c260139fddc1def8c6bf3c50e6cd84d5d70e5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,11 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
5
5
|
|
6
6
|
## Unreleased
|
7
7
|
|
8
|
+
## [0.3.1] - 2015-12-29
|
9
|
+
### Changed
|
10
|
+
- Update metrics-es-node.rb to use version checks consistent with other metrics
|
11
|
+
- Update metrics-es-cluster.rb to use `_stats` api instead of `/_count?q=*:*` see [Unbound wildcard range query cripples es on larger installs #20](https://github.com/sensu-plugins/sensu-plugins-elasticsearch/issues/20)
|
12
|
+
|
8
13
|
## [0.3.0] - 2015-11-18
|
9
14
|
### Changed
|
10
15
|
- Update metrics-es-node-graphite.rb, check-es-node-status.rb, and check-es-file-descriptors.rb for Elasticsearch 2.0
|
data/bin/check-es-query-count.rb
CHANGED
@@ -34,8 +34,7 @@
|
|
34
34
|
require 'sensu-plugin/check/cli'
|
35
35
|
require 'elasticsearch'
|
36
36
|
require 'time'
|
37
|
-
|
38
|
-
require_relative 'sensu-plugins-elasticsearch'
|
37
|
+
require 'sensu-plugins-elasticsearch'
|
39
38
|
|
40
39
|
#
|
41
40
|
# ES Heap
|
@@ -103,6 +102,13 @@ class ESQueryCount < Sensu::Plugin::Check::CLI
|
|
103
102
|
boolean: true,
|
104
103
|
default: false
|
105
104
|
|
105
|
+
option :search_field,
|
106
|
+
description: 'The Elasticsearch document field to search for your query string.',
|
107
|
+
short: '-f FIELD',
|
108
|
+
long: '--field FIELD',
|
109
|
+
required: false,
|
110
|
+
default: 'message'
|
111
|
+
|
106
112
|
option :query,
|
107
113
|
description: 'Elasticsearch query',
|
108
114
|
short: '-q QUERY',
|
@@ -168,29 +174,29 @@ class ESQueryCount < Sensu::Plugin::Check::CLI
|
|
168
174
|
response = client.count(build_request_options)
|
169
175
|
if config[:invert]
|
170
176
|
if response['count'] < config[:crit]
|
171
|
-
critical
|
177
|
+
critical "Query count (#{response['count']}) was below critical threshold"
|
172
178
|
elsif response['count'] < config[:warn]
|
173
|
-
warning
|
179
|
+
warning "Query count (#{response['count']}) was below warning threshold"
|
174
180
|
else
|
175
|
-
ok
|
181
|
+
ok "Query count (#{response['count']}) was ok"
|
176
182
|
end
|
177
183
|
else
|
178
184
|
if response['count'] > config[:crit]
|
179
|
-
critical
|
185
|
+
critical "Query count (#{response['count']}) was above critical threshold"
|
180
186
|
elsif response['count'] > config[:warn]
|
181
|
-
warning
|
187
|
+
warning "Query count (#{response['count']}) was above warning threshold"
|
182
188
|
else
|
183
|
-
ok
|
189
|
+
ok "Query count (#{response['count']}) was ok"
|
184
190
|
end
|
185
191
|
end
|
186
192
|
rescue Elasticsearch::Transport::Transport::Errors::NotFound
|
187
193
|
if config[:invert]
|
188
194
|
if response['count'] < config[:crit]
|
189
|
-
critical
|
195
|
+
critical "Query count (#{response['count']}) was below critical threshold"
|
190
196
|
elsif response['count'] < config[:warn]
|
191
|
-
warning
|
197
|
+
warning "Query count (#{response['count']}) was below warning threshold"
|
192
198
|
else
|
193
|
-
ok
|
199
|
+
ok "Query count (#{response['count']}) was ok"
|
194
200
|
end
|
195
201
|
else
|
196
202
|
ok 'No results found, count was below thresholds'
|
data/bin/metrics-es-cluster.rb
CHANGED
@@ -109,8 +109,8 @@ class ESClusterMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def acquire_document_count
|
112
|
-
document_count = get_es_resource('/
|
113
|
-
document_count['count']
|
112
|
+
document_count = get_es_resource('/_stats/docs')
|
113
|
+
document_count['_all']['total']['docs']['count']
|
114
114
|
end
|
115
115
|
|
116
116
|
def run
|
data/bin/metrics-es-node.rb
CHANGED
@@ -66,16 +66,34 @@ class ESMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
66
66
|
short: '-P PASS',
|
67
67
|
long: '--password PASS'
|
68
68
|
|
69
|
-
def
|
69
|
+
def acquire_es_version
|
70
|
+
info = get_es_resource('/')
|
71
|
+
info['version']['number']
|
72
|
+
end
|
73
|
+
|
74
|
+
def get_es_resource(resource)
|
70
75
|
headers = {}
|
71
76
|
if config[:user] && config[:password]
|
72
77
|
auth = 'Basic ' + Base64.encode64("#{config[:user]}:#{config[:password]}").chomp
|
73
78
|
headers = { 'Authorization' => auth }
|
74
79
|
end
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
80
|
+
r = RestClient::Resource.new("http://#{config[:host]}:#{config[:port]}#{resource}", timeout: config[:timeout], headers: headers)
|
81
|
+
JSON.parse(r.get)
|
82
|
+
rescue Errno::ECONNREFUSED
|
83
|
+
warning 'Connection refused'
|
84
|
+
rescue RestClient::RequestTimeout
|
85
|
+
warning 'Connection timed out'
|
86
|
+
end
|
87
|
+
|
88
|
+
def run
|
89
|
+
if Gem::Version.new(acquire_es_version) >= Gem::Version.new('1.0.0')
|
90
|
+
ln = get_es_resource('/_nodes/_local')
|
91
|
+
stats = get_es_resource('/_nodes/_local/stats')
|
92
|
+
else
|
93
|
+
ln = get_es_resource('/_cluster/nodes/_local')
|
94
|
+
stats = get_es_resource('/_cluster/nodes/_local/stats')
|
95
|
+
end
|
96
|
+
|
79
97
|
timestamp = Time.now.to_i
|
80
98
|
node = stats['nodes'].values.first
|
81
99
|
node['jvm']['mem']['heap_max_in_bytes'] = ln['nodes'].values.first['jvm']['mem']['heap_max_in_bytes']
|
@@ -74,7 +74,7 @@ module ElasticsearchQuery
|
|
74
74
|
'filtered' => {
|
75
75
|
'query' => {
|
76
76
|
'query_string' => {
|
77
|
-
'default_field' =>
|
77
|
+
'default_field' => config[:search_field],
|
78
78
|
'query' => config[:query]
|
79
79
|
}
|
80
80
|
},
|
@@ -97,6 +97,7 @@ module ElasticsearchQuery
|
|
97
97
|
def es_date_math_string
|
98
98
|
if config[:minutes_previous] == 0 && \
|
99
99
|
config[:hours_previous] == 0 && \
|
100
|
+
config[:days_previous] == 0 && \
|
100
101
|
config[:weeks_previous] == 0 && \
|
101
102
|
config[:months_previous] == 0
|
102
103
|
return nil
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu Plugins and contributors
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
|
31
31
|
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2015-
|
33
|
+
date: 2015-12-29 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rest-client
|
@@ -203,7 +203,7 @@ dependencies:
|
|
203
203
|
description: |-
|
204
204
|
This plugin provides native ElasticSearch instrumentation
|
205
205
|
for monitoring and metrics collection, including:
|
206
|
-
service health and metrics for cluster, node, and more
|
206
|
+
service health and metrics for cluster, node, and more.
|
207
207
|
email: "<sensu-users@googlegroups.com>"
|
208
208
|
executables:
|
209
209
|
- metrics-es-node.rb
|
metadata.gz.sig
CHANGED
Binary file
|