fluent-plugin-jfrog-send-metrics 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: dd62b6f383bac20cabda8fae79fce79add0502c8a5d5a0fcd2b7030ca5c20565
4
+ data.tar.gz: e48147f7ea482b85fbb40dfed81b9c3b11b5f142d5b47733689cc41c26544094
5
+ SHA512:
6
+ metadata.gz: 6f44b9765d16eb082126f928bc2ce80f10b851c1901cc2554ab5d0253c6648a8a6916beb22a41270397c39f5c1af82c019d7682a7a5e98859f3af22962c60774
7
+ data.tar.gz: 1e5ab4e3b8c7d19fc14b249a668346adf28bcad16c5ddc2eadbae420eec0db1da59023464ef26d0ec5cc29853fc560781ec6cffab5d88f9167589f9560684cfa
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "fluent-plugin-jfrog-send-metrics"
4
+
5
+ gemspec
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,83 @@
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"
68
+ apikey <api_key>
69
+ </match>
70
+
71
+ ```
72
+ #### Configuration parameters
73
+
74
+ Obtain respective authentication credentials for log-vendors
75
+
76
+ * **target_platform**(string)(required): The target log-vendor ("NEWRELIC" or "DATADOG")
77
+ * **apikey**(string)(required): APIKEY is the apikey of log-vendor for authentication(LicenseKey for NewRelic)
78
+
79
+ ## Copyright
80
+
81
+ * Copyright(c) 2022- MahithaB
82
+ * License
83
+ * 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"
6
+ spec.version = "0.1.0"
7
+ spec.authors = ["MahithaB"]
8
+ spec.email = ["60710901+MahithaB@users.noreply.github.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.0"
27
+ spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
28
+ spec.add_runtime_dependency "rest-client", "~> 2.0"
29
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+ require 'json'
3
+
4
+ class NewRelicMetrics
5
+ def initialize(apikey)
6
+ @apikey = apikey
7
+ end
8
+
9
+ def send_metrics(metrics_data)
10
+ metrics_payload = []
11
+ metrics_payload.push(JSON.parse(metrics_data.to_json))
12
+ response = RestClient::Request.new(
13
+ method: :post,
14
+ url: "https://metric-api.newrelic.com/metric/v1",
15
+ payload: metrics_payload.to_json,
16
+ headers: {params: {'Api-Key' => @apikey}}
17
+ ).execute do |response, request, result|
18
+ case response.code
19
+ when 202
20
+ return response.body
21
+ else
22
+ puts 'Cannot send metrics to NewRelic'
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,51 @@
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_relative 'newrelic_metrics_sender'
18
+
19
+ module Fluent
20
+ module Plugin
21
+ class JfrogSendMetricsOutput < Fluent::Plugin::Output
22
+ Fluent::Plugin.register_output("jfrog_send_metrics", self)
23
+ helpers :timer
24
+ # `config_param` defines a parameter.
25
+ # You can refer to a parameter like an instance variable e.g. @port.
26
+ # `:default` means that the parameter is optional.
27
+ config_param :target_platform, :string, default: ''
28
+ config_param :apikey, :string, default: ''
29
+
30
+ # `configure` is called before `start`.
31
+ # 'conf' is a `Hash` that includes the configuration parameters.
32
+ # If the configuration is invalid, raise `Fluent::ConfigError`.
33
+ def configure(conf)
34
+ super
35
+ raise Fluent::ConfigError, 'Must define the vendor to use for getting the metrics.' if @target_platform == ''
36
+
37
+ raise Fluent::ConfigError, 'Must define the apikey to use for authentication.' if @apikey == ''
38
+
39
+ end
40
+
41
+ def process(tag, es)
42
+ es.each do |time, record|
43
+ if @target_platform == 'NEWRELIC'
44
+ vendor = NewRelicMetrics.new(@apikey)
45
+ vendor.send_metrics(record)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+ $newrelic_apikey = ''
3
+
4
+ def get_newrelic_credentials
5
+ $newrelic_apikey;;
6
+ 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,54 @@
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 = 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
+ puts platform_metrics.class
23
+ expect(platform_metrics.size).to be > 1
24
+
25
+ response = RestClient::Request.new(
26
+ method: :post,
27
+ url: "https://metric-api.newrelic.com/metric/v1",
28
+ payload: platform_metrics,
29
+ headers: {params: {'Api-Key' => newrelic_apikey, "Content-Type" => "application/json"}}
30
+ ).execute do |response, request, result|
31
+ puts response
32
+ expect(response.code).to eq(202)
33
+ expect(response.size).to be > 1
34
+ end
35
+ end
36
+
37
+ it 'should read sample Xray metrics data and verify the size of parsed data > 1' do
38
+ platform_metrics = File.read('./spec/fixtures/files/sample_xray_newrelic_metrics.txt')
39
+ expect(platform_metrics.size).to be > 1
40
+
41
+ response = RestClient::Request.new(
42
+ method: :post,
43
+ url: "https://metric-api.newrelic.com/metric/v1",
44
+ payload: platform_metrics,
45
+ headers: {params: {'Api-Key' => newrelic_apikey, "Content-Type" => "application/json"}}
46
+ ).execute do |response, request, result|
47
+ puts response
48
+ expect(response.code).to eq(202)
49
+ expect(response.size).to be > 1
50
+ end
51
+ end
52
+
53
+ end
54
+ 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,35 @@
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 ""
19
+ )
20
+
21
+ def create_driver(conf)
22
+ Fluent::Test::Driver::Output.new(Fluent::Plugin::JfrogSendMetricsOutput).configure(conf)
23
+ end
24
+
25
+ sub_test_case 'Testing' do
26
+ test 'Testing plugin jfrog_send_metrics' do
27
+ d = create_driver(CONFIG)
28
+ begin
29
+ d.run
30
+ rescue StandardError => e
31
+ raise "Test failed due to #{e}"
32
+ end
33
+ end
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-jfrog-send-metrics
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - MahithaB
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rest-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: fluentd
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 0.14.10
76
+ - - "<"
77
+ - !ruby/object:Gem::Version
78
+ version: '2'
79
+ type: :runtime
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 0.14.10
86
+ - - "<"
87
+ - !ruby/object:Gem::Version
88
+ version: '2'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rest-client
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '2.0'
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '2.0'
103
+ description: Fluentd Plugin for sending metrics to the respective log-vendor
104
+ email:
105
+ - 60710901+MahithaB@users.noreply.github.com
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - ".rspec"
111
+ - Gemfile
112
+ - LICENSE
113
+ - README.md
114
+ - Rakefile
115
+ - fluent-plugin-jfrog-send-metrics.gemspec
116
+ - lib/fluent/plugin/newrelic_metrics_sender.rb
117
+ - lib/fluent/plugin/out_jfrog_send_metrics.rb
118
+ - spec/fixtures/files/creds.rb
119
+ - spec/fixtures/files/sample_artifactory_newrelic_metrics.txt
120
+ - spec/fixtures/files/sample_xray_newrelic_metrics.txt
121
+ - spec/lib/newrelic_metrics_sender_spec.rb
122
+ - spec/spec_helper.rb
123
+ - test/helper.rb
124
+ - test/plugin/test_out_jfrog_send_metrics.rb
125
+ homepage: https://github.com/jfrog/jfrog-fluentd-plugins/tree/main/fluent-plugin-jfrog-send-metrics
126
+ licenses:
127
+ - Apache-2.0
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubygems_version: 3.0.3.1
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Fluentd Plugin for sending metrics to the respective log-vendor
148
+ test_files:
149
+ - spec/fixtures/files/creds.rb
150
+ - spec/fixtures/files/sample_artifactory_newrelic_metrics.txt
151
+ - spec/fixtures/files/sample_xray_newrelic_metrics.txt
152
+ - spec/lib/newrelic_metrics_sender_spec.rb
153
+ - spec/spec_helper.rb
154
+ - test/helper.rb
155
+ - test/plugin/test_out_jfrog_send_metrics.rb