fluent-plugin-elasticsearch-stats 0.4.0 → 0.5.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4186ce2d0c16afc286ac07121d65e1169b184ea2b09fb35300dd30e360e936a
|
4
|
+
data.tar.gz: 07c3fd6f782a8c5a006bd9d901d6014a78b8df910954741c2ed6f350f7ed1fc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab34eabaf609eba4eacd8b148656968b5fc175e571b6a4531ba1b52e93a654219c5d292297c93893ce2315b410e155a15949dfbd1a6dfa98039c76b7a4caf816
|
7
|
+
data.tar.gz: 661eedf6ac5f362437ccdd447e43ca09a93d439811b1fc9998971e36463c688520f5d89dd35e150e0a2e9b0a9ca34810ebc70e37498144cd5d0d1cf400e71f5b
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent-plugin-elasticsearch-stats (0.
|
4
|
+
fluent-plugin-elasticsearch-stats (0.5.0)
|
5
5
|
faraday (~> 2.9)
|
6
|
+
faraday-retry (~> 2.2, >= 2.2.1)
|
6
7
|
fluentd (>= 0.14.10, < 2)
|
7
8
|
|
8
9
|
GEM
|
@@ -46,6 +47,8 @@ GEM
|
|
46
47
|
faraday-net_http (>= 2.0, < 3.2)
|
47
48
|
faraday-net_http (3.1.0)
|
48
49
|
net-http
|
50
|
+
faraday-retry (2.2.1)
|
51
|
+
faraday (~> 2.0)
|
49
52
|
fluentd (1.16.3)
|
50
53
|
bundler
|
51
54
|
cool.io (>= 1.4.5, < 2.0.0)
|
@@ -5,16 +5,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'fluent-plugin-elasticsearch-stats'
|
8
|
-
spec.version = '0.
|
8
|
+
spec.version = '0.5.0'
|
9
9
|
spec.authors = ['Thomas Tych']
|
10
10
|
spec.email = ['thomas.tych@gmail.com']
|
11
11
|
|
12
12
|
spec.summary = 'fluentd plugin to generate elasticsearch cluster stats events.'
|
13
|
-
spec.homepage =
|
13
|
+
spec.homepage = "https://gitlab.com/ttych/#{spec.name}"
|
14
14
|
spec.license = 'Apache-2.0'
|
15
15
|
|
16
16
|
spec.required_ruby_version = '>= 2.7.0'
|
17
17
|
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
19
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
20
|
+
spec.metadata['documentation_uri'] = "http://www.rubydoc.info/gems/#{spec.name}/#{spec.version}"
|
18
21
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
19
22
|
|
20
23
|
_, files = `git ls-files -z`.split("\x0").partition do |f|
|
@@ -36,5 +39,6 @@ Gem::Specification.new do |spec|
|
|
36
39
|
spec.add_development_dependency 'timecop', '~> 0.9.6'
|
37
40
|
|
38
41
|
spec.add_runtime_dependency 'faraday', '~> 2.9'
|
42
|
+
spec.add_runtime_dependency 'faraday-retry', '~> 2.2', '>= 2.2.1'
|
39
43
|
spec.add_runtime_dependency 'fluentd', ['>= 0.14.10', '< 2']
|
40
44
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'faraday'
|
4
|
+
require 'faraday/retry'
|
4
5
|
|
5
6
|
module Fluent
|
6
7
|
module Plugin
|
@@ -9,6 +10,9 @@ module Fluent
|
|
9
10
|
class Error < StandardError
|
10
11
|
end
|
11
12
|
|
13
|
+
RETRY_COUNT = 2
|
14
|
+
RETRY_DELAY = 5
|
15
|
+
|
12
16
|
TIMEOUT = 10
|
13
17
|
USER_AGENT = 'elasticsearch_stats'
|
14
18
|
|
@@ -16,7 +20,7 @@ module Fluent
|
|
16
20
|
CLUSTER_HEALTH_LEVEL = 'cluster'
|
17
21
|
NODES_STATS_LEVEL = 'cluster'
|
18
22
|
INDICES_STATS_LEVEL = 'indices'
|
19
|
-
INDICES = [:_all]
|
23
|
+
INDICES = [:_all].freeze
|
20
24
|
|
21
25
|
ALLOWED_CLUSTER_HEALTH_LEVELS = %i[cluster indices shards].freeze
|
22
26
|
ALLOWED_NODES_STATS_LEVELS = %i[nodes indices shards].freeze
|
@@ -71,6 +75,11 @@ module Fluent
|
|
71
75
|
@log = log
|
72
76
|
end
|
73
77
|
|
78
|
+
def cluster_info
|
79
|
+
endpoint = '/'
|
80
|
+
get(endpoint)
|
81
|
+
end
|
82
|
+
|
74
83
|
# https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html
|
75
84
|
def cluster_health(level: CLUSTER_HEALTH_LEVEL, local: LOCAL)
|
76
85
|
endpoint = '/_cluster/health'
|
@@ -96,7 +105,7 @@ module Fluent
|
|
96
105
|
# https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html
|
97
106
|
def indices_stats(indices: INDICES, level: INDICES_STATS_LEVEL, metrics: nil)
|
98
107
|
indices ||= INDICES
|
99
|
-
endpoint =
|
108
|
+
endpoint = '/_stats'
|
100
109
|
endpoint = "/#{indices.join(',')}#{endpoint}" if !indices.nil? && !indices.empty?
|
101
110
|
endpoint += "/#{metrics.join(',')}" if metrics&.any?
|
102
111
|
params = { level: level }
|
@@ -141,6 +150,8 @@ module Fluent
|
|
141
150
|
config.response :json
|
142
151
|
config.response :raise_error
|
143
152
|
config.response :logger, log, headers: false, bodies: false, log_level: :debug if log
|
153
|
+
|
154
|
+
config.request :retry, max: RETRY_COUNT, interval: RETRY_DELAY
|
144
155
|
config.adapter :net_http
|
145
156
|
end
|
146
157
|
end
|
@@ -4,6 +4,8 @@ module Fluent
|
|
4
4
|
module Plugin
|
5
5
|
module ElasticsearchStats
|
6
6
|
class Collector
|
7
|
+
CLUSTER_INFO_TTL = 12 * 3600
|
8
|
+
|
7
9
|
attr_reader :client, :stats_config, :log
|
8
10
|
|
9
11
|
def initialize(client:,
|
@@ -32,7 +34,7 @@ module Fluent
|
|
32
34
|
level: stats_config.cluster_health_level,
|
33
35
|
local: stats_config.cluster_health_local
|
34
36
|
)
|
35
|
-
ClusterHealthData.new(data).extract_metrics
|
37
|
+
ClusterHealthData.new(data, metadata: metadata).extract_metrics
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
@@ -41,7 +43,7 @@ module Fluent
|
|
41
43
|
|
42
44
|
without_error(rescue_return: []) do
|
43
45
|
data = client.cluster_stats
|
44
|
-
ClusterStatsData.new(data).extract_metrics
|
46
|
+
ClusterStatsData.new(data, metadata: metadata).extract_metrics
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
@@ -53,7 +55,7 @@ module Fluent
|
|
53
55
|
level: stats_config.nodes_stats_level,
|
54
56
|
metrics: stats_config.nodes_stats_metrics
|
55
57
|
)
|
56
|
-
NodesStatsData.new(data).extract_metrics
|
58
|
+
NodesStatsData.new(data, metadata: metadata).extract_metrics
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
@@ -66,7 +68,7 @@ module Fluent
|
|
66
68
|
level: stats_config.indices_stats_level,
|
67
69
|
metrics: stats_config.indices_stats_metrics
|
68
70
|
)
|
69
|
-
IndicesStatsData.new(data).extract_metrics
|
71
|
+
IndicesStatsData.new(data, metadata: metadata).extract_metrics
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
@@ -75,15 +77,28 @@ module Fluent
|
|
75
77
|
|
76
78
|
without_error(rescue_return: []) do
|
77
79
|
data = client.dangling
|
78
|
-
DanglingData.new(data).extract_metrics
|
80
|
+
DanglingData.new(data, metadata: metadata).extract_metrics
|
79
81
|
end
|
80
82
|
end
|
81
83
|
|
82
|
-
# FIXME: inject metadata !
|
83
|
-
# cluster metadata / info ?
|
84
84
|
def metadata
|
85
85
|
Metadata.new
|
86
|
-
.set(label: '
|
86
|
+
.set(label: 'cluster_name', value: cluster_info['cluster_name'])
|
87
|
+
# .set(label: 'cluster_url', value: client.url)
|
88
|
+
end
|
89
|
+
|
90
|
+
def cluster_info(ttl: CLUSTER_INFO_TTL)
|
91
|
+
cluster_info_prev = nil
|
92
|
+
if @cluster_info_timestamp && (Time.now - @cluster_info_timestamp > ttl)
|
93
|
+
cluster_info_prev = @cluster_info
|
94
|
+
@cluster_info = nil
|
95
|
+
end
|
96
|
+
|
97
|
+
without_error do
|
98
|
+
@cluster_info ||= client.cluster_info
|
99
|
+
@cluster_info_timestamp = Time.now
|
100
|
+
end
|
101
|
+
@cluster_info ||= cluster_info_prev
|
87
102
|
end
|
88
103
|
|
89
104
|
def without_error(error: StandardError, rescue_return: nil)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-elasticsearch-stats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Tych
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bump
|
@@ -176,6 +176,26 @@ dependencies:
|
|
176
176
|
- - "~>"
|
177
177
|
- !ruby/object:Gem::Version
|
178
178
|
version: '2.9'
|
179
|
+
- !ruby/object:Gem::Dependency
|
180
|
+
name: faraday-retry
|
181
|
+
requirement: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - "~>"
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: '2.2'
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: 2.2.1
|
189
|
+
type: :runtime
|
190
|
+
prerelease: false
|
191
|
+
version_requirements: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - "~>"
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '2.2'
|
196
|
+
- - ">="
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: 2.2.1
|
179
199
|
- !ruby/object:Gem::Dependency
|
180
200
|
name: fluentd
|
181
201
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,6 +250,9 @@ homepage: https://gitlab.com/ttych/fluent-plugin-elasticsearch-stats
|
|
230
250
|
licenses:
|
231
251
|
- Apache-2.0
|
232
252
|
metadata:
|
253
|
+
homepage_uri: https://gitlab.com/ttych/fluent-plugin-elasticsearch-stats
|
254
|
+
source_code_uri: https://gitlab.com/ttych/fluent-plugin-elasticsearch-stats
|
255
|
+
documentation_uri: http://www.rubydoc.info/gems/fluent-plugin-elasticsearch-stats/0.5.0
|
233
256
|
rubygems_mfa_required: 'true'
|
234
257
|
post_install_message:
|
235
258
|
rdoc_options: []
|