fluent-plugin-jfrog-send-metrics 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/fluent-plugin-jfrog-send-metrics.gemspec +1 -1
- data/lib/fluent/plugin/datadog_metrics_sender.rb +13 -12
- data/lib/fluent/plugin/newrelic_metrics_sender.rb +13 -11
- data/lib/fluent/plugin/out_jfrog_send_metrics.rb +13 -9
- data/lib/fluent/plugin/utility.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dba18a765b27f3db29659ae09f1a1ef75b070c67cbe7a29592377da5356d71f8
|
4
|
+
data.tar.gz: 2d2da3f01f7ea0edd77a401326514cc564489d7b879d7d54c9044f00300cb29b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b7e3f13368de75df746fc76270933ff705284b9eb6b77eaf4a7ad62a3fb50acbfc0309638cbb4798610202aba38d0bc12cd97f6221bc164668952b8f00594ae
|
7
|
+
data.tar.gz: 4d0c1a771da41f45fc8924ca9e25caf94d081ea0080c3611151f4c425a792846af9ec1c8a8bd329ee4cf5caf1ae42f5bc67d90a257cf32f6ea274c72ff7b8bec
|
data/Gemfile.lock
CHANGED
@@ -3,7 +3,7 @@ $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.
|
6
|
+
spec.version = "0.1.10"
|
7
7
|
spec.authors = ["MahithaB", "BenH"]
|
8
8
|
spec.email = ["partner_support@jfrog.com"]
|
9
9
|
|
@@ -26,24 +26,24 @@ class DatadogMetrics
|
|
26
26
|
return record
|
27
27
|
end
|
28
28
|
|
29
|
-
def send_metrics(ddtags, record, http_proxy, verify_ssl, request_timeout, gzip_compression)
|
29
|
+
def send_metrics(ddtags, record, http_proxy, verify_ssl, request_timeout, gzip_compression, logger)
|
30
30
|
# Get the current local timestamp
|
31
|
-
|
31
|
+
logger.info("#{Utility.get_time} Additional tags to be added to metrics are:", ddtags)
|
32
32
|
metrics_data = add_custom_data(ddtags, record)
|
33
|
-
|
33
|
+
logger.info("#{Utility.get_time} Sending received metrics data")
|
34
34
|
|
35
35
|
if http_proxy
|
36
36
|
RestClient.proxy = URI.parse(http_proxy)
|
37
|
-
|
37
|
+
logger.info("#{Utility.get_time} Using http_proxy param to set proxy for request. Proxy url: #{RestClient.proxy}")
|
38
38
|
elsif ENV['HTTP_PROXY']
|
39
39
|
RestClient.proxy = ENV['HTTP_PROXY']
|
40
|
-
|
40
|
+
logger.info("#{Utility.get_time} Using 'HTTP_PROXY' environment variable to set proxy for request. Proxy url: #{RestClient.proxy}")
|
41
41
|
elsif ENV['http_proxy']
|
42
42
|
RestClient.proxy = ENV['http_proxy']
|
43
|
-
|
43
|
+
logger.info("#{Utility.get_time} Using 'http_proxy' environment variable to set proxy for request. Proxy url: #{RestClient.proxy}")
|
44
44
|
elsif ENV['https_proxy']
|
45
45
|
RestClient.proxy = ENV['https_proxy']
|
46
|
-
|
46
|
+
logger.info("#{Utility.get_time} Using 'https_proxy' environment variable to set proxy for request. Proxy url: #{RestClient.proxy}")
|
47
47
|
end
|
48
48
|
|
49
49
|
headers = {
|
@@ -57,23 +57,24 @@ class DatadogMetrics
|
|
57
57
|
headers[:'Content-Encoding'] = 'gzip'
|
58
58
|
end
|
59
59
|
|
60
|
-
|
60
|
+
request = RestClient::Request.new(
|
61
61
|
method: :post,
|
62
62
|
url: @url,
|
63
63
|
payload: payload,
|
64
64
|
headers: headers,
|
65
65
|
verify_ssl: verify_ssl,
|
66
66
|
timeout: request_timeout
|
67
|
-
)
|
67
|
+
)
|
68
|
+
|
69
|
+
request.execute do |response, request, result|
|
68
70
|
case response.code
|
69
71
|
when 202
|
70
|
-
|
72
|
+
logger.info("#{Utility.get_time} Metrics were successfully sent to DataDog")
|
71
73
|
return response.body
|
72
74
|
else
|
73
|
-
|
75
|
+
logger.info("#{Utility.get_time} Cannot send metrics to DataDog url: %s. Received response code: %d, Response body: %s" % [@url, response.code, response.body])
|
74
76
|
end
|
75
77
|
end
|
76
78
|
end
|
77
|
-
|
78
79
|
end
|
79
80
|
|
@@ -10,23 +10,23 @@ class NewRelicMetrics
|
|
10
10
|
@url = url
|
11
11
|
end
|
12
12
|
|
13
|
-
def send_metrics(metrics_data, http_proxy, verify_ssl, request_timeout, gzip_compression)
|
14
|
-
|
13
|
+
def send_metrics(metrics_data, http_proxy, verify_ssl, request_timeout, gzip_compression, logger)
|
14
|
+
logger.info("#{Utility.get_time} Sending received metrics data")
|
15
15
|
metrics_payload = []
|
16
16
|
metrics_payload.push(JSON.parse(metrics_data.to_json))
|
17
17
|
|
18
18
|
if http_proxy
|
19
19
|
RestClient.proxy = URI.parse(http_proxy)
|
20
|
-
|
20
|
+
logger.info("#{Utility.get_time} Using http_proxy param to set proxy for request. Proxy url: #{RestClient.proxy}")
|
21
21
|
elsif ENV['HTTP_PROXY']
|
22
22
|
RestClient.proxy = ENV['HTTP_PROXY']
|
23
|
-
|
23
|
+
logger.info("#{Utility.get_time} Using 'HTTP_PROXY' environment variable to set proxy for request. Proxy url: #{RestClient.proxy}")
|
24
24
|
elsif ENV['http_proxy']
|
25
25
|
RestClient.proxy = ENV['http_proxy']
|
26
|
-
|
26
|
+
logger.info("#{Utility.get_time} Using 'http_proxy' environment variable to set proxy for request. Proxy url: #{RestClient.proxy}")
|
27
27
|
elsif ENV['https_proxy']
|
28
28
|
RestClient.proxy = ENV['https_proxy']
|
29
|
-
|
29
|
+
logger.info("#{Utility.get_time} Using 'https_proxy' environment variable to set proxy for request. Proxy url: #{RestClient.proxy}")
|
30
30
|
end
|
31
31
|
|
32
32
|
headers = {
|
@@ -37,21 +37,23 @@ class NewRelicMetrics
|
|
37
37
|
payload = Utility.compress_payload(metrics_payload)
|
38
38
|
headers[:'Content-Encoding'] = 'gzip'
|
39
39
|
end
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
request = RestClient::Request.new(
|
42
42
|
method: :post,
|
43
43
|
url: @url,
|
44
44
|
payload: payload,
|
45
45
|
headers: headers,
|
46
46
|
verify_ssl: verify_ssl,
|
47
47
|
timeout: request_timeout
|
48
|
-
)
|
48
|
+
)
|
49
|
+
|
50
|
+
request.execute do |response, request, result|
|
49
51
|
case response.code
|
50
52
|
when 202
|
51
|
-
|
53
|
+
logger.info("#{Utility.get_time} Metrics were successfully sent to NewRelic")
|
52
54
|
return response.body
|
53
55
|
else
|
54
|
-
|
56
|
+
logger.info("#{Utility.get_time} Cannot send metrics to NewRelic url: %s. Received response code: %d, Response body: %s" % [@url, response.code, response.body])
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
@@ -14,6 +14,7 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
|
16
16
|
require "fluent/plugin/output"
|
17
|
+
require 'rest-client'
|
17
18
|
require_relative 'newrelic_metrics_sender'
|
18
19
|
require_relative 'datadog_metrics_sender'
|
19
20
|
|
@@ -40,33 +41,36 @@ module Fluent
|
|
40
41
|
def configure(conf)
|
41
42
|
super
|
42
43
|
|
43
|
-
raise Fluent::ConfigError, 'Must define the target_platform to be one of the following (DATADOG, NEWRELIC
|
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))
|
44
45
|
|
45
46
|
raise Fluent::ConfigError, 'Must define the apikey to use for authentication.' if @apikey == ''
|
46
47
|
end
|
47
48
|
|
48
49
|
def process(tag, es)
|
50
|
+
logger = log
|
49
51
|
es.each do |time, record|
|
50
52
|
begin
|
53
|
+
logger.info("Sending metrics to target platform: #{@target_platform} started")
|
51
54
|
if @target_platform == 'NEWRELIC'
|
52
55
|
vendor = NewRelicMetrics.new(@apikey, @url)
|
53
|
-
vendor.send_metrics(record, @http_proxy, @verify_ssl, @request_timeout, @gzip_compression)
|
56
|
+
vendor.send_metrics(record, @http_proxy, @verify_ssl, @request_timeout, @gzip_compression, logger)
|
54
57
|
elsif @target_platform == 'DATADOG'
|
55
58
|
vendor = DatadogMetrics.new(@apikey, @url)
|
56
|
-
vendor.send_metrics(@ddtags, record, @http_proxy, @verify_ssl, @request_timeout, @gzip_compression)
|
59
|
+
vendor.send_metrics(@ddtags, record, @http_proxy, @verify_ssl, @request_timeout, @gzip_compression, logger)
|
57
60
|
end
|
61
|
+
logger.info("Sending metrics to target platform: #{@target_platform} finished")
|
58
62
|
rescue RestClient::Exceptions::OpenTimeout
|
59
|
-
|
63
|
+
logger.info("#{Utility.get_time} The request timed out while trying to open a connection. The configured request timeout is: #{@request_timeout}")
|
60
64
|
rescue RestClient::Exceptions::ReadTimeout
|
61
|
-
|
65
|
+
logger.info("#{Utility.get_time} The request timed out while waiting for a response. The configured request timeout is: #{@request_timeout}")
|
62
66
|
rescue RestClient::Exceptions::RequestTimeout
|
63
|
-
|
67
|
+
logger.info("#{Utility.get_time} The request timed out. The configured request timeout is: #{@request_timeout}")
|
64
68
|
rescue RestClient::ExceptionWithResponse => e
|
65
|
-
|
69
|
+
logger.info("#{Utility.get_time} HTTP request failed: #{e.response}")
|
66
70
|
rescue Net::HTTPClientException => e
|
67
|
-
|
71
|
+
logger.info("#{Utility.get_time} An HTTP client error occurred when sending metrics to #{@target_platform}: #{e.message}")
|
68
72
|
rescue StandardError => e
|
69
|
-
|
73
|
+
logger.info("#{Utility.get_time} An error occurred when sending metrics to #{@target_platform}: #{e.message}")
|
70
74
|
end
|
71
75
|
end
|
72
76
|
end
|
@@ -8,7 +8,11 @@ class Utility
|
|
8
8
|
# Compress the JSON string using zlib's GzipWriter
|
9
9
|
compressed_payload = StringIO.new
|
10
10
|
Zlib::GzipWriter.wrap(compressed_payload) do |gz|
|
11
|
-
|
11
|
+
begin
|
12
|
+
gz.write(json_payload)
|
13
|
+
ensure
|
14
|
+
gz.close
|
15
|
+
end
|
12
16
|
end
|
13
17
|
|
14
18
|
# convert the compressed data to a string
|
@@ -23,4 +27,5 @@ class Utility
|
|
23
27
|
def self.get_time()
|
24
28
|
return Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
25
29
|
end
|
30
|
+
|
26
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MahithaB
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|