fluent-plugin-jfrog-send-metrics 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- 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 +12 -9
- data/lib/fluent/plugin/utility.rb +14 -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: 898feff8ab8f4a975854370c16b2d400e16918afe77dbc09e76b930ea62a2c05
|
4
|
+
data.tar.gz: 98102867a939e246ba8a688c1afd65853dacb62f0e4df23970ecd0bb5387628a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efc92c68d8d5eac16199f54d129ad2786356c8b81a30236a7af5aaff559446e8239f9fb378506d4fa9f1d8b8997067f7b8fe2572ce70c6c4b564c7b0882b2265
|
7
|
+
data.tar.gz: 97dad1d675ccb149eaaf3a4d6232e51558221323245eb43acde64147451f056179490d178defd53d223557ce4e3521bc7de12f3a53b5be03c106ee38ed854c81
|
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.9"
|
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
|
@@ -40,33 +40,36 @@ module Fluent
|
|
40
40
|
def configure(conf)
|
41
41
|
super
|
42
42
|
|
43
|
-
raise Fluent::ConfigError, 'Must define the target_platform to be one of the following (DATADOG, NEWRELIC
|
43
|
+
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
44
|
|
45
45
|
raise Fluent::ConfigError, 'Must define the apikey to use for authentication.' if @apikey == ''
|
46
46
|
end
|
47
47
|
|
48
48
|
def process(tag, es)
|
49
|
+
logger = log
|
49
50
|
es.each do |time, record|
|
50
51
|
begin
|
52
|
+
logger.info("Sending metrics to target platform: #{@target_platform} started")
|
51
53
|
if @target_platform == 'NEWRELIC'
|
52
54
|
vendor = NewRelicMetrics.new(@apikey, @url)
|
53
|
-
vendor.send_metrics(record, @http_proxy, @verify_ssl, @request_timeout, @gzip_compression)
|
55
|
+
vendor.send_metrics(record, @http_proxy, @verify_ssl, @request_timeout, @gzip_compression, logger)
|
54
56
|
elsif @target_platform == 'DATADOG'
|
55
57
|
vendor = DatadogMetrics.new(@apikey, @url)
|
56
|
-
vendor.send_metrics(@ddtags, record, @http_proxy, @verify_ssl, @request_timeout, @gzip_compression)
|
58
|
+
vendor.send_metrics(@ddtags, record, @http_proxy, @verify_ssl, @request_timeout, @gzip_compression, logger)
|
57
59
|
end
|
60
|
+
logger.info("Sending metrics to target platform: #{@target_platform} finished")
|
58
61
|
rescue RestClient::Exceptions::OpenTimeout
|
59
|
-
|
62
|
+
logger.info("#{Utility.get_time} The request timed out while trying to open a connection. The configured request timeout is: #{@request_timeout}")
|
60
63
|
rescue RestClient::Exceptions::ReadTimeout
|
61
|
-
|
64
|
+
logger.info("#{Utility.get_time} The request timed out while waiting for a response. The configured request timeout is: #{@request_timeout}")
|
62
65
|
rescue RestClient::Exceptions::RequestTimeout
|
63
|
-
|
66
|
+
logger.info("#{Utility.get_time} The request timed out. The configured request timeout is: #{@request_timeout}")
|
64
67
|
rescue RestClient::ExceptionWithResponse => e
|
65
|
-
|
68
|
+
logger.info("#{Utility.get_time} HTTP request failed: #{e.response}")
|
66
69
|
rescue Net::HTTPClientException => e
|
67
|
-
|
70
|
+
logger.info("#{Utility.get_time} An HTTP client error occurred when sending metrics to #{@target_platform}: #{e.message}")
|
68
71
|
rescue StandardError => e
|
69
|
-
|
72
|
+
logger.info("#{Utility.get_time} An error occurred when sending metrics to #{@target_platform}: #{e.message}")
|
70
73
|
end
|
71
74
|
end
|
72
75
|
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,13 @@ class Utility
|
|
23
27
|
def self.get_time()
|
24
28
|
return Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
25
29
|
end
|
30
|
+
|
31
|
+
def self.enable_http_client_logs(http_client_logs)
|
32
|
+
if http_client_logs
|
33
|
+
RestClient.log = STDOUT
|
34
|
+
else
|
35
|
+
RestClient.log = nil
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
26
39
|
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.9
|
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
|