fluent-plugin-jfrog-send-metrics-deepakk 0.1.12

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 92658c3544435da8ce651487bf18100b914e8df6ffaca711a1c321c17a01b62f
4
+ data.tar.gz: 43309c8523dadc0c9e754ab83b4fd3087f92ef3fb89d4e42b1f016c78491bb6e
5
+ SHA512:
6
+ metadata.gz: b273203809ecc26d90eb7d4d1f25a943145de3e0933f3582fa108f4c15cfc1e4f8f1dfbd302b151acd4e4d84c696630ca75e4dc7782347067da9630bf6813248
7
+ data.tar.gz: baaf693dfcbd01f534d8e6d33df73f08fbf2b701379ddf591626dcda1498ed092a162df3557df6d564c4dd9e244c645883fc587ad73b4a28798b5a9b3a5ae233
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ group :test do
8
+ gem 'minitest'
9
+ gem 'minitest-reporters', '>= 0.5.0'
10
+ gem 'rest-client', '>= 2.1.0'
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,88 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fluent-plugin-jfrog-send-metrics (0.1.11)
5
+ fluentd (>= 0.14.10, < 2)
6
+ rest-client (~> 2.1.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ansi (1.5.0)
12
+ base64 (0.2.0)
13
+ builder (3.2.4)
14
+ concurrent-ruby (1.3.4)
15
+ cool.io (1.8.1)
16
+ csv (3.3.0)
17
+ domain_name (0.5.20190701)
18
+ unf (>= 0.0.5, < 1.0.0)
19
+ drb (2.2.1)
20
+ fluentd (1.17.0)
21
+ base64 (~> 0.2)
22
+ bundler
23
+ cool.io (>= 1.4.5, < 2.0.0)
24
+ csv (~> 3.2)
25
+ drb (~> 2.2)
26
+ http_parser.rb (>= 0.5.1, < 0.9.0)
27
+ msgpack (>= 1.3.1, < 2.0.0)
28
+ serverengine (>= 2.3.2, < 3.0.0)
29
+ sigdump (~> 0.2.5)
30
+ strptime (>= 0.2.4, < 1.0.0)
31
+ tzinfo (>= 1.0, < 3.0)
32
+ tzinfo-data (~> 1.0)
33
+ webrick (~> 1.4)
34
+ yajl-ruby (~> 1.0)
35
+ http-accept (1.7.0)
36
+ http-cookie (1.0.4)
37
+ domain_name (~> 0.5)
38
+ http_parser.rb (0.8.0)
39
+ mime-types (3.4.1)
40
+ mime-types-data (~> 3.2015)
41
+ mime-types-data (3.2022.0105)
42
+ minitest (5.14.4)
43
+ minitest-reporters (1.4.3)
44
+ ansi
45
+ builder
46
+ minitest (>= 5.0)
47
+ ruby-progressbar
48
+ msgpack (1.7.2)
49
+ netrc (0.11.0)
50
+ power_assert (2.0.1)
51
+ rake (12.3.3)
52
+ rest-client (>= 2.1.0)
53
+ http-accept (>= 1.7.0, < 2.0)
54
+ http-cookie (>= 1.0.2, < 2.0)
55
+ mime-types (>= 1.16, < 4.0)
56
+ netrc (~> 0.8)
57
+ ruby-progressbar (1.11.0)
58
+ serverengine (2.3.2)
59
+ sigdump (~> 0.2.2)
60
+ sigdump (0.2.5)
61
+ strptime (0.2.5)
62
+ test-unit (3.5.3)
63
+ power_assert
64
+ tzinfo (2.0.6)
65
+ concurrent-ruby (~> 1.0)
66
+ tzinfo-data (1.2024.1)
67
+ tzinfo (>= 1.0.0)
68
+ unf (0.1.4)
69
+ unf_ext
70
+ unf_ext (0.0.8)
71
+ webrick (1.8.1)
72
+ yajl-ruby (1.4.3)
73
+
74
+ PLATFORMS
75
+ ruby
76
+ universal-darwin-21
77
+
78
+ DEPENDENCIES
79
+ bundler (> 1.14)
80
+ fluent-plugin-jfrog-send-metrics!
81
+ minitest
82
+ minitest-reporters (>= 0.5.0)
83
+ rake (~> 12.0)
84
+ rest-client (>= 2.1.0)
85
+ test-unit (~> 3.0)
86
+
87
+ BUNDLED WITH
88
+ 2.3.8
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # fluent-plugin-jfrog-send-metrics
2
+
3
+ [Fluentd](https://fluentd.org/) output plugin to consume metrics emitted from [fluent-plugin-jfrog-metrics](https://github.com/jfrog/jfrog-fluentd-plugins/tree/main/fluent-plugin-jfrog-metrics) input plugin and send them to respective log-vendors.
4
+
5
+ ## Building
6
+
7
+ To build / test locally use rake:
8
+
9
+ ```text
10
+ rake
11
+ ```
12
+
13
+ To build install locally use bundler:
14
+
15
+ ```text
16
+ bundle install
17
+ ```
18
+
19
+ This will install the gem shown below from source.
20
+
21
+ ## Development
22
+
23
+ ### Bundler
24
+
25
+ Add following line to your Gemfile:
26
+
27
+ ```ruby
28
+ gem "fluent-plugin-jfrog-send-metrics"
29
+ ```
30
+
31
+ And then execute:
32
+
33
+ ```
34
+ $ bundle
35
+ ```
36
+
37
+ ## Configuration
38
+
39
+ You can generate configuration template:
40
+
41
+ ```
42
+ $ fluent-plugin-config-format output jfrog-send-metrics
43
+ ```
44
+
45
+ You can copy and paste generated documents here.
46
+
47
+ ## Installation
48
+
49
+ ### RubyGems
50
+
51
+ ```
52
+ $ gem install rest-client
53
+ $ gem install fluent-plugin-jfrog-send-metrics
54
+ ```
55
+
56
+ ### Setup & configuration
57
+
58
+ Fluentd is the supported log collector for this integration. For Fluentd setup and information, read the JFrog log analytics repository's [README](https://github.com/jfrog/log-analytics/blob/master/README.md).
59
+
60
+ #### Fluentd config
61
+
62
+ Configure the match directive parameters as specified below
63
+
64
+ ```
65
+ <match jfrog.metrics.**>
66
+ @type jfrog_send_metrics
67
+ target_platform "NEWRELIC" # or "DATADOG"
68
+ apikey <api_key>
69
+ url https://metric-api.newrelic.com/metric/v1 # or DataDog's metrics URL
70
+ http_proxy <proxy_url>
71
+ </match>
72
+ ```
73
+
74
+ #### Configuration parameters
75
+
76
+ Obtain respective authentication credentials for log-vendors
77
+
78
+ * **target_platform**(string)(required): The target log-vendor ("NEWRELIC" or "DATADOG")
79
+ * **apikey**(string)(required): APIKEY is the apikey of log-vendor for authentication(LicenseKey for NewRelic)
80
+ * **url**(string)(required): Metrics url of the mertics-vendor (Metrics URL for NewRelic or DataDog)
81
+ * **http_proxy**(string)(optional): Proxy server URL - which will proxy http/s calls to your observability vendor (DataDog/NewRelic)
82
+ * **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
83
+ * Default value: true
84
+ * **gzip_compression** (true / false) (optional): This flag should be set as true for compressing (gzip) the metrics payload on outbound posts. This parameter is set to false by default for backwards compatibility.
85
+ * Default value: false
86
+ * **request_timeout** (integer) (optional): Http request timeout when calling Artifactory/Xray to pull new events (http client)
87
+ * Default value: `20`
88
+
89
+ ## Copyright
90
+
91
+ * Copyright(c) 2024 - JFrog
92
+ * Maintainers - MahithaB, BenHarosh
93
+ * License
94
+ * Apache License, Version 2.0
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require "bundler"
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs.push("lib", "test")
8
+ t.test_files = FileList["test/**/test_*.rb"]
9
+ t.verbose = true
10
+ t.warning = true
11
+ end
12
+
13
+ task default: [:test]
@@ -0,0 +1,29 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "fluent-plugin-jfrog-send-metrics-deepakk"
6
+ spec.version = "0.1.12"
7
+ spec.authors = ["MahithaB", "BenH"]
8
+ spec.email = ["partner_support@jfrog.com"]
9
+
10
+ spec.summary = %q{Fluentd Plugin for sending metrics to the respective log-vendor}
11
+ spec.description = %q{Fluentd Plugin for sending metrics to the respective log-vendor}
12
+ spec.homepage = "https://github.com/jfrog/jfrog-fluentd-plugins/tree/main/fluent-plugin-jfrog-send-metrics"
13
+ spec.license = "Apache-2.0"
14
+
15
+ test_files, files = `git ls-files -z`.split("\x0").partition do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.files = files
19
+ spec.executables = files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = test_files
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "> 1.14"
24
+ spec.add_development_dependency "rake", "~> 12.0"
25
+ spec.add_development_dependency "test-unit", "~> 3.0"
26
+ spec.add_development_dependency "rest-client", "~> 2.1.0"
27
+ spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
28
+ spec.add_runtime_dependency "rest-client", "~> 2.1.0"
29
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+ require 'json'
3
+ require 'rest-client'
4
+ require 'uri'
5
+ require 'stringio'
6
+ require_relative 'utility'
7
+ require_relative 'proxy_helper'
8
+
9
+ class DatadogMetrics
10
+ def initialize(apikey, url)
11
+ @apikey = apikey
12
+ @url = url
13
+ end
14
+
15
+ def add_custom_data(ddtags, record)
16
+ if ddtags.length() > 0
17
+ record_series = record['series']
18
+ data_array = []
19
+ record_series.each do |interim_data|
20
+ interim_data['tags'] ||= []
21
+ interim_data['tags'].push(*ddtags)
22
+ data_array << interim_data
23
+ end
24
+ record['series'] = data_array
25
+ return record
26
+ end
27
+ return record
28
+ end
29
+
30
+ def send_metrics(ddtags, record, http_proxy, verify_ssl, request_timeout, gzip_compression, logger)
31
+ # Get the current local timestamp
32
+ logger.info("Additional tags to be added to metrics are:", ddtags)
33
+ metrics_data = add_custom_data(ddtags, record)
34
+ logger.info("Sending received metrics data")
35
+
36
+ # Configure proxy with NO_PROXY support
37
+ ProxyHelper.configure_rest_client_proxy(@url, http_proxy, logger)
38
+
39
+ headers = {
40
+ 'DD-API-KEY': @apikey,
41
+ content_type: :json
42
+ }
43
+
44
+ payload = metrics_data.to_json
45
+ if gzip_compression
46
+ payload = Utility.compress_payload(metrics_data, logger)
47
+ headers[:'Content-Encoding'] = 'gzip'
48
+ end
49
+
50
+ request = RestClient::Request.new(
51
+ method: :post,
52
+ url: @url,
53
+ payload: payload,
54
+ headers: headers,
55
+ verify_ssl: verify_ssl,
56
+ timeout: request_timeout
57
+ )
58
+
59
+ request.execute do |response, request, result|
60
+ case response.code
61
+ when 202
62
+ logger.info("Metrics were successfully sent to DataDog")
63
+ return response.body
64
+ else
65
+ logger.info("Cannot send metrics to DataDog url: %s. Received response code: %d, Response body: %s" % [@url, response.code, response.body])
66
+ end
67
+ end
68
+ end
69
+ end
70
+
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+ require 'json'
3
+ require 'rest-client'
4
+ require 'stringio'
5
+ require_relative 'utility'
6
+
7
+ class NewRelicMetrics
8
+ def initialize(apikey, url)
9
+ @apikey = apikey
10
+ @url = url
11
+ end
12
+
13
+ def send_metrics(metrics_data, http_proxy, verify_ssl, request_timeout, gzip_compression, logger)
14
+ logger.info("Sending received metrics data")
15
+ metrics_payload = []
16
+ metrics_payload.push(JSON.parse(metrics_data.to_json))
17
+
18
+ if http_proxy
19
+ RestClient.proxy = URI.parse(http_proxy)
20
+ logger.info("Using http_proxy param to set proxy for request. Proxy url: #{RestClient.proxy}")
21
+ elsif ENV['HTTP_PROXY']
22
+ RestClient.proxy = ENV['HTTP_PROXY']
23
+ logger.info("Using 'HTTP_PROXY' environment variable to set proxy for request. Proxy url: #{RestClient.proxy}")
24
+ elsif ENV['http_proxy']
25
+ RestClient.proxy = ENV['http_proxy']
26
+ logger.info("Using 'http_proxy' environment variable to set proxy for request. Proxy url: #{RestClient.proxy}")
27
+ elsif ENV['https_proxy']
28
+ RestClient.proxy = ENV['https_proxy']
29
+ logger.info("Using 'https_proxy' environment variable to set proxy for request. Proxy url: #{RestClient.proxy}")
30
+ end
31
+
32
+ headers = {
33
+ params: {'Api-Key' => @apikey}
34
+ }
35
+ payload = metrics_payload.to_json
36
+ if gzip_compression
37
+ payload = Utility.compress_payload(metrics_payload, logger)
38
+ headers[:'Content-Encoding'] = 'gzip'
39
+ end
40
+
41
+ request = RestClient::Request.new(
42
+ method: :post,
43
+ url: @url,
44
+ payload: payload,
45
+ headers: headers,
46
+ verify_ssl: verify_ssl,
47
+ timeout: request_timeout
48
+ )
49
+
50
+ request.execute do |response, request, result|
51
+ case response.code
52
+ when 202
53
+ logger.info("Metrics were successfully sent to NewRelic")
54
+ return response.body
55
+ else
56
+ logger.info("Cannot send metrics to NewRelic url: %s. Received response code: %d, Response body: %s" % [@url, response.code, response.body])
57
+ end
58
+ end
59
+ end
60
+ end
61
+
@@ -0,0 +1,77 @@
1
+ #
2
+ # Copyright 2022- MahithaB
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/output"
17
+ require 'rest-client'
18
+ require_relative 'newrelic_metrics_sender'
19
+ require_relative 'datadog_metrics_sender'
20
+
21
+ module Fluent
22
+ module Plugin
23
+ class JfrogSendMetricsOutput < Fluent::Plugin::Output
24
+ Fluent::Plugin.register_output("jfrog_send_metrics", self)
25
+ helpers :timer
26
+ # `config_param` defines a parameter.
27
+ # You can refer to a parameter like an instance variable e.g. @port.
28
+ # `:default` means that the parameter is optional.
29
+ config_param :target_platform, :string, default: ''
30
+ config_param :apikey, :string, default: ''
31
+ config_param :url, :string, default: 'https://metric-api.newrelic.com/metric/v1'
32
+ config_param :ddtags, :array, default: []
33
+ config_param :http_proxy, :string, :default => nil
34
+ config_param :verify_ssl, :bool, default: true
35
+ config_param :request_timeout, :time, default: 20
36
+ config_param :gzip_compression, :bool, default: false
37
+
38
+ # `configure` is called before `start`.
39
+ # 'conf' is a `Hash` that includes the configuration parameters.
40
+ # If the configuration is invalid, raise `Fluent::ConfigError`.
41
+ def configure(conf)
42
+ super
43
+
44
+ raise Fluent::ConfigError, 'Must define the target_platform to be one of the following (DATADOG, NEWRELIC).' if @target_platform == '' || !(['DATADOG', 'NEWRELIC'].include?(@target_platform))
45
+
46
+ raise Fluent::ConfigError, 'Must define the apikey to use for authentication.' if @apikey == ''
47
+ end
48
+
49
+ def process(tag, es)
50
+ logger = log
51
+ es.each do |time, record|
52
+ begin
53
+ logger.info("Sending metrics to target platform: #{@target_platform} started")
54
+ if @target_platform == 'NEWRELIC'
55
+ vendor = NewRelicMetrics.new(@apikey, @url)
56
+ vendor.send_metrics(record, @http_proxy, @verify_ssl, @request_timeout, @gzip_compression, logger)
57
+ elsif @target_platform == 'DATADOG'
58
+ vendor = DatadogMetrics.new(@apikey, @url)
59
+ vendor.send_metrics(@ddtags, record, @http_proxy, @verify_ssl, @request_timeout, @gzip_compression, logger)
60
+ end
61
+ logger.info("Sending metrics to target platform: #{@target_platform} finished")
62
+ rescue RestClient::Exceptions::OpenTimeout
63
+ logger.info("The request timed out while trying to open a connection. The configured request timeout is: #{@request_timeout}")
64
+ rescue RestClient::Exceptions::ReadTimeout
65
+ logger.info("The request timed out while waiting for a response. The configured request timeout is: #{@request_timeout}")
66
+ rescue RestClient::ExceptionWithResponse => e
67
+ logger.info("HTTP request failed: #{e.response}")
68
+ rescue Net::HTTPClientException => e
69
+ logger.info("An HTTP client error occurred when sending metrics to #{@target_platform}: #{e.message}")
70
+ rescue StandardError => e
71
+ logger.info("An error occurred when sending metrics to #{@target_platform}: #{e.message}")
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+
5
+ module ProxyHelper
6
+ # Check if a host should bypass the proxy based on NO_PROXY environment variable
7
+ def self.should_bypass_proxy?(url, logger = nil)
8
+ no_proxy = ENV['NO_PROXY'] || ENV['no_proxy']
9
+ return false if no_proxy.nil? || no_proxy.empty?
10
+
11
+ begin
12
+ target_host = URI.parse(url).host
13
+ return false if target_host.nil?
14
+
15
+ no_proxy_hosts = no_proxy.split(',').map(&:strip)
16
+
17
+ no_proxy_hosts.each do |pattern|
18
+ next if pattern.empty?
19
+
20
+ # Remove leading dot if present (e.g., ".example.com" -> "example.com")
21
+ # Downcase both for case-insensitive matching (domain names are case-insensitive per RFC 1035)
22
+ pattern = pattern.sub(/^\./, '').downcase
23
+ target_host_lower = target_host.downcase
24
+
25
+ # Check for exact match or subdomain match
26
+ if target_host_lower == pattern || target_host_lower.end_with?(".#{pattern}")
27
+ logger&.debug("Host '#{target_host}' matches NO_PROXY pattern '#{pattern}', bypassing proxy")
28
+ return true
29
+ end
30
+
31
+ # Check for wildcard
32
+ if pattern == '*'
33
+ logger&.debug("NO_PROXY contains '*', bypassing proxy for all hosts")
34
+ return true
35
+ end
36
+ end
37
+ rescue URI::InvalidURIError => e
38
+ logger&.warn("Failed to parse URL '#{url}': #{e.message}")
39
+ return false
40
+ end
41
+
42
+ false
43
+ end
44
+
45
+ # Get the proxy URL to use for a given target URL
46
+ # Returns nil if proxy should be bypassed, otherwise returns the proxy URL
47
+ def self.get_proxy_for_url(url, http_proxy_param = nil, logger = nil)
48
+ # Check if this URL should bypass proxy
49
+ if should_bypass_proxy?(url, logger)
50
+ return nil
51
+ end
52
+
53
+ # Return proxy URL in order of precedence
54
+ if http_proxy_param && !http_proxy_param.empty?
55
+ logger&.debug("Using http_proxy param for request. Proxy url: #{http_proxy_param}")
56
+ return http_proxy_param
57
+ elsif ENV['HTTP_PROXY'] && !ENV['HTTP_PROXY'].empty?
58
+ logger&.debug("Using 'HTTP_PROXY' environment variable for request. Proxy url: #{ENV['HTTP_PROXY']}")
59
+ return ENV['HTTP_PROXY']
60
+ elsif ENV['http_proxy'] && !ENV['http_proxy'].empty?
61
+ logger&.debug("Using 'http_proxy' environment variable for request. Proxy url: #{ENV['http_proxy']}")
62
+ return ENV['http_proxy']
63
+ elsif ENV['HTTPS_PROXY'] && !ENV['HTTPS_PROXY'].empty?
64
+ logger&.debug("Using 'HTTPS_PROXY' environment variable for request. Proxy url: #{ENV['HTTPS_PROXY']}")
65
+ return ENV['HTTPS_PROXY']
66
+ elsif ENV['https_proxy'] && !ENV['https_proxy'].empty?
67
+ logger&.debug("Using 'https_proxy' environment variable for request. Proxy url: #{ENV['https_proxy']}")
68
+ return ENV['https_proxy']
69
+ end
70
+
71
+ nil
72
+ end
73
+
74
+ # Configure RestClient proxy for a given URL
75
+ def self.configure_rest_client_proxy(url, http_proxy_param = nil, logger = nil)
76
+ proxy_url = get_proxy_for_url(url, http_proxy_param, logger)
77
+
78
+ if proxy_url.nil?
79
+ RestClient.proxy = nil
80
+ logger&.debug("Proxy disabled for URL: #{url}")
81
+ else
82
+ RestClient.proxy = proxy_url
83
+ logger&.debug("Proxy enabled for URL: #{url}, using: #{proxy_url}")
84
+ end
85
+ end
86
+ end
87
+
88
+
@@ -0,0 +1,26 @@
1
+ require 'zlib'
2
+
3
+ class Utility
4
+ def self.compress_payload(payload, logger)
5
+ logger.info("Compressing metrics payload")
6
+ json_payload = payload.to_json
7
+
8
+ # Compress the JSON string using zlib's GzipWriter
9
+ compressed_payload = StringIO.new
10
+ Zlib::GzipWriter.wrap(compressed_payload) do |gz|
11
+ begin
12
+ gz.write(json_payload)
13
+ ensure
14
+ gz.close
15
+ end
16
+ end
17
+
18
+ # convert the compressed data to a string
19
+ compressed_data = compressed_payload.string
20
+
21
+ logger.debug("Original metrics payload size: #{json_payload.bytesize} bytes")
22
+ logger.debug("Compressed metrics payload size: #{compressed_data.bytesize} bytes")
23
+
24
+ return compressed_data
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+ $newrelic_apikey = ''
3
+ $url = 'https://metric-api.newrelic.com/metric/v1'
4
+
5
+ def get_newrelic_credentials
6
+ [$newrelic_apikey, $url]
7
+ end
@@ -0,0 +1,3 @@
1
+ [
2
+ {"metrics":[{"name":"jfrog.artifactory.jfrt_runtime_heap_freememory_bytes","value":546559184,"timestamp":1645812876593},{"name":"jfrog.artifactory.jfrt_runtime_heap_maxmemory_bytes","value":2147483648,"timestamp":1645812876593},{"name":"jfrog.artifactory.jfrt_runtime_heap_totalmemory_bytes","value":1306525696,"timestamp":1645812876593},{"name":"jfrog.artifactory.jfrt_runtime_heap_processors_total","value":1,"timestamp":1645812876593},{"name":"jfrog.artifactory.jfrt_db_connections_active_total","value":0,"timestamp":1645812876593},{"name":"jfrog.artifactory.jfrt_db_connections_idle_total","value":1,"timestamp":1645812876593},{"name":"jfrog.artifactory.jfrt_db_connections_max_active_total","value":80,"timestamp":1645812876593},{"name":"jfrog.artifactory.jfrt_db_connections_min_idle_total","value":1,"timestamp":1645812876593},{"name":"jfrog.artifactory.jfrt_projects_active_total","value":0,"timestamp":1645812876593},{"name":"jfrog.artifactory.jfrt_storage_current_total_size_bytes","value":0,"timestamp":1645812876593},{"name":"jfrog.artifactory.app_disk_used_bytes","value":393256960,"timestamp":1645812876593},{"name":"jfrog.artifactory.app_disk_free_bytes","value":209848303616,"timestamp":1645812876593},{"name":"jfrog.artifactory.jfrt_artifacts_gc_next_run_seconds","value":14348,"timestamp":1645812876593}]}
3
+ ]
@@ -0,0 +1,3 @@
1
+ [
2
+ {"metrics":[{"name":"jfrog.xray.app_disk_used_bytes","value":14808166400.0,"timestamp":1645811154337},{"name":"jfrog.xray.app_disk_free_bytes","value":33568542720.0,"timestamp":1645811154337},{"name":"jfrog.xray.app_io_counters_write_bytes","value":1217306624.0,"timestamp":1645811154337},{"name":"jfrog.xray.app_io_counters_read_bytes","value":210030592.0,"timestamp":1645811154337},{"name":"jfrog.xray.app_self_metrics_calc_seconds","value":0.050925766,"timestamp":1645811154337},{"name":"jfrog.xray.app_self_metrics_total","value":31,"timestamp":1645811154337},{"name":"jfrog.xray.db_connection_pool_in_use_total","value":0,"timestamp":1645811154337},{"name":"jfrog.xray.db_connection_pool_idle_total","value":5,"timestamp":1645811154337},{"name":"jfrog.xray.db_connection_pool_max_open_total","value":60,"timestamp":1645811154337},{"name":"jfrog.xray.go_memstats_heap_in_use_bytes","value":198139904.0,"timestamp":1645811154337},{"name":"jfrog.xray.go_memstats_heap_allocated_bytes","value":185429088.0,"timestamp":1645811154337},{"name":"jfrog.xray.go_memstats_heap_idle_bytes","value":135733248.0,"timestamp":1645811154337},{"name":"jfrog.xray.go_memstats_heap_objects_total","value":1931860.0,"timestamp":1645811154337},{"name":"jfrog.xray.go_memstats_heap_reserved_bytes","value":333873152.0,"timestamp":1645811154337},{"name":"jfrog.xray.go_memstats_gc_cpu_fraction_ratio","value":0.00024063137131169772,"timestamp":1645811154337},{"name":"jfrog.xray.go_routines_total","value":169,"timestamp":1645811154337},{"name":"jfrog.xray.jfxr_data_artifacts_total","value":1,"timestamp":1645811154337,"attributes":{"package_type":"generic"}},{"name":"jfrog.xray.jfxr_data_components_total","value":1,"timestamp":1645811154337,"attributes":{"package_type":"generic"}},{"name":"jfrog.xray.jfxr_db_sync_running_total","value":0,"timestamp":1645811154337},{"name":"jfrog.xray.jfxr_jira_last_ticket_creation_time_seconds","value":0,"timestamp":1645811154337},{"name":"jfrog.xray.jfxr_jira_no_of_errors_in_last_hour_total","value":0,"timestamp":1645811154337},{"name":"jfrog.xray.jfxr_jira_last_error_time_seconds","value":0,"timestamp":1645811154337},{"name":"jfrog.xray.jfxr_jira_no_of_integrations_total","value":0,"timestamp":1645811154337},{"name":"jfrog.xray.jfxr_jira_no_of_profiles_total","value":0,"timestamp":1645811154337},{"name":"jfrog.xray.jfxr_jira_no_of_tickets_created_in_last_one_hour_total","value":0,"timestamp":1645811154337},{"name":"jfrog.xray.jfxr_performance_server_up_time_seconds","value":928277.850744045,"timestamp":1645811154337},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"alert"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"alertImpactAnalysis"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"alertImpactAnalysisRetry"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"alertRetry"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"analysis"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"analysisExistingContent"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"analysisExistingContentRetry"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"analysisRetry"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"buildReport_xray-0"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"failure"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"gcSyncMaster"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"impactAnalysis"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"impactAnalysisRetry"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"impactPathRecovery"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"impactPathRecoveryRetry"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"index"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"indexExistingContentRetry"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"indexExistsContent"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"indexRetry"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"job"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"mdsUpdate"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"mdsUpdateExistingContent"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"mdsUpdateExistingContentRetry"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"mdsUpdateRetry"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"notification"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"notificationRetry"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"persist"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"persistExistingContent"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"persistExistingContentRetry"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"persistRetry"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"report"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"reportRetry"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"ticketing"}},{"name":"jfrog.xray.queue_messages_total","value":0,"timestamp":1645811154337,"attributes":{"queue_name":"ticketingRetry","new_queue_name":"ticketingRetry2"}},{"name":"jfrog.xray.sys_cpu_ratio","value":0.3333333337029058,"timestamp":1645811154337},{"name":"jfrog.xray.sys_load_1","value":2,"timestamp":1645811154337},{"name":"jfrog.xray.sys_load_5","value":1.82,"timestamp":1645811154337},{"name":"jfrog.xray.sys_load_15","value":1.73,"timestamp":1645811154337},{"name":"jfrog.xray.sys_memory_used_bytes","value":6971801600.0,"timestamp":1645811154337},{"name":"jfrog.xray.sys_memory_free_bytes","value":317022208.0,"timestamp":1645811154337}]}
3
+ ]
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+ [
3
+ File.join(File.dirname(__FILE__), '..'),
4
+ File.join(File.dirname(__FILE__), '..', 'lib/fluent/plugin'),
5
+ File.join(File.dirname(__FILE__), '..', 'spec'),
6
+ ].each do |dir|
7
+ $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir)
8
+ end
9
+
10
+ require 'newrelic_metrics_sender'
11
+ require 'date'
12
+ require 'rspec'
13
+ require 'rest-client'
14
+ require './spec/fixtures/files/creds'
15
+
16
+
17
+ RSpec.describe NewRelicMetrics do
18
+ newrelic_apikey, url = get_newrelic_credentials
19
+ describe "#emit_parsed_metrics" do
20
+ it 'should read sample Artifactory metrics data and verify the size of parsed data > 1' do
21
+ platform_metrics = File.read('./spec/fixtures/files/sample_artifactory_newrelic_metrics.txt')
22
+ expect(platform_metrics.size).to be > 1
23
+
24
+ response = RestClient::Request.new(
25
+ method: :post,
26
+ url: url,
27
+ payload: platform_metrics,
28
+ headers: {params: {'Api-Key' => newrelic_apikey, "Content-Type" => "application/json"}}
29
+ ).execute do |response, request, result|
30
+ puts response
31
+ expect(response.code).to eq(202)
32
+ expect(response.size).to be > 1
33
+ end
34
+ end
35
+
36
+ it 'should read sample Xray metrics data and verify the size of parsed data > 1' do
37
+ platform_metrics = File.read('./spec/fixtures/files/sample_xray_newrelic_metrics.txt')
38
+ expect(platform_metrics.size).to be > 1
39
+
40
+ response = RestClient::Request.new(
41
+ method: :post,
42
+ url: url,
43
+ payload: platform_metrics,
44
+ headers: {params: {'Api-Key' => newrelic_apikey, "Content-Type" => "application/json"}}
45
+ ).execute do |response, request, result|
46
+ puts response
47
+ expect(response.code).to eq(202)
48
+ expect(response.size).to be > 1
49
+ end
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,111 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
16
+
17
+ [
18
+ File.join(File.dirname(__FILE__), '..'),
19
+ File.join(File.dirname(__FILE__), '..', 'lib/fluent/plugin'),
20
+ File.join(File.dirname(__FILE__), '..', 'spec')
21
+ ].each do |dir|
22
+ $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir)
23
+ end
24
+
25
+ require 'newrelic_metrics_sender'
26
+
27
+ RSpec.configure do |config|
28
+ # rspec-expectations config goes here. You can use an alternate
29
+ # assertion/expectation library such as wrong or the stdlib/minitest
30
+ # assertions if you prefer.
31
+ config.expect_with :rspec do |expectations|
32
+ # This option will default to `true` in RSpec 4. It makes the `description`
33
+ # and `failure_message` of custom matchers include text for helper methods
34
+ # defined using `chain`, e.g.:
35
+ # be_bigger_than(2).and_smaller_than(4).description
36
+ # # => "be bigger than 2 and smaller than 4"
37
+ # ...rather than:
38
+ # # => "be bigger than 2"
39
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
40
+ end
41
+
42
+ # rspec-mocks config goes here. You can use an alternate test double
43
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
44
+ config.mock_with :rspec do |mocks|
45
+ # Prevents you from mocking or stubbing a method that does not exist on
46
+ # a real object. This is generally recommended, and will default to
47
+ # `true` in RSpec 4.
48
+ mocks.verify_partial_doubles = true
49
+ end
50
+
51
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
52
+ # have no way to turn it off -- the option exists only for backwards
53
+ # compatibility in RSpec 3). It causes shared context metadata to be
54
+ # inherited by the metadata hash of host groups and examples, rather than
55
+ # triggering implicit auto-inclusion in groups with matching metadata.
56
+ config.shared_context_metadata_behavior = :apply_to_host_groups
57
+
58
+ # The settings below are suggested to provide a good initial experience
59
+ # with RSpec, but feel free to customize to your heart's content.
60
+ =begin
61
+ # This allows you to limit a spec run to individual examples or groups
62
+ # you care about by tagging them with `:focus` metadata. When nothing
63
+ # is tagged with `:focus`, all examples get run. RSpec also provides
64
+ # aliases for `it`, `describe`, and `context` that include `:focus`
65
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
66
+ config.filter_run_when_matching :focus
67
+
68
+ # Allows RSpec to persist some state between runs in order to support
69
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
70
+ # you configure your source control system to ignore this file.
71
+ config.example_status_persistence_file_path = "spec/examples.txt"
72
+
73
+ # Limits the available syntax to the non-monkey patched syntax that is
74
+ # recommended. For more details, see:
75
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
76
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
77
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
78
+ config.disable_monkey_patching!
79
+
80
+ # This setting enables warnings. It's recommended, but in some cases may
81
+ # be too noisy due to issues in dependencies.
82
+ config.warnings = true
83
+
84
+ # Many RSpec users commonly either run the entire suite or an individual
85
+ # file, and it's useful to allow more verbose output when running an
86
+ # individual spec file.
87
+ if config.files_to_run.one?
88
+ # Use the documentation formatter for detailed output,
89
+ # unless a formatter has already been configured
90
+ # (e.g. via a command-line flag).
91
+ config.default_formatter = "doc"
92
+ end
93
+
94
+ # Print the 10 slowest examples and example groups at the
95
+ # end of the spec run, to help surface which specs are running
96
+ # particularly slow.
97
+ config.profile_examples = 10
98
+
99
+ # Run specs in random order to surface order dependencies. If you find an
100
+ # order dependency and want to debug it, you can fix the order by providing
101
+ # the seed, which is printed after each run.
102
+ # --seed 1234
103
+ config.order = :random
104
+
105
+ # Seed global randomization in this process using the `--seed` CLI option.
106
+ # Setting this allows you to use `--seed` to deterministically reproduce
107
+ # test failures related to randomization by passing the same `--seed` value
108
+ # as the one that triggered the failure.
109
+ Kernel.srand config.seed
110
+ =end
111
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift(File.expand_path("../../", __FILE__))
2
+ require "test-unit"
3
+ require "fluent/test"
4
+ require "fluent/test/driver/output"
5
+ require "fluent/test/helpers"
6
+
7
+ Test::Unit::TestCase.include(Fluent::Test::Helpers)
8
+ Test::Unit::TestCase.extend(Fluent::Test::Helpers)
@@ -0,0 +1,36 @@
1
+ require "helper"
2
+ require "fluent/plugin/out_jfrog_send_metrics.rb"
3
+
4
+ class JfrogSendMetricsOutputTest < Test::Unit::TestCase
5
+ setup do
6
+ Fluent::Test.setup
7
+ end
8
+
9
+ test "failure" do
10
+ #flunk
11
+ end
12
+
13
+ private
14
+
15
+ # Default configuration for tests
16
+ CONFIG = %(
17
+ target_platform "NEWRELIC"
18
+ apikey "apiKey"
19
+ url "https://metric-api.newrelic.com/metric/v1"
20
+ )
21
+
22
+ def create_driver(conf)
23
+ Fluent::Test::Driver::Output.new(Fluent::Plugin::JfrogSendMetricsOutput).configure(conf)
24
+ end
25
+
26
+ sub_test_case 'Testing' do
27
+ test 'Testing plugin jfrog_send_metrics' do
28
+ d = create_driver(CONFIG)
29
+ begin
30
+ d.run
31
+ rescue StandardError => e
32
+ raise "Test failed due to #{e}"
33
+ end
34
+ end
35
+ end
36
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-jfrog-send-metrics-deepakk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.12
5
+ platform: ruby
6
+ authors:
7
+ - MahithaB
8
+ - BenH
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2026-01-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.14'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.14'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '12.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '12.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: test-unit
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '3.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rest-client
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 2.1.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 2.1.0
70
+ - !ruby/object:Gem::Dependency
71
+ name: fluentd
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 0.14.10
77
+ - - "<"
78
+ - !ruby/object:Gem::Version
79
+ version: '2'
80
+ type: :runtime
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 0.14.10
87
+ - - "<"
88
+ - !ruby/object:Gem::Version
89
+ version: '2'
90
+ - !ruby/object:Gem::Dependency
91
+ name: rest-client
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.1.0
97
+ type: :runtime
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 2.1.0
104
+ description: Fluentd Plugin for sending metrics to the respective log-vendor
105
+ email:
106
+ - partner_support@jfrog.com
107
+ executables: []
108
+ extensions: []
109
+ extra_rdoc_files: []
110
+ files:
111
+ - ".rspec"
112
+ - Gemfile
113
+ - Gemfile.lock
114
+ - LICENSE
115
+ - README.md
116
+ - Rakefile
117
+ - fluent-plugin-jfrog-send-metrics.gemspec
118
+ - lib/fluent/plugin/datadog_metrics_sender.rb
119
+ - lib/fluent/plugin/newrelic_metrics_sender.rb
120
+ - lib/fluent/plugin/out_jfrog_send_metrics.rb
121
+ - lib/fluent/plugin/proxy_helper.rb
122
+ - lib/fluent/plugin/utility.rb
123
+ - spec/fixtures/files/creds.rb
124
+ - spec/fixtures/files/sample_artifactory_newrelic_metrics.txt
125
+ - spec/fixtures/files/sample_xray_newrelic_metrics.txt
126
+ - spec/lib/newrelic_metrics_sender_spec.rb
127
+ - spec/spec_helper.rb
128
+ - test/helper.rb
129
+ - test/plugin/test_out_jfrog_send_metrics.rb
130
+ homepage: https://github.com/jfrog/jfrog-fluentd-plugins/tree/main/fluent-plugin-jfrog-send-metrics
131
+ licenses:
132
+ - Apache-2.0
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubygems_version: 3.0.3.1
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: Fluentd Plugin for sending metrics to the respective log-vendor
153
+ test_files:
154
+ - spec/fixtures/files/creds.rb
155
+ - spec/fixtures/files/sample_artifactory_newrelic_metrics.txt
156
+ - spec/fixtures/files/sample_xray_newrelic_metrics.txt
157
+ - spec/lib/newrelic_metrics_sender_spec.rb
158
+ - spec/spec_helper.rb
159
+ - test/helper.rb
160
+ - test/plugin/test_out_jfrog_send_metrics.rb