sensu-plugins-logstash 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/bin/metrics-logstash-node.rb +145 -0
- data/lib/sensu-plugins-logstash/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a2d687c679ae0fe582beb5778e4db2f4e12bf62
|
4
|
+
data.tar.gz: 272f841956109a14fd161b0023836422eb10f78a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d238bf0b47db82d88f16b00b0c158f317b8f6e232e11226989f0ffedc83a1122d334e33a59bfb141b26c807b22aa12f146a12641b71a90f64d1a767b3cb5b782
|
7
|
+
data.tar.gz: a5cfddbd9c76a97c2d10aefcb8692534ae42df199fab04e0e6b9d7e1d6bb5148186fe108c1499ac90b9b68e765d5b1480940925cec0d865ad0d9213b10034da8
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
|
+
|
8
|
+
## [1.1.0] - 2017-07-27
|
9
|
+
## Added
|
10
|
+
- test with ruby 2.4 as sensu now ships with it. (@majormoses)
|
11
|
+
- metrics-logstash-node.rb: new check to collect metrics via the logstash api (@runningman84)
|
12
|
+
|
7
13
|
## [1.0.0] - 2017-05-29
|
8
14
|
### Added
|
9
15
|
- testing on ruby 2.3
|
@@ -40,7 +46,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
40
46
|
### Added
|
41
47
|
- initial release
|
42
48
|
|
43
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-logstash/compare/1.
|
49
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-logstash/compare/1.1.0...HEAD
|
50
|
+
[1.1.0]: https://github.com/sensu-plugins/sensu-plugins-logstash/compare/1.0.0...1.1.0
|
44
51
|
[1.0.0]: https://github.com/sensu-plugins/sensu-plugins-logstash/compare/0.1.1...1.0.0
|
45
52
|
[0.1.1]: https://github.com/sensu-plugins/sensu-plugins-logstash/compare/0.1.0...0.1.1
|
46
53
|
[0.1.0]: https://github.com/sensu-plugins/sensu-plugins-logstash/compare/0.0.4...0.1.0
|
@@ -0,0 +1,145 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# logstash-node-metrics
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin uses the Logstash API to collect metrics, producing a JSON
|
7
|
+
# document which is outputted to STDOUT. An exit status of 0 indicates
|
8
|
+
# the plugin has successfully collected and produced.
|
9
|
+
#
|
10
|
+
# OUTPUT:
|
11
|
+
# metric data
|
12
|
+
#
|
13
|
+
# PLATFORMS:
|
14
|
+
# Linux
|
15
|
+
#
|
16
|
+
# DEPENDENCIES:
|
17
|
+
# gem: sensu-plugin
|
18
|
+
# gem: rest-client
|
19
|
+
#
|
20
|
+
# USAGE:
|
21
|
+
# #YELLOW
|
22
|
+
#
|
23
|
+
# NOTES:
|
24
|
+
#
|
25
|
+
# LICENSE:
|
26
|
+
# Copyright 2011 Sonian, Inc <chefs@sonian.net>
|
27
|
+
# Copyright 2016 Philipp Hellmich <phil@hellmi.de>
|
28
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
29
|
+
# for details.
|
30
|
+
#
|
31
|
+
|
32
|
+
require 'sensu-plugin/metric/cli'
|
33
|
+
require 'rest-client'
|
34
|
+
require 'json'
|
35
|
+
require 'base64'
|
36
|
+
|
37
|
+
#
|
38
|
+
# ES Node Metrics
|
39
|
+
#
|
40
|
+
class ESMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
41
|
+
option :scheme,
|
42
|
+
description: 'Metric naming scheme, text to prepend to queue_name.metric',
|
43
|
+
short: '-s SCHEME',
|
44
|
+
long: '--scheme SCHEME',
|
45
|
+
default: "#{Socket.gethostname}.logstash"
|
46
|
+
|
47
|
+
option :host,
|
48
|
+
description: 'Elasticsearch server host.',
|
49
|
+
short: '-h HOST',
|
50
|
+
long: '--host HOST',
|
51
|
+
default: 'localhost'
|
52
|
+
|
53
|
+
option :port,
|
54
|
+
description: 'Elasticsearch port',
|
55
|
+
short: '-p PORT',
|
56
|
+
long: '--port PORT',
|
57
|
+
proc: proc(&:to_i),
|
58
|
+
default: 9600
|
59
|
+
|
60
|
+
option :user,
|
61
|
+
description: 'Elasticsearch User',
|
62
|
+
short: '-u USER',
|
63
|
+
long: '--user USER'
|
64
|
+
|
65
|
+
option :password,
|
66
|
+
description: 'Elasticsearch Password',
|
67
|
+
short: '-P PASS',
|
68
|
+
long: '--password PASS'
|
69
|
+
|
70
|
+
option :https,
|
71
|
+
description: 'Enables HTTPS',
|
72
|
+
short: '-e',
|
73
|
+
long: '--https'
|
74
|
+
|
75
|
+
def get_es_resource(resource)
|
76
|
+
headers = {}
|
77
|
+
if config[:user] && config[:password]
|
78
|
+
auth = 'Basic ' + Base64.encode64("#{config[:user]}:#{config[:password]}").chomp
|
79
|
+
headers = { 'Authorization' => auth }
|
80
|
+
end
|
81
|
+
|
82
|
+
protocol = if config[:https]
|
83
|
+
'https'
|
84
|
+
else
|
85
|
+
'http'
|
86
|
+
end
|
87
|
+
|
88
|
+
r = RestClient::Resource.new("#{protocol}://#{config[:host]}:#{config[:port]}#{resource}", timeout: config[:timeout], headers: headers)
|
89
|
+
JSON.parse(r.get)
|
90
|
+
rescue Errno::ECONNREFUSED
|
91
|
+
warning 'Connection refused'
|
92
|
+
rescue RestClient::RequestTimeout
|
93
|
+
warning 'Connection timed out'
|
94
|
+
end
|
95
|
+
|
96
|
+
def run # rubocop:disable Metrics/AbcSize
|
97
|
+
stats = get_es_resource('/_node/stats')
|
98
|
+
|
99
|
+
timestamp = Time.now.to_i
|
100
|
+
node = stats
|
101
|
+
|
102
|
+
metrics = {}
|
103
|
+
metrics['jvm.threads.count'] = node['jvm']['threads']['count']
|
104
|
+
metrics['jvm.mem.heap_used_in_bytes'] = node['jvm']['mem']['heap_used_in_bytes']
|
105
|
+
metrics['jvm.mem.heap_used_percent'] = node['jvm']['mem']['heap_used_percent']
|
106
|
+
metrics['jvm.mem.non_heap_used_in_bytes'] = node['jvm']['mem']['non_heap_used_in_bytes']
|
107
|
+
metrics['jvm.gc.collectors.old.collection_time_in_millis'] = node['jvm']['gc']['collectors']['old']['collection_time_in_millis']
|
108
|
+
metrics['jvm.gc.collectors.young.collection_time_in_millis'] = node['jvm']['gc']['collectors']['young']['collection_time_in_millis']
|
109
|
+
metrics['jvm.gc.collectors.old.collection_count'] = node['jvm']['gc']['collectors']['old']['collection_count']
|
110
|
+
metrics['jvm.gc.collectors.young.collection_count'] = node['jvm']['gc']['collectors']['young']['collection_count']
|
111
|
+
|
112
|
+
metrics['process.open_file_descriptors'] = node['process']['open_file_descriptors']
|
113
|
+
metrics['process.peak_open_file_descriptors'] = node['process']['peak_open_file_descriptors']
|
114
|
+
metrics['process.max_file_descriptors'] = node['process']['max_file_descriptors']
|
115
|
+
|
116
|
+
node['pipeline']['events'].each do |key, value|
|
117
|
+
metrics["pipeline.events.#{key}"] = value
|
118
|
+
end
|
119
|
+
|
120
|
+
node['pipeline']['plugins']['inputs'].each do |item|
|
121
|
+
item['events'] = {} unless item.key?('events')
|
122
|
+
metrics["pipeline.plugins.inputs.#{item['id']}.events.in"] = item['events']['in'].to_i || 0
|
123
|
+
metrics["pipeline.plugins.inputs.#{item['id']}.events.out"] = item['events']['out'].to_i || 0
|
124
|
+
end
|
125
|
+
|
126
|
+
node['pipeline']['plugins']['filters'].each do |item|
|
127
|
+
item['events'] = {} unless item.key?('events')
|
128
|
+
metrics["pipeline.plugins.filters.#{item['id']}.events.in"] = item['events']['in'].to_i || 0
|
129
|
+
metrics["pipeline.plugins.filters.#{item['id']}.events.out"] = item['events']['out'].to_i || 0
|
130
|
+
metrics["pipeline.plugins.filters.#{item['id']}.events.duration_in_millis"] = item['events']['duration_in_millis'].to_i || 0
|
131
|
+
metrics["pipeline.plugins.filters.#{item['id']}.matches"] = item['matches'].to_i if item.key?('matches')
|
132
|
+
end
|
133
|
+
|
134
|
+
node['pipeline']['plugins']['outputs'].each do |item|
|
135
|
+
item['events'] = {} unless item.key?('events')
|
136
|
+
metrics["pipeline.plugins.outputs.#{item['id']}.events.in"] = item['events']['in'].to_i || 0
|
137
|
+
metrics["pipeline.plugins.outputs.#{item['id']}.events.out"] = item['events']['out'].to_i || 0
|
138
|
+
end
|
139
|
+
|
140
|
+
metrics.each do |k, v|
|
141
|
+
output([config[:scheme], k].join('.'), v, timestamp)
|
142
|
+
end
|
143
|
+
ok
|
144
|
+
end
|
145
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-logstash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -185,6 +185,7 @@ description: |-
|
|
185
185
|
email: "<sensu-users@googlegroups.com>"
|
186
186
|
executables:
|
187
187
|
- handler-logstash.rb
|
188
|
+
- metrics-logstash-node.rb
|
188
189
|
extensions: []
|
189
190
|
extra_rdoc_files: []
|
190
191
|
files:
|
@@ -192,6 +193,7 @@ files:
|
|
192
193
|
- LICENSE
|
193
194
|
- README.md
|
194
195
|
- bin/handler-logstash.rb
|
196
|
+
- bin/metrics-logstash-node.rb
|
195
197
|
- lib/sensu-plugins-logstash.rb
|
196
198
|
- lib/sensu-plugins-logstash/version.rb
|
197
199
|
homepage: https://github.com/sensu-plugins/sensu-plugins-logstash
|