fluent-plugin-jfrog-metrics 0.2.6 → 0.2.8
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/Gemfile.lock +3 -3
- data/README.md +4 -2
- data/fluent-plugin-jfrog-metrics.gemspec +4 -4
- data/lib/fluent/plugin/datadog_metrics_parser.rb +6 -12
- data/lib/fluent/plugin/in_jfrog_metrics.rb +5 -5
- data/lib/fluent/plugin/metrics_helper.rb +20 -16
- data/lib/fluent/plugin/newrelic_metrics_parser.rb +7 -7
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be1f993ce6a17cbbd55addf9bd1c2c987861373b86d0c9e5bf57fba2391b89c6
|
4
|
+
data.tar.gz: 42caf47f85ef0005eae2b35b35c6c4f7cf9c0cb39bd8f8b361cdf282f8e5ea2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 459aa4c98d67051b19e5c3947277ade652eaaea9fb868bd41ac9ba1d0126bc15247d9b1f4076c21abe526ae74e9e0f68d565578916077ffcf3385717354f7b64
|
7
|
+
data.tar.gz: 41008a0e14481e8b1b0a9881ada4559cc4d2edbc13d5af4d43d294b26ebebab58710cd0dfcda55815541b77a129cc68f5fc3b668abcb460a0b8069d0465f5091
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent-plugin-jfrog-metrics (0.2.
|
4
|
+
fluent-plugin-jfrog-metrics (0.2.8)
|
5
5
|
fluentd (>= 0.14.10, < 2)
|
6
|
-
rest-client (~> 2.0)
|
6
|
+
rest-client (~> 2.1.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
11
|
ansi (1.5.0)
|
12
12
|
builder (3.2.4)
|
13
|
-
concurrent-ruby (1.
|
13
|
+
concurrent-ruby (1.2.2)
|
14
14
|
cool.io (1.7.1)
|
15
15
|
domain_name (0.5.20190701)
|
16
16
|
unf (>= 0.0.5, < 1.0.0)
|
data/README.md
CHANGED
@@ -93,12 +93,14 @@ Integration is done by setting up Xray. Obtain JPD url and access token for API.
|
|
93
93
|
- Default value: false
|
94
94
|
- **target_platform** (string) (optional): Output format of target platform allowed values SPLUNK and ELASTIC
|
95
95
|
- Default value: `SPLUNK`
|
96
|
+
- **verify_ssl** (true / false) (optional): This flag should be set as false in order to bypass client's ssl certificate verification. When false, sets ssl_opts['verify_ssl'] to OpenSSL::SSL::VERIFY_NONE. Otherwise, sets ssl_opts['verify_ssl'] to OpenSSL::SSL::VERIFY_PEER
|
97
|
+
- Default value: true
|
96
98
|
|
97
99
|
Note:
|
98
100
|
|
99
101
|
- For Artifactory v7.4 and below only API Key must be used,
|
100
|
-
- For Artifactory v7.4 to 7.
|
101
|
-
- For Artifactory v7.
|
102
|
+
- For Artifactory v7.4 to 7.46 either Token or API Key can be used,
|
103
|
+
- For Artifactory v7.47 and above token only must be used.
|
102
104
|
|
103
105
|
## Copyright
|
104
106
|
|
@@ -3,8 +3,8 @@ $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.
|
7
|
-
spec.authors = ['MahithaB,
|
6
|
+
spec.version = '0.2.8'
|
7
|
+
spec.authors = ['MahithaB, BenHarosh']
|
8
8
|
spec.email = ['cpe-support@jfrog.com']
|
9
9
|
|
10
10
|
spec.summary = %q{Fluentd Plugin for converting JFrog Artifactory, Xray generated metrics (Prometheus Exposition Format) to target observability platform format (Splunk HEC, New Relic, Elastic)}
|
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.14'
|
25
25
|
spec.add_development_dependency 'rake', '~> 12.0'
|
26
26
|
spec.add_development_dependency 'test-unit', '~> 3.0'
|
27
|
-
spec.add_development_dependency "rest-client", "~> 2.0"
|
27
|
+
spec.add_development_dependency "rest-client", "~> 2.1.0"
|
28
28
|
spec.add_runtime_dependency 'fluentd', ['>= 0.14.10', '< 2']
|
29
|
-
spec.add_runtime_dependency "rest-client", "~> 2.0"
|
29
|
+
spec.add_runtime_dependency "rest-client", "~> 2.1.0"
|
30
30
|
end
|
@@ -20,18 +20,12 @@ class DatadogMetricsParser < BaseMetricsParser
|
|
20
20
|
points = []
|
21
21
|
if interim_data =~ /{/ && interim_data =~ /}/
|
22
22
|
metric_name, additional_dims, metric_val_and_time = interim_data.match(/(.*){(.*)}(.*)/i).captures
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
23
|
+
additional_dims.split("\",").each do |interim_data|
|
24
|
+
pair_data = interim_data.gsub("\"", "").gsub("{", "").gsub("}", "")
|
25
|
+
interim_data_value = pair_data.split("=", 2)[1]
|
26
|
+
interim_data_key = pair_data.split("=", 2)[0]
|
27
|
+
interim_data_tag = interim_data_key + ':' + interim_data_value
|
28
|
+
tags << interim_data_tag
|
35
29
|
end
|
36
30
|
if metric_val_and_time =~ / /
|
37
31
|
metrics_hash['metric'] = prefix + separator + metric_name
|
@@ -42,6 +42,7 @@ module Fluent
|
|
42
42
|
config_param :metric_prefix, :string, default: ''
|
43
43
|
config_param :target_platform, :string, default: 'SPLUNK'
|
44
44
|
config_param :common_jpd, :bool, default: false
|
45
|
+
config_param :verify_ssl, :bool, default: true
|
45
46
|
|
46
47
|
# `configure` is called before `start`.
|
47
48
|
# 'conf' is a `Hash` that includes the configuration parameters.
|
@@ -85,8 +86,8 @@ module Fluent
|
|
85
86
|
end
|
86
87
|
|
87
88
|
def do_execute
|
88
|
-
puts('
|
89
|
-
metrics_helper = MetricsHelper.new(@metric_prefix, @jpd_url, @username, @apikey, @token, @common_jpd)
|
89
|
+
puts('Metrics collection started')
|
90
|
+
metrics_helper = MetricsHelper.new(@metric_prefix, @jpd_url, @username, @apikey, @token, @common_jpd, @verify_ssl)
|
90
91
|
platform_metrics = metrics_helper.get_metrics
|
91
92
|
|
92
93
|
additional_metrics = metrics_helper.get_additional_metrics
|
@@ -95,16 +96,15 @@ module Fluent
|
|
95
96
|
end
|
96
97
|
if @target_platform == 'SPLUNK'
|
97
98
|
parser = SplunkMetricsParser.new(@metric_prefix, router, @tag)
|
98
|
-
elsif @target_platform == 'ELASTIC'
|
99
|
-
parser = ElasticMetricsParser.new(@metric_prefix, router, @tag)
|
100
99
|
elsif @target_platform == 'NEWRELIC'
|
101
100
|
parser = NewRelicMetricsParser.new(@metric_prefix, router, @tag)
|
102
101
|
elsif @target_platform == 'DATADOG'
|
103
102
|
parser = DatadogMetricsParser.new(@metric_prefix, router, @tag)
|
104
103
|
else
|
105
|
-
raise 'Parser Type is not valid.Should be SPLUNK or
|
104
|
+
raise 'Parser Type is not valid.Should be SPLUNK or NEWRELIC or DATADOG'
|
106
105
|
end
|
107
106
|
parser.emit_parsed_metrics(platform_metrics)
|
107
|
+
puts('Metrics collection finished')
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
@@ -5,13 +5,14 @@ require 'rest-client'
|
|
5
5
|
class MetricsHelper
|
6
6
|
@@obs_endpoint_exists = false
|
7
7
|
|
8
|
-
def initialize(metric_prefix, jpd_url, username, apikey, token, common_jpd)
|
8
|
+
def initialize(metric_prefix, jpd_url, username, apikey, token, common_jpd, verify_ssl)
|
9
9
|
@metric_prefix = metric_prefix
|
10
10
|
@jpd_url = jpd_url
|
11
11
|
@username = username
|
12
12
|
@apikey = apikey
|
13
13
|
@token = token
|
14
14
|
@common_jpd = common_jpd
|
15
|
+
@verify_ssl = verify_ssl
|
15
16
|
end
|
16
17
|
|
17
18
|
def get_metrics
|
@@ -24,60 +25,63 @@ class MetricsHelper
|
|
24
25
|
else
|
25
26
|
"#{@jpd_url}/artifactory/api/v1/metrics"
|
26
27
|
end
|
28
|
+
|
29
|
+
puts "Executing #{@metric_prefix} metrics collection from: #{url}"
|
27
30
|
if !@token.nil? && @token != ''
|
28
|
-
execute_rest_call(url, @username, nil, @token,
|
31
|
+
execute_rest_call(url, @username, nil, @token, true, @verify_ssl)
|
29
32
|
elsif !@apikey.nil? && @apikey != ''
|
30
|
-
execute_rest_call(url, @username, @apikey, nil, false,
|
33
|
+
execute_rest_call(url, @username, @apikey, nil, false, @verify_ssl)
|
31
34
|
end
|
32
35
|
|
33
36
|
end
|
34
37
|
|
35
38
|
def get_additional_metrics
|
36
39
|
if (@metric_prefix == 'jfrog.artifactory' || @common_jpd == false) && !@token.nil? && @token != ''
|
37
|
-
puts 'Executing additional metrics collection'
|
38
40
|
url = "#{@jpd_url}/observability/api/v1/metrics"
|
39
|
-
|
40
|
-
|
41
|
+
puts "Executing additional metrics collection from: #{url}"
|
42
|
+
check_endpoint(url, @token, @verify_ssl) if @@obs_endpoint_exists == nil? || !@@obs_endpoint_exists
|
43
|
+
execute_rest_call(url, @username, nil, @token, true, @verify_ssl) if @@obs_endpoint_exists
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
44
|
-
def check_endpoint(url, token)
|
47
|
+
def check_endpoint(url, token, verify_ssl)
|
45
48
|
response = RestClient::Request.new(
|
46
49
|
method: :get,
|
47
50
|
url: url,
|
48
|
-
headers: { Authorization: "Bearer #{token}"
|
51
|
+
headers: { Authorization: "Bearer #{token}"},
|
52
|
+
verify_ssl: verify_ssl
|
49
53
|
).execute do |response, request, result|
|
50
54
|
@@obs_endpoint_exists = true if response.code == 200
|
51
55
|
puts "#{url} exists? -> #{@@obs_endpoint_exists}, storing the result for next executions"
|
52
56
|
end
|
53
57
|
end
|
54
58
|
|
55
|
-
def execute_rest_call(url, user, password, token,
|
59
|
+
def execute_rest_call(url, user, password, token, use_token, verify_ssl)
|
56
60
|
request = if use_token == true
|
57
61
|
RestClient::Request.new(
|
58
62
|
method: :get,
|
59
63
|
url: url,
|
60
|
-
headers: { Authorization: "Bearer #{token}" }
|
64
|
+
headers: { Authorization: "Bearer #{token}" },
|
65
|
+
verify_ssl: verify_ssl
|
61
66
|
)
|
62
67
|
else
|
63
68
|
RestClient::Request.new(
|
64
69
|
method: :get,
|
65
70
|
url: url,
|
66
71
|
user: user,
|
67
|
-
password: password
|
72
|
+
password: password,
|
73
|
+
verify_ssl: verify_ssl
|
68
74
|
)
|
69
75
|
end
|
70
76
|
|
71
77
|
request.execute do |response, request, result|
|
72
78
|
case response.code
|
73
79
|
when 200
|
80
|
+
puts "#{@metric_prefix} metrics were successfully collected from url: #{url}"
|
74
81
|
return response.body
|
75
82
|
else
|
76
|
-
|
77
|
-
|
78
|
-
else
|
79
|
-
raise Fluent::ConfigError, 'Cannot fetch #{@metric_prefix} metrics'
|
80
|
-
end
|
83
|
+
puts "Cannot fetch #{@metric_prefix} metrics from url: #{url}. Received response code: #{response.code}, Response body:\n#{response.body}"
|
84
|
+
raise Fluent::ConfigError, 'Cannot fetch #{@metric_prefix} metrics'
|
81
85
|
end
|
82
86
|
end
|
83
87
|
end
|
@@ -13,18 +13,18 @@ class NewRelicMetricsParser < BaseMetricsParser
|
|
13
13
|
hash_data_array = []
|
14
14
|
data_hash = {}
|
15
15
|
data_array = []
|
16
|
+
puts cleaned_data
|
16
17
|
cleaned_data.each do |interim_data|
|
17
18
|
metrics_hash = {}
|
18
19
|
if interim_data =~ /{/ && interim_data =~ /}/
|
19
20
|
attributes = {}
|
20
21
|
metric_name, additional_dims, metric_val_and_time = interim_data.match(/(.*){(.*)}(.*)/i).captures
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
attributes[attribute_name] = attribute_value.delete_prefix('"').delete_suffix('"')
|
22
|
+
additional_dims.split("\",").each do |interim_data|
|
23
|
+
puts interim_data
|
24
|
+
pair_data = interim_data.gsub("\"", "").gsub("{", "").gsub("}", "")
|
25
|
+
interim_data_value = pair_data.split("=", 2)[1]
|
26
|
+
interim_data_key = pair_data.split("=", 2)[0]
|
27
|
+
attributes[interim_data_key] = interim_data_value
|
28
28
|
end
|
29
29
|
if metric_val_and_time =~ / /
|
30
30
|
metrics_hash['name'] = prefix + separator + metric_name
|
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
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- MahithaB,
|
7
|
+
- MahithaB, BenHarosh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.1.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2.1.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: fluentd
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,14 +92,14 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
95
|
+
version: 2.1.0
|
96
96
|
type: :runtime
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
102
|
+
version: 2.1.0
|
103
103
|
description: Fluentd Plugin for converting JFrog Artifactory, Xray generated metrics
|
104
104
|
(Prometheus Exposition Format) to target observability platform format (Splunk HEC,
|
105
105
|
New Relic, Elastic)
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
|
-
rubygems_version: 3.
|
156
|
+
rubygems_version: 3.5.3
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: Fluentd Plugin for converting JFrog Artifactory, Xray generated metrics (Prometheus
|