logstash-output-application_insights 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/lib/logstash/outputs/application_insights.rb +4 -4
- data/lib/logstash/outputs/application_insights/blob.rb +3 -1
- data/lib/logstash/outputs/application_insights/channel.rb +12 -4
- data/lib/logstash/outputs/application_insights/constants.rb +3 -3
- data/lib/logstash/outputs/application_insights/notification_recovery.rb +18 -15
- data/lib/logstash/outputs/application_insights/shutdown.rb +0 -2
- data/lib/logstash/outputs/application_insights/storage_recovery.rb +21 -8
- data/lib/logstash/outputs/application_insights/telemetry.rb +25 -8
- data/lib/logstash/outputs/application_insights/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eeff77711bd05c02e3efc1c3a0a7ab7dc40fb109
|
4
|
+
data.tar.gz: d4e3a91792cccfd42befb748d1dfc0dea6181735
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bff4c4074ed237dc768c9c69d555eee4241651d240dc69786431f7f24d7ab67487a01c7f209cc51b8d210561bb348f4c2f32c3b183ebf9c7d52bb0f2eb2c7039
|
7
|
+
data.tar.gz: 18a245f8fd5ecdff45c0efdb6fc73b236d9f89996d711ed8cce63fb9bd2a09e66a0731ec2cea5a8d0a23fb5b4cd02d58ae2cf2fe112b3d14aebd0ca9297759ba
|
data/README.md
CHANGED
@@ -48,13 +48,16 @@ input {
|
|
48
48
|
}
|
49
49
|
}
|
50
50
|
filter {
|
51
|
-
|
51
|
+
# some filters here
|
52
52
|
}
|
53
53
|
output {
|
54
54
|
application_insights {
|
55
55
|
instrumentation_key => "5a6714a3-ec7b-4999-ab96-232f1da92059"
|
56
56
|
table_id => "c24394e1-f077-420e-8a25-ef6fdf045938"
|
57
57
|
storage_account_name_key => [ "my-storage-account", "pfrYTwPgKyYNfKBY2QdF+v5sbgx8/eAQp+FFkGpPBnkMDE1k+ZNK3r3qIPqqw8UsOIUqaF3dXBdPDouGJuxNXQ==" ]
|
58
|
+
#
|
59
|
+
# if you want to allow Microsoft get telemtry data about this process please set it to true
|
60
|
+
enable_telemetry_to_microsoft => false
|
58
61
|
}
|
59
62
|
}
|
60
63
|
```
|
@@ -341,11 +344,12 @@ example:
|
|
341
344
|
ca_file => "/path/to/cafile.crt"
|
342
345
|
```
|
343
346
|
|
344
|
-
###
|
345
|
-
When set to true, telemetry about the plugin,
|
347
|
+
### enable_telemetry_to_microsoft
|
348
|
+
When set to true, telemetry about the plugin, will't be sent to Microsoft. Deafult false
|
349
|
+
**Only if you want to allow Microsoft get telemtry data about this process set it to true**
|
346
350
|
example:
|
347
351
|
```ruby
|
348
|
-
|
352
|
+
enable_telemetry_to_microsoft => true
|
349
353
|
```
|
350
354
|
|
351
355
|
### disable_cleanup
|
@@ -253,8 +253,8 @@ class LogStash::Outputs::Application_insights < LogStash::Outputs::Base
|
|
253
253
|
config :ca_file, :validate => :string
|
254
254
|
|
255
255
|
|
256
|
-
# When set to true, telemetry about the plugin,
|
257
|
-
config :
|
256
|
+
# When set to true, telemetry about the plugin, will't be sent to Microsoft. Deafult false
|
257
|
+
config :enable_telemetry_to_microsoft, :validate => :boolean
|
258
258
|
|
259
259
|
# When set to true, storage cleanup won't be done by the plugin (should be done by some other means or by another Logstash process with this flag enabled)
|
260
260
|
config :disable_cleanup, :validate => :boolean
|
@@ -349,7 +349,7 @@ class LogStash::Outputs::Application_insights < LogStash::Outputs::Base
|
|
349
349
|
# @channels.receive( event, encoded_event )
|
350
350
|
# end
|
351
351
|
|
352
|
-
@telemetry.track_event
|
352
|
+
@telemetry.track_event { { :name => "register", :properties => configuration } }
|
353
353
|
|
354
354
|
|
355
355
|
return "ok\n"
|
@@ -363,7 +363,7 @@ class LogStash::Outputs::Application_insights < LogStash::Outputs::Base
|
|
363
363
|
end
|
364
364
|
|
365
365
|
def close
|
366
|
-
@telemetry.track_event
|
366
|
+
@telemetry.track_event { { :name => "close" } }
|
367
367
|
@telemetry.flush
|
368
368
|
@shutdown_recovery.close
|
369
369
|
@storage_recovery.close
|
@@ -259,6 +259,7 @@ class LogStash::Outputs::Application_insights
|
|
259
259
|
end
|
260
260
|
end
|
261
261
|
|
262
|
+
# must return whether notification was successful or failed
|
262
263
|
def notify ( tuple = nil )
|
263
264
|
tuple_to_state( tuple ) if tuple
|
264
265
|
@action = :notify
|
@@ -275,10 +276,12 @@ class LogStash::Outputs::Application_insights
|
|
275
276
|
@log_state = :notified
|
276
277
|
}
|
277
278
|
if success
|
279
|
+
Telemetry.instance.track_event { { :name => "notified", :properties => state_to_table_entity } }
|
278
280
|
state_table_update
|
279
281
|
else
|
280
282
|
notify_retry_later
|
281
283
|
end
|
284
|
+
success
|
282
285
|
end
|
283
286
|
|
284
287
|
CREATE_EXIST_ERRORS = { :container => [ :create_container, :container_exist ], :table => [ :create_table, :table_exist ] }
|
@@ -473,7 +476,6 @@ class LogStash::Outputs::Application_insights
|
|
473
476
|
@block_to_upload = nil
|
474
477
|
State.instance.inc_pending_commits if first_block_in_blob
|
475
478
|
State.instance.dec_upload_bytesize( bytesize )
|
476
|
-
Telemetry.instance.track_event("uploading", {:properties => state_to_table_entity})
|
477
479
|
}
|
478
480
|
|
479
481
|
upload_retry_later unless success
|
@@ -46,7 +46,6 @@ class LogStash::Outputs::Application_insights
|
|
46
46
|
@failed_on_notify_retry_Q = Queue.new
|
47
47
|
@workers_channel = { }
|
48
48
|
@active_blobs = [ Blob.new( self, 1 ) ]
|
49
|
-
@state = State.instance
|
50
49
|
|
51
50
|
launch_upload_recovery_thread
|
52
51
|
launch_notify_recovery_thread
|
@@ -137,20 +136,29 @@ class LogStash::Outputs::Application_insights
|
|
137
136
|
end
|
138
137
|
|
139
138
|
|
140
|
-
# thread that failed to notify due to Application
|
139
|
+
# thread that failed to notify due to Application Insights error, such as wrong key or wrong schema
|
141
140
|
def launch_notify_recovery_thread
|
142
141
|
#recovery thread
|
143
142
|
Thread.new do
|
144
143
|
loop do
|
145
|
-
tuple
|
144
|
+
tuple = @failed_on_notify_retry_Q.pop
|
146
145
|
begin
|
147
146
|
Stud.stoppable_sleep( 60 ) { stopped? }
|
148
147
|
end until Clients.instance.storage_account_state_on? || stopped?
|
148
|
+
|
149
149
|
if stopped?
|
150
|
+
@state ||= State.instance
|
150
151
|
@state.dec_pending_notifications
|
152
|
+
@shutdown ||= Shutdown.instance
|
153
|
+
@shutdown.display_msg("!!! notification won't recover in this session due to shutdown")
|
151
154
|
else
|
152
|
-
Blob.new.notify( tuple )
|
155
|
+
success = Blob.new.notify( tuple )
|
156
|
+
while success && @failed_on_notify_retry_Q.length > 0
|
157
|
+
tuple = @failed_on_notify_retry_Q.pop
|
158
|
+
success = Blob.new.notify( tuple )
|
159
|
+
end
|
153
160
|
end
|
161
|
+
tuple = nil # release for GC
|
154
162
|
end
|
155
163
|
end
|
156
164
|
end
|
@@ -37,7 +37,7 @@ class LogStash::Outputs::Application_insights
|
|
37
37
|
:stop_on_unknown_io_errors => @stop_on_unknown_io_errors || DEFAULT_STOP_ON_UNKNOWN_IO_ERRORS,
|
38
38
|
:delete_not_notified_blobs => @delete_not_notified_blobs || DEFAULT_DELETE_NOT_NOTIFIED_BLOBS,
|
39
39
|
:save_notified_blobs_records => @save_notified_blobs_records || DEFAULT_SAVE_NOTIFIED_BLOBS_RECORDS,
|
40
|
-
:
|
40
|
+
:enable_telemetry_to_microsoft => @enable_telemetry_to_microsoft || DEFAULT_ENABLE_TELEMETRY_TO_MICROSOFT,
|
41
41
|
:disable_cleanup => @disable_cleanup || DEFAULT_DISABLE_CLEANUP,
|
42
42
|
:blob_max_bytesize => @blob_max_bytesize || DEFAULT_BLOB_MAX_BYTESIZE,
|
43
43
|
:blob_max_events => @blob_max_events || DEFAULT_BLOB_MAX_EVENTS,
|
@@ -78,7 +78,7 @@ class LogStash::Outputs::Application_insights
|
|
78
78
|
end
|
79
79
|
|
80
80
|
BOOLEAN_PROPERTIES = [ :disable_notification, :disable_blob_upload,
|
81
|
-
:stop_on_unknown_io_errors, :
|
81
|
+
:stop_on_unknown_io_errors, :enable_telemetry_to_microsoft,
|
82
82
|
:disable_cleanup, :delete_not_notified_blobs,
|
83
83
|
:validate_notification, :validate_storage,
|
84
84
|
:save_notified_blobs_records, :case_insensitive_columns,
|
@@ -193,7 +193,7 @@ class LogStash::Outputs::Application_insights
|
|
193
193
|
DEFAULT_DISABLE_NOTIFICATION = false
|
194
194
|
DEFAULT_DISABLE_BLOB_UPLOAD = false
|
195
195
|
DEFAULT_STOP_ON_UNKNOWN_IO_ERRORS = false
|
196
|
-
|
196
|
+
DEFAULT_ENABLE_TELEMETRY_TO_MICROSOFT = false
|
197
197
|
DEFAULT_DISABLE_CLEANUP = false
|
198
198
|
DEFAULT_DELETE_NOT_NOTIFIED_BLOBS = false
|
199
199
|
DEFAULT_SAVE_NOTIFIED_BLOBS_RECORDS = false
|
@@ -39,7 +39,14 @@ class LogStash::Outputs::Application_insights
|
|
39
39
|
|
40
40
|
def recover_later ( tuple )
|
41
41
|
@notification_state_on = false
|
42
|
-
|
42
|
+
if stopped?
|
43
|
+
@state ||= State.instance
|
44
|
+
@state.dec_pending_notifications
|
45
|
+
@shutdown ||= Shutdown.instance
|
46
|
+
@shutdown.display_msg("!!! notification won't recover in this session due to shutdown")
|
47
|
+
else
|
48
|
+
@queue << tuple
|
49
|
+
end
|
43
50
|
end
|
44
51
|
|
45
52
|
def enqueue ( tuple )
|
@@ -57,14 +64,6 @@ class LogStash::Outputs::Application_insights
|
|
57
64
|
@closing
|
58
65
|
end
|
59
66
|
|
60
|
-
def init_queues ( storage_account_name_key, queues )
|
61
|
-
storage_account_name_key.each do |storage_account_name, storage_account_keys|
|
62
|
-
queues.each_key do |action|
|
63
|
-
queues[action][storage_account_name] = Queue.new
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
67
|
def recovery_thread
|
69
68
|
Thread.new do
|
70
69
|
blob = Blob.new
|
@@ -72,12 +71,16 @@ class LogStash::Outputs::Application_insights
|
|
72
71
|
|
73
72
|
loop do
|
74
73
|
tuple = @queue.pop
|
75
|
-
Stud.stoppable_sleep(Float::INFINITY, 1) { state_on?( blob ) && 10 > counter.value }
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
counter.
|
74
|
+
Stud.stoppable_sleep(Float::INFINITY, 1) { ( state_on?( blob ) || stopped? ) && 10 > counter.value }
|
75
|
+
|
76
|
+
if stopped? && !state_on?( blob )
|
77
|
+
recover_later( tuple )
|
78
|
+
else
|
79
|
+
counter.increment
|
80
|
+
Thread.new( counter, tuple ) do |counter, tuple|
|
81
|
+
Blob.new.notify( tuple )
|
82
|
+
counter.decrement
|
83
|
+
end
|
81
84
|
end
|
82
85
|
tuple = nil # release for GC
|
83
86
|
end
|
@@ -43,8 +43,17 @@ class LogStash::Outputs::Application_insights
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
def recover_later ( tuple, action, storage_account_name )
|
47
|
-
|
46
|
+
def recover_later ( tuple, action = nil, storage_account_name = nil )
|
47
|
+
if stopped?
|
48
|
+
if :commit == action
|
49
|
+
@state ||= State.instance
|
50
|
+
@state.dec_pending_commits
|
51
|
+
@shutdown ||= Shutdown.instance
|
52
|
+
@shutdown.display_msg("!!! commit won't recover in this session due to shutdown")
|
53
|
+
end
|
54
|
+
else
|
55
|
+
@queues[action][storage_account_name] << tuple
|
56
|
+
end
|
48
57
|
end
|
49
58
|
|
50
59
|
def close
|
@@ -75,12 +84,16 @@ class LogStash::Outputs::Application_insights
|
|
75
84
|
queue = @queues[action][storage_account_name]
|
76
85
|
loop do
|
77
86
|
tuple = queue.pop
|
78
|
-
Stud.stoppable_sleep(Float::INFINITY, 1) { state_on?( storage_account_name ) && 10 > counter.value }
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
counter.
|
87
|
+
Stud.stoppable_sleep(Float::INFINITY, 1) { ( state_on?( storage_account_name ) || stopped? ) && 10 > counter.value }
|
88
|
+
|
89
|
+
if stopped? && !state_on?( storage_account_name )
|
90
|
+
recover_later( tuple )
|
91
|
+
else
|
92
|
+
counter.increment
|
93
|
+
Thread.new( action, counter, tuple ) do |action, counter, tuple|
|
94
|
+
Blob.new.send( action, tuple )
|
95
|
+
counter.decrement
|
96
|
+
end
|
84
97
|
end
|
85
98
|
tuple = nil # release for GC
|
86
99
|
end
|
@@ -30,8 +30,8 @@ class LogStash::Outputs::Application_insights
|
|
30
30
|
|
31
31
|
def initialize
|
32
32
|
configuration = Config.current
|
33
|
-
@
|
34
|
-
|
33
|
+
@enable_telemetry_to_microsoft = configuration[:enable_telemetry_to_microsoft]
|
34
|
+
if @enable_telemetry_to_microsoft
|
35
35
|
@telemetry_channel = create_async_channel( LOGSTASH_TELEMETRY_INSTRUMENTATION_KEY )
|
36
36
|
set_async_channel_properties( @telemetry_channel )
|
37
37
|
set_channel_context( @telemetry_channel )
|
@@ -69,16 +69,33 @@ class LogStash::Outputs::Application_insights
|
|
69
69
|
# tc.context.user.id = 'santa@northpole.net'
|
70
70
|
end
|
71
71
|
|
72
|
-
def track_event
|
73
|
-
|
72
|
+
def track_event
|
73
|
+
if @enable_telemetry_to_microsoft
|
74
|
+
options = yield
|
75
|
+
name = options.delete( :name )
|
76
|
+
@telemetry_channel.track_event( name, options )
|
77
|
+
end
|
74
78
|
end
|
75
79
|
|
76
|
-
def track_metric
|
77
|
-
|
80
|
+
def track_metric
|
81
|
+
if @enable_telemetry_to_microsoft
|
82
|
+
options = yield
|
83
|
+
name = options.delete( :name )
|
84
|
+
value = options.delete( :value )
|
85
|
+
@telemetry_channel.track_metric( name, value, options )
|
86
|
+
end
|
78
87
|
end
|
79
88
|
|
80
|
-
def track_request
|
81
|
-
|
89
|
+
def track_request
|
90
|
+
if @enable_telemetry_to_microsoft
|
91
|
+
options = yield
|
92
|
+
id = options.delete( :id )
|
93
|
+
start_time = options.delete( :start_time )
|
94
|
+
duration = options.delete( :duration )
|
95
|
+
response_code = options.delete( :response_code )
|
96
|
+
success = options.delete( :success )
|
97
|
+
@telemetry_channel.track_request( id, start_time, duration, response_code, success, options )
|
98
|
+
end
|
82
99
|
end
|
83
100
|
|
84
101
|
def flush
|
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.5
|
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-09-
|
11
|
+
date: 2016-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|