fluent-plugin-calyptia-monitoring 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fc0b5aeb01b9d8633b36bf2f3b9f58edbcb9ef013714e3e835521701351a4d4
4
- data.tar.gz: db62765482fe0dd3cc2a3ceba7267f40a9da21bb4b52f99d230ccda39c52d27f
3
+ metadata.gz: c8a47c5ddcd660a66dcec0b732510d97f65d5df3c732faf3f6575828948076de
4
+ data.tar.gz: d4796efe64fe5cc8bdd6c531a3f3b27de8c759e3fed3fadb5d7e79e5345f76fd
5
5
  SHA512:
6
- metadata.gz: 9d56cd4f622355e6b7f3939044e33290fdfd1dc017fe77988296af190f1ba89020d0be45e123a782083e7bc7d617125ef92c2042e2d4777f7ef57736da0f75de
7
- data.tar.gz: 36c91c64f0e13a06d9c2dd57c265989c6bf132dd7c9a57d388b22c6ba9d324af361253272763d761c6b21a99b8355f199ddd22b03539e6abd697488994c99767
6
+ metadata.gz: 3af292be5c20644444af230895df1b6a1f918513d899736e2f8d97cedec6b9d2335f25469e557cb7b8a14d78b6cdabe5bf3e59e2c5863e19f131a066876bce57
7
+ data.tar.gz: fbc3e6d065c9fe6ed75cfe31e58f81367d7b1fdc02c5c93d0e5148fe789ccab2cfdcf4cae42948a309a5cf6ea206c4b129da157ca489540884bcf623ca98a125
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "fluent-plugin-calyptia-monitoring"
6
- spec.version = "0.1.1"
6
+ spec.version = "0.1.2"
7
7
  spec.authors = ["Hiroshi Hatake"]
8
8
  spec.email = ["hatake@calyptia.com"]
9
9
 
@@ -0,0 +1,68 @@
1
+ #
2
+ # fluent-plugin-calyptia-monitoring
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ require 'fluent/plugin/in_monitor_agent'
17
+
18
+ module Fluent::Plugin
19
+ class CalyptiaMonitoringInTailInput < MonitorAgentInput
20
+ CALYPTIA_PLUGIN_METRIC_INFO = {
21
+ 'files_opened_total' => ->(){
22
+ throw(:skip) unless instance_variable_defined?(:@metrics) && !@metrics.nil? && !@metrics.opened.get.nil?
23
+ @metrics.opened.cmetrics.to_msgpack
24
+ },
25
+ 'files_closed_total' => ->(){
26
+ throw(:skip) unless instance_variable_defined?(:@metrics) && !@metrics.nil? && !@metrics.closed.get.nil?
27
+ @metrics.closed.cmetrics.to_msgpack
28
+ },
29
+ 'files_rotated_total' => ->(){
30
+ throw(:skip) unless instance_variable_defined?(:@metrics) && !@metrics.nil? && !@metrics.rotated.get.nil?
31
+ @metrics.rotated.cmetrics.to_msgpack
32
+ },
33
+ }
34
+
35
+ def plugins_info_all(opts={})
36
+ agent_info = all_plugins.select {|pe|
37
+ pe.config['@type'] == "tail".freeze rescue nil
38
+ }
39
+
40
+ agent_info.map do |pe|
41
+ get_monitor_info(pe, opts)
42
+ end
43
+ end
44
+
45
+ def get_monitor_info(pe, opts = {})
46
+ obj = {}
47
+
48
+ obj['metrics'] = get_plugin_metric(pe)
49
+
50
+ obj
51
+ end
52
+
53
+ def get_plugin_metric(pe)
54
+ metrics = {}
55
+ CALYPTIA_PLUGIN_METRIC_INFO.each_pair { |key, code|
56
+ begin
57
+ v = pe.instance_exec(&code)
58
+ unless v.nil?
59
+ metrics[key] = v
60
+ end
61
+ rescue
62
+ end
63
+ }
64
+
65
+ metrics
66
+ end
67
+ end
68
+ end
@@ -22,6 +22,7 @@ require "fluent/plugin/input"
22
22
  require "serverengine"
23
23
  require_relative "calyptia_monitoring_ext"
24
24
  require_relative "calyptia_monitoring_buffer_ext"
25
+ require_relative "calyptia_monitoring_in_tail"
25
26
  require_relative "calyptia_monitoring_calyptia_api_requester"
26
27
 
27
28
  module Fluent
@@ -135,6 +136,7 @@ module Fluent
135
136
  raise Fluent::ConfigError, "cmetrics plugin should be used to collect metrics on Calyptia Cloud" unless enabled_cmetrics
136
137
  @monitor_agent = Fluent::Plugin::CalyptiaMonitoringExtInput.new
137
138
  @monitor_agent_buffer = Fluent::Plugin::CalyptiaMonitoringBufferExtInput.new
139
+ @monitor_agent_in_tail = Fluent::Plugin::CalyptiaMonitoringInTailInput.new
138
140
  @api_requester = Fluent::Plugin::CalyptiaAPI::Requester.new(@cloud_monitoring.endpoint,
139
141
  @cloud_monitoring.api_key,
140
142
  log,
@@ -272,6 +274,12 @@ module Fluent
272
274
  buffer += v
273
275
  end
274
276
  }
277
+ @monitor_agent_in_tail.plugins_info_all(opts).each {|record|
278
+ metrics = record["metrics"]
279
+ metrics.each_pair do |k, v|
280
+ buffer += v
281
+ end
282
+ }
275
283
  if buffer.empty?
276
284
  log.debug "No initialized metrics is found. Trying to send cmetrics on the next tick."
277
285
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-calyptia-monitoring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Hatake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-30 00:00:00.000000000 Z
11
+ date: 2021-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,6 +106,7 @@ files:
106
106
  - lib/fluent/plugin/calyptia_monitoring_buffer_ext.rb
107
107
  - lib/fluent/plugin/calyptia_monitoring_calyptia_api_requester.rb
108
108
  - lib/fluent/plugin/calyptia_monitoring_ext.rb
109
+ - lib/fluent/plugin/calyptia_monitoring_in_tail.rb
109
110
  - lib/fluent/plugin/calyptia_monitoring_machine_id.rb
110
111
  - lib/fluent/plugin/in_calyptia_monitoring.rb
111
112
  - templates/calyptia-conf.erb