fluent-plugin-jfrog-metrics 0.2.4 → 0.2.6

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: c00c423ab9491557efdbe34b16c0ce13efa20a311e8f91fe9d89a6385e95d9db
4
- data.tar.gz: b2bb9ea1003ce8b06bef69fbd6a8d28605e928e7842b2a85cbe6a490c10854d7
3
+ metadata.gz: b93ecb5ecea1f1ab7144d5f1032951346c68427c6f2797a9c1799562ab609835
4
+ data.tar.gz: baa93977ee4ee4015fa1779a3d2c7ae4dc442e1084b730d944e5820664a1ff40
5
5
  SHA512:
6
- metadata.gz: 860cdc25af5d5922732a15a82ec3fa597e66e6acf51f90a827397e10469b0dfe45b2b4d83b58c4f24635743b1e612b41c45ab779f64f2f7d34565d3257faefba
7
- data.tar.gz: 664974e6bdcd74531c020381b015ff5783080124bf3d16eec9ef72b6861819b9fa1a5c1759a4616aa99640bbee231c5b044797836a705e56e5ba539c52c48b4c
6
+ metadata.gz: e6fc16c13405a355a325f4bd91e0be810e7b84325fdacb638ffa5403c3a6e1fff3d4914231916378d484725f439903ea0e720f5b62c9d6e1270d5f9c867dd871
7
+ data.tar.gz: d50066d93ceec87c01396a5730531d6bc0018fe50c6ba3f63c62832db5db38009c22b0d1d0a8773c959625b0aa46885ab26e21601d3ac0036079c230993b32cf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-jfrog-metrics (0.2.4)
4
+ fluent-plugin-jfrog-metrics (0.2.6)
5
5
  fluentd (>= 0.14.10, < 2)
6
6
  rest-client (~> 2.0)
7
7
 
@@ -14,17 +14,17 @@ GEM
14
14
  cool.io (1.7.1)
15
15
  domain_name (0.5.20190701)
16
16
  unf (>= 0.0.5, < 1.0.0)
17
- fluentd (1.14.5)
17
+ fluentd (1.16.1)
18
18
  bundler
19
19
  cool.io (>= 1.4.5, < 2.0.0)
20
20
  http_parser.rb (>= 0.5.1, < 0.9.0)
21
21
  msgpack (>= 1.3.1, < 2.0.0)
22
- serverengine (>= 2.2.5, < 3.0.0)
22
+ serverengine (>= 2.3.2, < 3.0.0)
23
23
  sigdump (~> 0.2.2)
24
24
  strptime (>= 0.2.4, < 1.0.0)
25
25
  tzinfo (>= 1.0, < 3.0)
26
26
  tzinfo-data (~> 1.0)
27
- webrick (>= 1.4.2, < 1.8.0)
27
+ webrick (~> 1.4)
28
28
  yajl-ruby (~> 1.0)
29
29
  http-accept (1.7.0)
30
30
  http-cookie (1.0.4)
@@ -39,7 +39,7 @@ GEM
39
39
  builder
40
40
  minitest (>= 5.0)
41
41
  ruby-progressbar
42
- msgpack (1.4.5)
42
+ msgpack (1.7.1)
43
43
  netrc (0.11.0)
44
44
  power_assert (2.0.1)
45
45
  rake (12.3.3)
@@ -49,21 +49,21 @@ GEM
49
49
  mime-types (>= 1.16, < 4.0)
50
50
  netrc (~> 0.8)
51
51
  ruby-progressbar (1.11.0)
52
- serverengine (2.2.5)
52
+ serverengine (2.3.2)
53
53
  sigdump (~> 0.2.2)
54
54
  sigdump (0.2.4)
55
55
  strptime (0.2.5)
56
56
  test-unit (3.5.0)
57
57
  power_assert
58
- tzinfo (2.0.4)
58
+ tzinfo (2.0.6)
59
59
  concurrent-ruby (~> 1.0)
60
- tzinfo-data (1.2021.5)
60
+ tzinfo-data (1.2023.3)
61
61
  tzinfo (>= 1.0.0)
62
62
  unf (0.1.4)
63
63
  unf_ext
64
64
  unf_ext (0.0.8)
65
- webrick (1.7.0)
66
- yajl-ruby (1.4.1)
65
+ webrick (1.8.1)
66
+ yajl-ruby (1.4.3)
67
67
 
68
68
  PLATFORMS
69
69
  ruby
@@ -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-jfrog-metrics'
6
- spec.version = '0.2.4'
6
+ spec.version = '0.2.6'
7
7
  spec.authors = ['MahithaB, VasukiN, giri-vsr']
8
8
  spec.email = ['cpe-support@jfrog.com']
