fluent-plugin-jfrog-metrics-deepakk 0.2.14

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.
@@ -0,0 +1,39 @@
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 'metrics_helper'
11
+ require 'date'
12
+ require 'rspec'
13
+ require 'rest-client'
14
+ require './spec/fixtures/files/creds'
15
+
16
+
17
+ RSpec.describe MetricsHelper do
18
+ jpd_url, username, apikey, token = get_credentials
19
+ describe '#get_metrics' do
20
+ it 'should return response code 200 and response body > 1' do
21
+ response = RestClient::Request.new(
22
+ method: :get,
23
+ url: "#{jpd_url}/artifactory/api/v1/metrics",
24
+ user: username.to_s,
25
+ password: apikey.to_s
26
+ ).execute do |response, request, result|
27
+ expect(response.code).to eq(200)
28
+ expect(response.size).to be > 1
29
+ end
30
+ end
31
+
32
+ it 'should return response code 200 and response body > 1' do
33
+ helper = MetricsHelper.new('jfrog.artifactory', jpd_url, username, apikey, token)
34
+ url = "#{jpd_url}/observability/api/v1/metrics"
35
+ helper.check_endpoint(url, token)
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,55 @@
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_parser'
11
+ require 'date'
12
+ require 'rspec'
13
+
14
+
15
+ RSpec.describe NewRelicMetricsParser do
16
+ describe "#emit_parsed_metrics" do
17
+ it 'should read sample Artifactory metrics data and verify the size of parsed data > 1' do
18
+ platform_metrics = File.read('./spec/fixtures/files/sample_artifactory_metrics.txt')
19
+ expect(platform_metrics.size).to be > 1
20
+
21
+ parser = NewRelicMetricsParser.new('jfrog.artifactory', '', 'jfrog.artifactory.metrics')
22
+
23
+ normalized_data = parser.normalise_data(platform_metrics)
24
+ expect(normalized_data.size).to be > 1
25
+
26
+ cleaned_data = parser.clean_data(normalized_data)
27
+ expect(cleaned_data.size).to be > 1
28
+
29
+ hash_data_array = parser.format_data(cleaned_data, 'jfrog.artifactory', '.')
30
+ expect(hash_data_array.size).to be 1
31
+
32
+ serialized_data = parser.serialize_data(hash_data_array)
33
+ expect(serialized_data.size).to be 1
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_metrics.txt')
38
+ expect(platform_metrics.size).to be > 1
39
+
40
+ parser = NewRelicMetricsParser.new('jfrog.xray', '', 'jfrog.xray.metrics')
41
+
42
+ normalized_data = parser.normalise_data(platform_metrics)
43
+ expect(normalized_data.size).to be > 1
44
+
45
+ cleaned_data = parser.clean_data(normalized_data)
46
+ expect(cleaned_data.size).to be > 1
47
+
48
+ hash_data_array = parser.format_data(cleaned_data, 'jfrog.xray', '.')
49
+ expect(hash_data_array.size).to be 1
50
+
51
+ serialized_data = parser.serialize_data(hash_data_array)
52
+ expect(serialized_data.size).to be 1
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,55 @@
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 'splunk_metrics_parser'
11
+ require 'date'
12
+ require 'rspec'
13
+
14
+
15
+ RSpec.describe SplunkMetricsParser do
16
+ describe "#emit_parsed_metrics" do
17
+ it 'should read sample Artifactory metrics data and verify the size of parsed data > 1' do
18
+ platform_metrics = File.read('./spec/fixtures/files/sample_artifactory_metrics.txt')
19
+ expect(platform_metrics.size).to be > 1
20
+
21
+ parser = SplunkMetricsParser.new('jfrog.artifactory', '', 'jfrog.artifactory.metrics')
22
+
23
+ normalized_data = parser.normalise_data(platform_metrics)
24
+ expect(normalized_data.size).to be > 1
25
+
26
+ cleaned_data = parser.clean_data(normalized_data)
27
+ expect(cleaned_data.size).to be > 1
28
+
29
+ hash_data_array = parser.format_data(cleaned_data, 'jfrog.artifactory', '.')
30
+ expect(hash_data_array.size).to be > 1
31
+
32
+ serialized_data = parser.serialize_data(hash_data_array)
33
+ expect(serialized_data.size).to be > 1
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_metrics.txt')
38
+ expect(platform_metrics.size).to be > 1
39
+
40
+ parser = SplunkMetricsParser.new('jfrog.xray', '', 'jfrog.xray.metrics')
41
+
42
+ normalized_data = parser.normalise_data(platform_metrics)
43
+ expect(normalized_data.size).to be > 1
44
+
45
+ cleaned_data = parser.clean_data(normalized_data)
46
+ expect(cleaned_data.size).to be > 1
47
+
48
+ hash_data_array = parser.format_data(cleaned_data, 'jfrog.xray', '.')
49
+ expect(hash_data_array.size).to be > 1
50
+
51
+ serialized_data = parser.serialize_data(hash_data_array)
52
+ expect(serialized_data.size).to be > 1
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,113 @@
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 'metrics_helper'
26
+ require 'splunk_metrics_parser'
27
+ require 'newrelic_metrics_parser'
28
+
29
+ RSpec.configure do |config|
30
+ # rspec-expectations config goes here. You can use an alternate
31
+ # assertion/expectation library such as wrong or the stdlib/minitest
32
+ # assertions if you prefer.
33
+ config.expect_with :rspec do |expectations|
34
+ # This option will default to `true` in RSpec 4. It makes the `description`
35
+ # and `failure_message` of custom matchers include text for helper methods
36
+ # defined using `chain`, e.g.:
37
+ # be_bigger_than(2).and_smaller_than(4).description
38
+ # # => "be bigger than 2 and smaller than 4"
39
+ # ...rather than:
40
+ # # => "be bigger than 2"
41
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
42
+ end
43
+
44
+ # rspec-mocks config goes here. You can use an alternate test double
45
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
46
+ config.mock_with :rspec do |mocks|
47
+ # Prevents you from mocking or stubbing a method that does not exist on
48
+ # a real object. This is generally recommended, and will default to
49
+ # `true` in RSpec 4.
50
+ mocks.verify_partial_doubles = true
51
+ end
52
+
53
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
54
+ # have no way to turn it off -- the option exists only for backwards
55
+ # compatibility in RSpec 3). It causes shared context metadata to be
56
+ # inherited by the metadata hash of host groups and examples, rather than
57
+ # triggering implicit auto-inclusion in groups with matching metadata.
58
+ config.shared_context_metadata_behavior = :apply_to_host_groups
59
+
60
+ # The settings below are suggested to provide a good initial experience
61
+ # with RSpec, but feel free to customize to your heart's content.
62
+ =begin
63
+ # This allows you to limit a spec run to individual examples or groups
64
+ # you care about by tagging them with `:focus` metadata. When nothing
65
+ # is tagged with `:focus`, all examples get run. RSpec also provides
66
+ # aliases for `it`, `describe`, and `context` that include `:focus`
67
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
68
+ config.filter_run_when_matching :focus
69
+
70
+ # Allows RSpec to persist some state between runs in order to support
71
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
72
+ # you configure your source control system to ignore this file.
73
+ config.example_status_persistence_file_path = "spec/examples.txt"
74
+
75
+ # Limits the available syntax to the non-monkey patched syntax that is
76
+ # recommended. For more details, see:
77
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
78
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
79
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
80
+ config.disable_monkey_patching!
81
+
82
+ # This setting enables warnings. It's recommended, but in some cases may
83
+ # be too noisy due to issues in dependencies.
84
+ config.warnings = true
85
+
86
+ # Many RSpec users commonly either run the entire suite or an individual
87
+ # file, and it's useful to allow more verbose output when running an
88
+ # individual spec file.
89
+ if config.files_to_run.one?
90
+ # Use the documentation formatter for detailed output,
91
+ # unless a formatter has already been configured
92
+ # (e.g. via a command-line flag).
93
+ config.default_formatter = "doc"
94
+ end
95
+
96
+ # Print the 10 slowest examples and example groups at the
97
+ # end of the spec run, to help surface which specs are running
98
+ # particularly slow.
99
+ config.profile_examples = 10
100
+
101
+ # Run specs in random order to surface order dependencies. If you find an
102
+ # order dependency and want to debug it, you can fix the order by providing
103
+ # the seed, which is printed after each run.
104
+ # --seed 1234
105
+ config.order = :random
106
+
107
+ # Seed global randomization in this process using the `--seed` CLI option.
108
+ # Setting this allows you to use `--seed` to deterministically reproduce
109
+ # test failures related to randomization by passing the same `--seed` value
110
+ # as the one that triggered the failure.
111
+ Kernel.srand config.seed
112
+ =end
113
+ 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/input"
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,39 @@
1
+ # frozen_string_literal: true
2
+ require_relative '../helper'
3
+ require 'fluent/plugin/in_jfrog_metrics'
4
+
5
+ class JfrogMetricsInputTest < Test::Unit::TestCase
6
+ setup do
7
+ Fluent::Test.setup
8
+ end
9
+
10
+ test 'failure' do
11
+ #flunk
12
+ end
13
+
14
+ # Default configuration for tests
15
+ CONFIG = %(
16
+ tag "jfrog.artifactory.metrics"
17
+ jpd_url "http://localhost:8081"
18
+ username "admin"
19
+ apikey "AKCp8k8PbyomdfXsVzoQWaYQZmq9wk49JXQLaP1wXJpa6LdzpFkuJ4VcWd61U6fYWwDJymLDR"
20
+ metric_prefix "jfrog.artifactory"
21
+ )
22
+
23
+ private
24
+
25
+ def create_driver(conf)
26
+ Fluent::Test::Driver::Input.new(Fluent::Plugin::JfrogMetricsInput).configure(conf)
27
+ end
28
+
29
+ sub_test_case 'Testing' do
30
+ test 'Testing plugin in_jfrog_metrics' do
31
+ d = create_driver(CONFIG)
32
+ begin
33
+ d.run
34
+ rescue StandardError => e
35
+ raise "Test failed due to #{e}"
36
+ end
37
+ end
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-jfrog-metrics-deepakk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.14
5
+ platform: ruby
6
+ authors:
7
+ - MahithaB, BenHarosh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-01-08 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.1.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.1.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.1.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.1.0
103
+ description: Fluentd Plugin for converting JFrog Artifactory, Xray generated metrics
104
+ (Prometheus Exposition Format) to target observability platform format (Splunk HEC,
105
+ New Relic, DataDog)
106
+ email:
107
+ - cpe-support@jfrog.com
108
+ executables: []
109
+ extensions: []
110
+ extra_rdoc_files: []
111
+ files:
112
+ - ".gitignore"
113
+ - ".rspec"
114
+ - Gemfile
115
+ - Gemfile.lock
116
+ - LICENSE
117
+ - README.md
118
+ - Rakefile
119
+ - fluent-plugin-jfrog-metrics.gemspec
120
+ - lib/fluent/plugin/base_metrics_parser.rb
121
+ - lib/fluent/plugin/datadog_metrics_parser.rb
122
+ - lib/fluent/plugin/in_jfrog_metrics.rb
123
+ - lib/fluent/plugin/metrics_helper.rb
124
+ - lib/fluent/plugin/newrelic_metrics_parser.rb
125
+ - lib/fluent/plugin/proxy_helper.rb
126
+ - lib/fluent/plugin/splunk_metrics_parser.rb
127
+ - spec/fixtures/files/creds.rb
128
+ - spec/fixtures/files/sample_artifactory_metrics.txt
129
+ - spec/fixtures/files/sample_xray_metrics.txt
130
+ - spec/lib/metrics_helper_spec.rb
131
+ - spec/lib/newrelic_metrics_parser_spec.rb
132
+ - spec/lib/splunk_metrics_parser_spec.rb
133
+ - spec/spec_helper.rb
134
+ - test/helper.rb
135
+ - test/plugin/test_in_jfrog_metrics.rb
136
+ homepage: https://github.com/jfrog/jfrog-fluentd-plugins/tree/main/fluent-plugin-jfrog-metrics
137
+ licenses:
138
+ - Apache-2.0
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubygems_version: 3.0.3.1
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: Fluentd Plugin for converting JFrog Artifactory, Xray generated metrics (Prometheus
159
+ Exposition Format) to target observability platform format (Splunk HEC, New Relic,
160
+ DataDog)
161
+ test_files:
162
+ - spec/fixtures/files/creds.rb
163
+ - spec/fixtures/files/sample_artifactory_metrics.txt
164
+ - spec/fixtures/files/sample_xray_metrics.txt
165
+ - spec/lib/metrics_helper_spec.rb
166
+ - spec/lib/newrelic_metrics_parser_spec.rb
167
+ - spec/lib/splunk_metrics_parser_spec.rb
168
+ - spec/spec_helper.rb
169
+ - test/helper.rb
170
+ - test/plugin/test_in_jfrog_metrics.rb