logstash-output-azure_service_bus 0.3.3 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logstash/outputs/azure_service_bus.rb +15 -11
- data/logstash-output-azure_service_bus.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 471a18d0fdea0bf6c21bdd48db014c8d30cb479c2b5200eac4f831d13b1d4038
|
4
|
+
data.tar.gz: 06aa88159a5f0966c47dfee28876fe380c3f19d6858a1f14190a71584b366641
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec4141fb080e65c35e2db12c59725cab3f62bfe78baac6fa7eb1ab4fb7e303fe48f40657bf82911e32af017e5e34fc472d0ab0be9efc3c9442d65820a515a2e8
|
7
|
+
data.tar.gz: 7db1ae28aaf1628f2ea39e048fc2e564eabcbc554006af062dbe0dc5cb9394ac5068dce209265506dd6f7ab4f7b9c8bdcbb7dda50af304b9562912dfd4c8c433
|
@@ -18,18 +18,21 @@ class LogStash::Outputs::AzureServiceBus < LogStash::Outputs::Base
|
|
18
18
|
interval: 1,
|
19
19
|
interval_randomness: 0.5,
|
20
20
|
backoff_factor: 2,
|
21
|
-
exceptions: [Faraday::ConnectionFailed, Faraday::TimeoutError, Faraday::RetriableResponse,
|
21
|
+
exceptions: [Faraday::ConnectionFailed, Faraday::TimeoutError, Faraday::RetriableResponse, Faraday::SSLError],
|
22
22
|
methods: [], # Empty -> all methods
|
23
23
|
retry_statuses: [401, 403, 404, 410, 429, 500], # https://docs.microsoft.com/en-us/rest/api/servicebus/send-message-batch#response-codes
|
24
24
|
retry_block: lambda do |env, _options, _retries, exception|
|
25
25
|
if env.status.nil?
|
26
|
-
@logger.warn("Problem (
|
26
|
+
@logger.warn("Problem while sending message(s) to Service Bus: #{exception.inspect}")
|
27
27
|
else
|
28
|
-
@logger.warn("Problem (
|
28
|
+
@logger.warn("Problem while sending message(s) to Service Bus: HTTP #{env.status}")
|
29
|
+
if env.status == 401
|
30
|
+
refresh_access_token
|
31
|
+
env.request_headers['Authorization'] = "Bearer #{@access_token}"
|
32
|
+
end
|
29
33
|
end
|
30
34
|
end,
|
31
|
-
retry_if: lambda do |
|
32
|
-
refresh_access_token if env.status == 401
|
35
|
+
retry_if: lambda do |_env, _exc|
|
33
36
|
true # Always retry
|
34
37
|
end
|
35
38
|
}
|
@@ -68,30 +71,31 @@ class LogStash::Outputs::AzureServiceBus < LogStash::Outputs::Base
|
|
68
71
|
end
|
69
72
|
rescue StandardError => e
|
70
73
|
# Hopefully we never make it here and "throw away" messages since we have an agressive retry strategy.
|
71
|
-
@logger.error("Error
|
74
|
+
@logger.error("Error while sending message(s) to Service Bus: #{e.inspect}")
|
72
75
|
else
|
73
76
|
if response.status == 201
|
74
77
|
@logger.debug("Sent #{messages.length} message(s) to Service Bus")
|
75
78
|
else
|
76
|
-
@logger.error("Error while sending message to Service Bus: HTTP #{response.status}")
|
79
|
+
@logger.error("Error while sending message(s) to Service Bus: HTTP #{response.status}")
|
77
80
|
end
|
78
81
|
end
|
79
82
|
|
80
83
|
def refresh_access_token
|
81
|
-
@logger.info('Refreshing Azure access token')
|
84
|
+
@logger.info('Refreshing Azure access token...')
|
82
85
|
begin
|
83
86
|
response = Faraday.get('http://169.254.169.254/metadata/identity/oauth2/token', { 'api-version' => '2018-02-01', 'resource' => 'https://servicebus.azure.net/' }) do |req|
|
84
87
|
req.headers = { 'Metadata' => 'true' }
|
85
|
-
req.options.timeout =
|
88
|
+
req.options.timeout = 10
|
86
89
|
end
|
87
90
|
rescue StandardError => e # We just catch everything and move on since @service_bus_conn will handle retries.
|
88
|
-
@logger.error("Error while fetching access token: #{e}")
|
91
|
+
@logger.error("Error while fetching access token: #{e.inpsect}")
|
89
92
|
else
|
90
93
|
if response.status == 200
|
91
94
|
data = JSON.parse(response.body)
|
92
95
|
@access_token = data['access_token']
|
96
|
+
@logger.info('Successfully refreshed Azure access token')
|
93
97
|
else
|
94
|
-
@logger.error("
|
98
|
+
@logger.error("Error while fetching access token: HTTP #{response.status}")
|
95
99
|
end
|
96
100
|
end
|
97
101
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-azure_service_bus'
|
3
|
-
s.version = '0.3.
|
3
|
+
s.version = '0.3.6'
|
4
4
|
s.licenses = ['Apache-2.0']
|
5
5
|
s.summary = 'Send Logstash messages to Azure Service Bus.'
|
6
6
|
s.homepage = 'https://github.com/gharryg/logstash-output-azure_service_bus'
|