fluent-plugin-jfrog-send-metrics 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +15 -9
- data/README.md +7 -3
- data/fluent-plugin-jfrog-send-metrics.gemspec +4 -4
- data/lib/fluent/plugin/datadog_metrics_sender.rb +31 -6
- data/lib/fluent/plugin/newrelic_metrics_sender.rb +36 -12
- data/lib/fluent/plugin/out_jfrog_send_metrics.rb +3 -3
- data/test/plugin/test_out_jfrog_send_metrics.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c2bbb59536e88ef36eff1311469d0267502fda2055ccbb318998e2df934ce99
|
4
|
+
data.tar.gz: 8a0182402b0dc16a93abd622d678b0823e4e86d537f3a6fe1c25e8b0e6e74c83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa8f245c2ce2c67812610d0c4859646860813945beb5a3444bfb63f5e1d01d68dfef9e3e4b0b2aef7a493ab634dda0bf3f9262712aa61708263568f12fd1cecd
|
7
|
+
data.tar.gz: 21a5875ea3dcf360f99ae02a32949b36cd929342b6e6d8c1c8899d3fc2dbd5521e3152b7394c502a8cc4b4a177abf9e1046cffd2845930cbbd46f6cd707b38dd
|
data/Gemfile.lock
CHANGED
@@ -1,26 +1,32 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent-plugin-jfrog-send-metrics (0.1.
|
4
|
+
fluent-plugin-jfrog-send-metrics (0.1.6)
|
5
5
|
fluentd (>= 0.14.10, < 2)
|
6
|
-
rest-client (~> 2.0)
|
6
|
+
rest-client (~> 2.1.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
11
|
ansi (1.5.0)
|
12
|
+
base64 (0.2.0)
|
12
13
|
builder (3.2.4)
|
13
|
-
concurrent-ruby (1.
|
14
|
-
cool.io (1.
|
14
|
+
concurrent-ruby (1.3.4)
|
15
|
+
cool.io (1.8.1)
|
16
|
+
csv (3.3.0)
|
15
17
|
domain_name (0.5.20190701)
|
16
18
|
unf (>= 0.0.5, < 1.0.0)
|
17
|
-
|
19
|
+
drb (2.2.1)
|
20
|
+
fluentd (1.17.0)
|
21
|
+
base64 (~> 0.2)
|
18
22
|
bundler
|
19
23
|
cool.io (>= 1.4.5, < 2.0.0)
|
24
|
+
csv (~> 3.2)
|
25
|
+
drb (~> 2.2)
|
20
26
|
http_parser.rb (>= 0.5.1, < 0.9.0)
|
21
27
|
msgpack (>= 1.3.1, < 2.0.0)
|
22
28
|
serverengine (>= 2.3.2, < 3.0.0)
|
23
|
-
sigdump (~> 0.2.
|
29
|
+
sigdump (~> 0.2.5)
|
24
30
|
strptime (>= 0.2.4, < 1.0.0)
|
25
31
|
tzinfo (>= 1.0, < 3.0)
|
26
32
|
tzinfo-data (~> 1.0)
|
@@ -39,7 +45,7 @@ GEM
|
|
39
45
|
builder
|
40
46
|
minitest (>= 5.0)
|
41
47
|
ruby-progressbar
|
42
|
-
msgpack (1.7.
|
48
|
+
msgpack (1.7.2)
|
43
49
|
netrc (0.11.0)
|
44
50
|
power_assert (2.0.1)
|
45
51
|
rake (12.3.3)
|
@@ -51,13 +57,13 @@ GEM
|
|
51
57
|
ruby-progressbar (1.11.0)
|
52
58
|
serverengine (2.3.2)
|
53
59
|
sigdump (~> 0.2.2)
|
54
|
-
sigdump (0.2.
|
60
|
+
sigdump (0.2.5)
|
55
61
|
strptime (0.2.5)
|
56
62
|
test-unit (3.5.3)
|
57
63
|
power_assert
|
58
64
|
tzinfo (2.0.6)
|
59
65
|
concurrent-ruby (~> 1.0)
|
60
|
-
tzinfo-data (1.
|
66
|
+
tzinfo-data (1.2024.1)
|
61
67
|
tzinfo (>= 1.0.0)
|
62
68
|
unf (0.1.4)
|
63
69
|
unf_ext
|
data/README.md
CHANGED
@@ -64,20 +64,24 @@ Configure the match directive parameters as specified below
|
|
64
64
|
```
|
65
65
|
<match jfrog.metrics.**>
|
66
66
|
@type jfrog_send_metrics
|
67
|
-
target_platform "NEWRELIC"
|
67
|
+
target_platform "NEWRELIC" # or "DATADOG"
|
68
68
|
apikey <api_key>
|
69
|
+
url https://metric-api.newrelic.com/metric/v1 # or DataDog's metrics URL
|
70
|
+
http_proxy <proxy_url>
|
69
71
|
</match>
|
70
|
-
|
71
72
|
```
|
73
|
+
|
72
74
|
#### Configuration parameters
|
73
75
|
|
74
76
|
Obtain respective authentication credentials for log-vendors
|
75
77
|
|
76
78
|
* **target_platform**(string)(required): The target log-vendor ("NEWRELIC" or "DATADOG")
|
77
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)
|
78
82
|
|
79
83
|
## Copyright
|
80
84
|
|
81
|
-
* Copyright(c)
|
85
|
+
* Copyright(c) 2024- MahithaB, BenH
|
82
86
|
* License
|
83
87
|
* Apache License, Version 2.0
|
@@ -3,9 +3,9 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "fluent-plugin-jfrog-send-metrics"
|
6
|
-
spec.version = "0.1.
|
7
|
-
spec.authors = ["MahithaB"]
|
8
|
-
spec.email = ["
|
6
|
+
spec.version = "0.1.6"
|
7
|
+
spec.authors = ["MahithaB", "BenH"]
|
8
|
+
spec.email = ["partner_support@jfrog.com"]
|
9
9
|
|
10
10
|
spec.summary = %q{Fluentd Plugin for sending metrics to the respective log-vendor}
|
11
11
|
spec.description = %q{Fluentd Plugin for sending metrics to the respective log-vendor}
|
@@ -25,5 +25,5 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "test-unit", "~> 3.0"
|
26
26
|
spec.add_development_dependency "rest-client", "~> 2.0"
|
27
27
|
spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
|
28
|
-
spec.add_runtime_dependency "rest-client", "~> 2.0"
|
28
|
+
spec.add_runtime_dependency "rest-client", "~> 2.1.0"
|
29
29
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'json'
|
3
3
|
require 'rest-client'
|
4
|
+
require 'uri'
|
4
5
|
|
5
6
|
class DatadogMetrics
|
6
7
|
def initialize(apikey, url)
|
@@ -23,22 +24,46 @@ class DatadogMetrics
|
|
23
24
|
return record
|
24
25
|
end
|
25
26
|
|
26
|
-
def send_metrics(ddtags, record)
|
27
|
+
def send_metrics(ddtags, record, http_proxy)
|
27
28
|
puts "Additional tags to be added to metrics are", ddtags
|
28
29
|
metrics_data = add_custom_data(ddtags, record)
|
29
30
|
puts "Sending received metrics data"
|
31
|
+
|
32
|
+
if http_proxy
|
33
|
+
RestClient.proxy = URI.parse(http_proxy)
|
34
|
+
puts "Using http_proxy param to set proxy for request. Proxy url: #{RestClient.proxy}"
|
35
|
+
elsif ENV['HTTP_PROXY']
|
36
|
+
RestClient.proxy = ENV['HTTP_PROXY']
|
37
|
+
puts "Using 'HTTP_PROXY' environment variable to set proxy for request. Proxy url: #{RestClient.proxy}"
|
38
|
+
elsif ENV['http_proxy']
|
39
|
+
RestClient.proxy = ENV['http_proxy']
|
40
|
+
puts "Using 'http_proxy' environment variable to set proxy for request. Proxy url: #{RestClient.proxy}"
|
41
|
+
elsif ENV['https_proxy']
|
42
|
+
RestClient.proxy = ENV['https_proxy']
|
43
|
+
puts "Using 'https_proxy' environment variable to set proxy for request. Proxy url: #{RestClient.proxy}"
|
44
|
+
end
|
45
|
+
|
46
|
+
begin
|
30
47
|
response = RestClient::Request.new(
|
31
48
|
method: :post,
|
32
49
|
url: @url,
|
33
50
|
payload: metrics_data.to_json,
|
34
51
|
headers: {'DD-API-KEY': @apikey, content_type: :json }
|
35
52
|
).execute do |response, request, result|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
53
|
+
case response.code
|
54
|
+
when 202
|
55
|
+
puts 'Metrics were successfully sent to DataDog'
|
56
|
+
return response.body
|
57
|
+
else
|
58
|
+
puts "Cannot send metrics to DataDog url: %s. Received response code: %d, Response body: %s" % [@url, response.code, response.body]
|
59
|
+
end
|
41
60
|
end
|
61
|
+
rescue Net::HTTPClientException => e
|
62
|
+
# Handle the HTTP client exception
|
63
|
+
puts "An HTTP client error occurred when sending metrics to DataDog: #{e.message}"
|
64
|
+
rescue StandardError => e
|
65
|
+
# Handle any other exceptions
|
66
|
+
puts "An error occurred when sending metrics to DataDog: #{e.message}"
|
42
67
|
end
|
43
68
|
end
|
44
69
|
end
|
@@ -8,22 +8,46 @@ class NewRelicMetrics
|
|
8
8
|
@url = url
|
9
9
|
end
|
10
10
|
|
11
|
-
def send_metrics(metrics_data)
|
11
|
+
def send_metrics(metrics_data, http_proxy)
|
12
12
|
puts "Sending received metrics data"
|
13
13
|
metrics_payload = []
|
14
14
|
metrics_payload.push(JSON.parse(metrics_data.to_json))
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
|
16
|
+
if http_proxy
|
17
|
+
RestClient.proxy = URI.parse(http_proxy)
|
18
|
+
puts "Using http_proxy param to set proxy for request. Proxy url: #{RestClient.proxy}"
|
19
|
+
elsif ENV['HTTP_PROXY']
|
20
|
+
RestClient.proxy = ENV['HTTP_PROXY']
|
21
|
+
puts "Using 'HTTP_PROXY' environment variable to set proxy for request. Proxy url: #{RestClient.proxy}"
|
22
|
+
elsif ENV['http_proxy']
|
23
|
+
RestClient.proxy = ENV['http_proxy']
|
24
|
+
puts "Using 'http_proxy' environment variable to set proxy for request. Proxy url: #{RestClient.proxy}"
|
25
|
+
elsif ENV['https_proxy']
|
26
|
+
RestClient.proxy = ENV['https_proxy']
|
27
|
+
puts "Using 'https_proxy' environment variable to set proxy for request. Proxy url: #{RestClient.proxy}"
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
response = RestClient::Request.new(
|
32
|
+
method: :post,
|
33
|
+
url: @url,
|
34
|
+
payload: metrics_payload.to_json,
|
35
|
+
headers: {params: {'Api-Key' => @apikey}}
|
36
|
+
).execute do |response, request, result|
|
37
|
+
case response.code
|
38
|
+
when 202
|
39
|
+
puts 'Metrics were successfully sent to NewRelic'
|
40
|
+
return response.body
|
41
|
+
else
|
42
|
+
puts "Cannot send metrics to NewRelic url: %s. Received response code: %d" % [@url, response&.code]
|
43
|
+
end
|
26
44
|
end
|
45
|
+
rescue Net::HTTPClientException => e
|
46
|
+
# Handle the HTTP client exception
|
47
|
+
puts "An HTTP client error occurred when sending metrics to NewRelic: #{e.message}"
|
48
|
+
rescue StandardError => e
|
49
|
+
# Handle any other exceptions
|
50
|
+
puts "An error occurred when sending metrics to NewRelic: #{e.message}"
|
27
51
|
end
|
28
52
|
end
|
29
53
|
end
|
@@ -29,6 +29,7 @@ module Fluent
|
|
29
29
|
config_param :apikey, :string, default: ''
|
30
30
|
config_param :url, :string, default: 'https://metric-api.newrelic.com/metric/v1'
|
31
31
|
config_param :ddtags, :array, default: []
|
32
|
+
config_param :http_proxy, :string, :default => nil
|
32
33
|
|
33
34
|
# `configure` is called before `start`.
|
34
35
|
# 'conf' is a `Hash` that includes the configuration parameters.
|
@@ -38,17 +39,16 @@ module Fluent
|
|
38
39
|
raise Fluent::ConfigError, 'Must define the vendor to use for getting the metrics.' if @target_platform == ''
|
39
40
|
|
40
41
|
raise Fluent::ConfigError, 'Must define the apikey to use for authentication.' if @apikey == ''
|
41
|
-
|
42
42
|
end
|
43
43
|
|
44
44
|
def process(tag, es)
|
45
45
|
es.each do |time, record|
|
46
46
|
if @target_platform == 'NEWRELIC'
|
47
47
|
vendor = NewRelicMetrics.new(@apikey, @url)
|
48
|
-
vendor.send_metrics(record)
|
48
|
+
vendor.send_metrics(record, @http_proxy)
|
49
49
|
elsif @target_platform == 'DATADOG'
|
50
50
|
vendor = DatadogMetrics.new(@apikey, @url)
|
51
|
-
vendor.send_metrics(@ddtags, record)
|
51
|
+
vendor.send_metrics(@ddtags, record, @http_proxy)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-jfrog-send-metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MahithaB
|
8
|
+
- BenH
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2024-
|
12
|
+
date: 2024-08-20 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
@@ -92,17 +93,17 @@ dependencies:
|
|
92
93
|
requirements:
|
93
94
|
- - "~>"
|
94
95
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
96
|
+
version: 2.1.0
|
96
97
|
type: :runtime
|
97
98
|
prerelease: false
|
98
99
|
version_requirements: !ruby/object:Gem::Requirement
|
99
100
|
requirements:
|
100
101
|
- - "~>"
|
101
102
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
103
|
+
version: 2.1.0
|
103
104
|
description: Fluentd Plugin for sending metrics to the respective log-vendor
|
104
105
|
email:
|
105
|
-
-
|
106
|
+
- partner_support@jfrog.com
|
106
107
|
executables: []
|
107
108
|
extensions: []
|
108
109
|
extra_rdoc_files: []
|
@@ -143,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
144
|
- !ruby/object:Gem::Version
|
144
145
|
version: '0'
|
145
146
|
requirements: []
|
146
|
-
rubygems_version: 3.
|
147
|
+
rubygems_version: 3.5.3
|
147
148
|
signing_key:
|
148
149
|
specification_version: 4
|
149
150
|
summary: Fluentd Plugin for sending metrics to the respective log-vendor
|