logstash-output-application_insights 0.1.3 → 0.1.4
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/README.md +29 -16
- data/lib/logstash/outputs/application_insights.rb +47 -62
- data/lib/logstash/outputs/application_insights/blob.rb +224 -383
- data/lib/logstash/outputs/application_insights/channel.rb +4 -4
- data/lib/logstash/outputs/application_insights/channels.rb +24 -24
- data/lib/logstash/outputs/application_insights/client.rb +10 -4
- data/lib/logstash/outputs/application_insights/config.rb +34 -27
- data/lib/logstash/outputs/application_insights/constants.rb +16 -6
- data/lib/logstash/outputs/application_insights/notification_recovery.rb +101 -0
- data/lib/logstash/outputs/application_insights/shutdown.rb +3 -0
- data/lib/logstash/outputs/application_insights/shutdown_recovery.rb +140 -0
- data/lib/logstash/outputs/application_insights/storage_cleanup.rb +7 -7
- data/lib/logstash/outputs/application_insights/storage_recovery.rb +104 -0
- data/lib/logstash/outputs/application_insights/utils.rb +17 -0
- data/lib/logstash/outputs/application_insights/validate_notification.rb +37 -0
- data/lib/logstash/outputs/application_insights/validate_storage.rb +41 -0
- data/lib/logstash/outputs/application_insights/version.rb +1 -1
- data/logstash-output-application-insights.gemspec +1 -1
- metadata +8 -3
@@ -90,7 +90,7 @@ class LogStash::Outputs::Application_insights
|
|
90
90
|
@info = "#{@action} #{@storage_account_name}"
|
91
91
|
|
92
92
|
containers = nil
|
93
|
-
success = storage_io_block
|
93
|
+
success = storage_io_block {
|
94
94
|
options = { :metadata => true }
|
95
95
|
options[:marker] = token if token
|
96
96
|
options[:prefix] = azure_storage_container_prefix if azure_storage_container_prefix
|
@@ -115,7 +115,7 @@ class LogStash::Outputs::Application_insights
|
|
115
115
|
continuation_token = nil
|
116
116
|
filter = "#{:container_name} eq '#{container_name}' and #{:log_state} ne '#{:notified}'"
|
117
117
|
begin
|
118
|
-
entities =
|
118
|
+
entities = state_table_query( @storage_account_name, filter , continuation_token )
|
119
119
|
return nil unless entities
|
120
120
|
token = entities.continuation_token
|
121
121
|
entities.each do |entity|
|
@@ -140,7 +140,7 @@ class LogStash::Outputs::Application_insights
|
|
140
140
|
@recoverable = [ :invalid_storage_key, :io_failure, :service_unavailable, :blob_exit, :create_container, :container_exist ]
|
141
141
|
@info = "#{@action} #{@storage_account_name}/#{container_name}/#{blob_name}"
|
142
142
|
tuple = nil
|
143
|
-
success = storage_io_block
|
143
|
+
success = storage_io_block {
|
144
144
|
create_exist_recovery( :container, @not_notified_container ) { |name| @client.blobClient.create_container( name ) }
|
145
145
|
if :blob_exit == @recovery
|
146
146
|
tuple = ["", :pending]
|
@@ -157,7 +157,7 @@ class LogStash::Outputs::Application_insights
|
|
157
157
|
@recoverable = [ :invalid_storage_key, :io_failure, :service_unavailable, :create_resource, :create_container, :container_exist ]
|
158
158
|
@info = "#{@action} #{@storage_account_name}/#{@not_notified_container}/#{blob_name}"
|
159
159
|
status = nil
|
160
|
-
success = storage_io_block
|
160
|
+
success = storage_io_block {
|
161
161
|
create_exist_recovery( :container, @not_notified_container ) { |name| @client.blobClient.create_container( name ) }
|
162
162
|
if :create_resource == @recovery
|
163
163
|
status = :not_started
|
@@ -177,11 +177,11 @@ class LogStash::Outputs::Application_insights
|
|
177
177
|
continuation_token = nil
|
178
178
|
filter = "#{:container_name} eq '#{container_name}'"
|
179
179
|
begin
|
180
|
-
entities =
|
180
|
+
entities = state_table_query( @storage_account_name, filter , continuation_token )
|
181
181
|
return nil unless entities
|
182
182
|
token = entities.continuation_token
|
183
183
|
entities.each do |entity|
|
184
|
-
return nil unless
|
184
|
+
return nil unless state_table_delete( table_entity_to_tuple( entity.properties ) )
|
185
185
|
end
|
186
186
|
end while continuation_token
|
187
187
|
true
|
@@ -194,7 +194,7 @@ class LogStash::Outputs::Application_insights
|
|
194
194
|
@recoverable = [ :invalid_storage_key, :io_failure, :service_unavailable, :create_container ]
|
195
195
|
@info = "#{@action} #{@storage_account_name}/#{container_name}"
|
196
196
|
|
197
|
-
success = storage_io_block
|
197
|
+
success = storage_io_block {
|
198
198
|
# delete container, if not found, skip
|
199
199
|
containers = @client.blobClient.delete_container( container_name ) unless :create_container == @recovery
|
200
200
|
}
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# ----------------------------------------------------------------------------------
|
4
|
+
# Logstash Output Application Insights
|
5
|
+
#
|
6
|
+
# Copyright (c) Microsoft Corporation
|
7
|
+
#
|
8
|
+
# All rights reserved.
|
9
|
+
#
|
10
|
+
# Licensed under the Apache License, Version 2.0 (the License);
|
11
|
+
# you may not use this file except in compliance with the License.
|
12
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
#
|
18
|
+
# See the Apache Version 2.0 License for specific language governing
|
19
|
+
# permissions and limitations under the License.
|
20
|
+
# ----------------------------------------------------------------------------------
|
21
|
+
class LogStash::Outputs::Application_insights
|
22
|
+
class Storage_recovery
|
23
|
+
|
24
|
+
public
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
configuration = Config.current
|
28
|
+
@logger = configuration[:logger]
|
29
|
+
@storage_account_name_key = configuration[:storage_account_name_key]
|
30
|
+
@queues = { :commit => {}, :notify => {}, :state_table_update => {} }
|
31
|
+
init_queues( @storage_account_name_key, @queues )
|
32
|
+
|
33
|
+
@closing = nil
|
34
|
+
@threads = []
|
35
|
+
end
|
36
|
+
|
37
|
+
def start
|
38
|
+
@storage_account_name_key.each do |storage_account_name, storage_account_keys|
|
39
|
+
# a threads, per storage account name
|
40
|
+
@queues.each_key do |action|
|
41
|
+
@threads << recovery_thread( storage_account_name, action )
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def recover_later ( tuple, action, storage_account_name )
|
47
|
+
@queues[action][storage_account_name] << tuple
|
48
|
+
end
|
49
|
+
|
50
|
+
def close
|
51
|
+
@closing = true
|
52
|
+
# @threads.each do |thread|
|
53
|
+
# thread.join
|
54
|
+
# end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def stopped?
|
60
|
+
@closing
|
61
|
+
end
|
62
|
+
|
63
|
+
def init_queues ( storage_account_name_key, queues )
|
64
|
+
storage_account_name_key.each do |storage_account_name, storage_account_keys|
|
65
|
+
queues.each_key do |action|
|
66
|
+
queues[action][storage_account_name] = Queue.new
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def recovery_thread( storage_account_name, action )
|
72
|
+
# a threads, per storage account name, that retries actions on storage
|
73
|
+
Thread.new( storage_account_name, action ) do |storage_account_name, action|
|
74
|
+
counter = Concurrent::AtomicFixnum.new(0)
|
75
|
+
queue = @queues[action][storage_account_name]
|
76
|
+
loop do
|
77
|
+
tuple = queue.pop
|
78
|
+
Stud.stoppable_sleep(Float::INFINITY, 1) { state_on?( storage_account_name ) && 10 > counter.value }
|
79
|
+
|
80
|
+
counter.increment
|
81
|
+
Thread.new( action, counter, tuple ) do |action, counter, tuple|
|
82
|
+
Blob.new.send( action, tuple )
|
83
|
+
counter.decrement
|
84
|
+
end
|
85
|
+
tuple = nil # release for GC
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def state_on? ( storage_account_name )
|
91
|
+
Clients.instance.storage_account_state_on?( storage_account_name )
|
92
|
+
end
|
93
|
+
|
94
|
+
public
|
95
|
+
|
96
|
+
@@instance = Storage_recovery.new
|
97
|
+
|
98
|
+
def self.instance
|
99
|
+
@@instance
|
100
|
+
end
|
101
|
+
|
102
|
+
private_class_method :new
|
103
|
+
end
|
104
|
+
end
|
@@ -111,6 +111,22 @@ class LogStash::Outputs::Application_insights
|
|
111
111
|
s =~ /\A(?<hostname>([A-Za-z0-9\.\-]+)|\[[0-9A-Fa-f\:]+\])(:(?<port>\d+))?\z/
|
112
112
|
end
|
113
113
|
|
114
|
+
def self.ip4_address? ( s )
|
115
|
+
s =~ /\A(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\z/
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.ip6_address? ( s )
|
119
|
+
s =~ /\A(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\z/
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.dns_address? ( s )
|
123
|
+
s =~ /\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/
|
124
|
+
end
|
125
|
+
|
126
|
+
def self.hosts_address? ( s )
|
127
|
+
ip4_address?( s ) || ip6_address?( s ) || dns_address?( s )
|
128
|
+
end
|
129
|
+
|
114
130
|
def self.to_storage_name ( s )
|
115
131
|
s.nil? ? nil : s.downcase.gsub(/[^0-9a-z]/i, '')
|
116
132
|
end
|
@@ -134,6 +150,7 @@ class LogStash::Outputs::Application_insights
|
|
134
150
|
end
|
135
151
|
new_hash
|
136
152
|
end
|
153
|
+
|
137
154
|
end
|
138
155
|
|
139
156
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# ----------------------------------------------------------------------------------
|
4
|
+
# Logstash Output Application Insights
|
5
|
+
#
|
6
|
+
# Copyright (c) Microsoft Corporation
|
7
|
+
#
|
8
|
+
# All rights reserved.
|
9
|
+
#
|
10
|
+
# Licensed under the Apache License, Version 2.0 (the License);
|
11
|
+
# you may not use this file except in compliance with the License.
|
12
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
#
|
18
|
+
# See the Apache Version 2.0 License for specific language governing
|
19
|
+
# permissions and limitations under the License.
|
20
|
+
# ----------------------------------------------------------------------------------
|
21
|
+
|
22
|
+
class LogStash::Outputs::Application_insights
|
23
|
+
class Validate_notification < Blob
|
24
|
+
|
25
|
+
public
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
# super first parameter must be nil. blob first parameter is channel, otherwise it will pass storage_account_name as channel
|
29
|
+
super( nil )
|
30
|
+
@storage_account_name_key = @configuration[:storage_account_name_key]
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate
|
34
|
+
{:success => test_notification( @storage_account_name_key[0][0] ), :error => @last_io_exception }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# ----------------------------------------------------------------------------------
|
4
|
+
# Logstash Output Application Insights
|
5
|
+
#
|
6
|
+
# Copyright (c) Microsoft Corporation
|
7
|
+
#
|
8
|
+
# All rights reserved.
|
9
|
+
#
|
10
|
+
# Licensed under the Apache License, Version 2.0 (the License);
|
11
|
+
# you may not use this file except in compliance with the License.
|
12
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
#
|
18
|
+
# See the Apache Version 2.0 License for specific language governing
|
19
|
+
# permissions and limitations under the License.
|
20
|
+
# ----------------------------------------------------------------------------------
|
21
|
+
|
22
|
+
class LogStash::Outputs::Application_insights
|
23
|
+
class Validate_storage < Blob
|
24
|
+
|
25
|
+
public
|
26
|
+
|
27
|
+
def initialize
|
28
|
+
# super first parameter must be nil. blob first parameter is channel, otherwise it will pass storage_account_name as channel
|
29
|
+
super( nil )
|
30
|
+
@storage_account_name_key = @configuration[:storage_account_name_key]
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate
|
34
|
+
result = {}
|
35
|
+
@storage_account_name_key.each do |storage_account_name, storage_account_keys|
|
36
|
+
result[storage_account_name] = {:success => test_storage( storage_account_name ), :error => @last_io_exception }
|
37
|
+
end
|
38
|
+
result
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.version = APPLICATION_INSIGHTS_VERSION
|
28
28
|
s.licenses = ['Apache License (2.0)']
|
29
29
|
s.summary = "Microsoft Application Insights openschema Logstash output plugin. 'Output events to Application Insights"
|
30
|
-
s.description = "Outputs events to Microsoft Application Insights Analytics. This gem is a Logstash output plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
30
|
+
s.description = "Outputs events to Microsoft Application Insights Analytics open schema tables. This gem is a Logstash output plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
31
31
|
s.authors = ["Microsoft Corporation"]
|
32
32
|
s.email = "info@microsoft.com"
|
33
33
|
s.homepage = "https://github.com/Microsoft/logstash-output-application-insights"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-application_insights
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Microsoft Corporation
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,7 +86,7 @@ dependencies:
|
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
|
-
description: Outputs events to Microsoft Application Insights Analytics. This gem is a Logstash output plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program
|
89
|
+
description: Outputs events to Microsoft Application Insights Analytics open schema tables. This gem is a Logstash output plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program
|
90
90
|
email: info@microsoft.com
|
91
91
|
executables: []
|
92
92
|
extensions: []
|
@@ -111,13 +111,18 @@ files:
|
|
111
111
|
- lib/logstash/outputs/application_insights/exceptions.rb
|
112
112
|
- lib/logstash/outputs/application_insights/flow_control.rb
|
113
113
|
- lib/logstash/outputs/application_insights/multi_io_logger.rb
|
114
|
+
- lib/logstash/outputs/application_insights/notification_recovery.rb
|
114
115
|
- lib/logstash/outputs/application_insights/shutdown.rb
|
116
|
+
- lib/logstash/outputs/application_insights/shutdown_recovery.rb
|
115
117
|
- lib/logstash/outputs/application_insights/state.rb
|
116
118
|
- lib/logstash/outputs/application_insights/storage_cleanup.rb
|
119
|
+
- lib/logstash/outputs/application_insights/storage_recovery.rb
|
117
120
|
- lib/logstash/outputs/application_insights/sub_channel.rb
|
118
121
|
- lib/logstash/outputs/application_insights/telemetry.rb
|
119
122
|
- lib/logstash/outputs/application_insights/timer.rb
|
120
123
|
- lib/logstash/outputs/application_insights/utils.rb
|
124
|
+
- lib/logstash/outputs/application_insights/validate_notification.rb
|
125
|
+
- lib/logstash/outputs/application_insights/validate_storage.rb
|
121
126
|
- lib/logstash/outputs/application_insights/version.rb
|
122
127
|
- logstash-output-application-insights.gemspec
|
123
128
|
- spec/outputs/application_insights_spec.rb
|