9
9
 
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+ require 'json'
3
+ require_relative 'base_metrics_parser'
4
+
5
+ class DatadogMetricsParser < BaseMetricsParser
6
+ def initialize(metric_prefix, router, tag)
7
+ @metric_prefix = metric_prefix
8
+ @router = router
9
+ @tag = tag
10
+ end
11
+
12
+ def format_data(cleaned_data = [], prefix = '', separator = '')
13
+ hash_data_array = []
14
+ data_hash = {}
15
+ data_array = []
16
+ cleaned_data.each do |interim_data|
17
+ metrics_hash = {}
18
+ tags = []
19
+ point = {}
20
+ points = []
21
+ if interim_data =~ /{/ && interim_data =~ /}/
22
+ metric_name, additional_dims, metric_val_and_time = interim_data.match(/(.*){(.*)}(.*)/i).captures
23
+ if additional_dims =~ /,/
24
+ additional_dims.split(/,/).map do |interim_data|
25
+ interim_data_value = interim_data.split(/=/)[1].gsub(/"/, '') if interim_data =~ /=/
26
+ interim_data_key = interim_data.split(/=/)[0]
27
+ interim_data_tag = interim_data_key + ':' + interim_data_value
28
+ tags << interim_data_tag
29
+ end
30
+ else
31
+ attribute_name, attribute_value = additional_dims.split('=')
32
+ attribute_value = attribute_value.delete_prefix('"').delete_suffix('"')
33
+ attribute_tag = attribute_name + ':' + attribute_value
34
+ tags << attribute_tag
35
+ end
36
+ if metric_val_and_time =~ / /
37
+ metrics_hash['metric'] = prefix + separator + metric_name
38
+ metric_timestamp = metric_val_and_time.strip.split[1]
39
+ point['timestamp'] = metric_timestamp[0,10].to_i if metric_timestamp != nil
40
+ point['value'] = metric_val_and_time.strip.split[0] =~ /^\S*\.\S*$/ ? metric_val_and_time.strip.split[0].to_f : metric_val_and_time.strip.split[0].to_i
41
+ points << point
42
+ metrics_hash['points'] = points
43
+ metrics_hash['tags'] = tags
44
+ end
45
+ else
46
+ metrics_hash['metric'], metric_value, metric_timestamp = interim_data.split
47
+ metrics_hash['metric'] = prefix + separator + metrics_hash['metric']
48
+ point['value'] = metric_value =~ /^\S*\.\S*$/ ? metric_value.to_f : metric_value.to_i
49
+ point['timestamp'] = metric_timestamp[0,10].to_i
50
+ points << point
51
+ metrics_hash['points'] = points
52
+ end
53
+ metrics_hash['type'] = 3
54
+ data_array << metrics_hash
55
+ end
56
+ data_hash["series"] = data_array
57
+ hash_data_array.push(data_hash)
58
+ hash_data_array
59
+ end
60
+
61
+ end
@@ -22,6 +22,7 @@ require_relative 'metrics_helper'
22
22
  require_relative 'newrelic_metrics_parser'
23
23
  require_relative 'splunk_metrics_parser'
24
24
  require_relative 'elastic_metrics_parser'
25
+ require_relative 'datadog_metrics_parser'
25
26
 
26
27
  module Fluent
27
28
  module Plugin
@@ -36,7 +37,8 @@ module Fluent
36
37
  config_param :username, :string, default: ''
37
38
  config_param :apikey, :string, default: '', :secret => true
38
39
  config_param :token, :string, default: '', :secret => true
39
- config_param :interval, :time, default: 10
40
+ config_param :execution_interval, :time, default: 10
41
+ config_param :timeout_interval, :time, default: 30
40
42
  config_param :metric_prefix, :string, default: ''
41
43
  config_param :target_platform, :string, default: 'SPLUNK'
42
44
  config_param :common_jpd, :bool, default: false
@@ -54,8 +56,6 @@ module Fluent
54
56
 
55
57
  raise Fluent::ConfigError, 'Must define the apikey or token for authentication.' if @token == '' && @apikey == ''
56
58
 
57
- raise Fluent::ConfigError, 'Must define the interval to use for gathering the metrics.' if @interval == ''
58
-
59
59
  raise Fluent::ConfigError, 'Must define the metric_prefix to use for getting the metrics.' if @metric_prefix == ''
60
60
 
61
61
  raise Fluent::ConfigError, 'Must define the vendor to use for getting the metrics.' if @target_platform == ''
@@ -76,17 +76,19 @@ module Fluent
76
76
 
77
77
  def run
78
78
  puts('Preparing metrics collection, creating timer task')
79
- timer_task = Concurrent::TimerTask.new(execution_interval: @interval, timeout_interval: 30, run_now: true) do
79
+ timer_task = Concurrent::TimerTask.new(execution_interval: @execution_interval, timeout_interval: @timeout_interval, run_now: true) do
80
80
  puts('Timer task execution')
81
81
  do_execute
82
82
  end
83
83
  timer_task.execute
84
+ sleep 100
84
85
  end
85
86
 
86
87
  def do_execute
87
88
  puts('Executing metrics collection')
88
89
  metrics_helper = MetricsHelper.new(@metric_prefix, @jpd_url, @username, @apikey, @token, @common_jpd)
89
90
  platform_metrics = metrics_helper.get_metrics
91
+
90
92
  additional_metrics = metrics_helper.get_additional_metrics
91
93
  if !additional_metrics.nil? && additional_metrics != ''
92
94
  platform_metrics += additional_metrics.to_s
@@ -97,6 +99,8 @@ module Fluent
97
99
  parser = ElasticMetricsParser.new(@metric_prefix, router, @tag)
98
100
  elsif @target_platform == 'NEWRELIC'
99
101
  parser = NewRelicMetricsParser.new(@metric_prefix, router, @tag)
102
+ elsif @target_platform == 'DATADOG'
103
+ parser = DatadogMetricsParser.new(@metric_prefix, router, @tag)
100
104
  else
101
105
  raise 'Parser Type is not valid.Should be SPLUNK or ELASTIC or NEWRELIC'
102
106
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-jfrog-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - MahithaB, VasukiN, giri-vsr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-23 00:00:00.000000000 Z
11
+ date: 2024-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -118,6 +118,7 @@ files:
118
118
  - Rakefile
119
119
  - fluent-plugin-jfrog-metrics.gemspec
120
120
  - lib/fluent/plugin/base_metrics_parser.rb
121
+ - lib/fluent/plugin/datadog_metrics_parser.rb
121
122
  - lib/fluent/plugin/elastic_metrics_parser.rb
122
123
  - lib/fluent/plugin/in_jfrog_metrics.rb
123
124
  - lib/fluent/plugin/metrics_helper.rb