logstash-output-applicationinsights 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ee4596c361e88edab65f8aa680efe054dc22661
4
- data.tar.gz: 6453ed63749c76d8d19411453dacdec2481f952f
3
+ metadata.gz: 56eb89268c2ab037a4210b2186c90e8f1e3b77e1
4
+ data.tar.gz: f4a10728a8a13bb5d730702d4f64ec77013be935
5
5
  SHA512:
6
- metadata.gz: 39b0079c0ee0add3155ec296a38fb56555595138feaddf997440ce2eb7f19e0ce304778aedb5d980d29ef3f994c805c10838cbd239877c24d9d3233d8f93935c
7
- data.tar.gz: 6861932fb600a9bcb92b13030ff870af483b66776cccecc397a14385e253df0adca3dfe8f09ac6527b96b89230c0a7c51c9e40b60fb6ad0d06d211cf9f875561
6
+ metadata.gz: 6861df39c2a94f2540b38e3e9fd4f007ba5aaaa0fec3161473af8d75953c38bd653d8e06960dd58fc75b94743ece57aee4c833d7e33623a34e710a13d8f1c24a
7
+ data.tar.gz: 5ddf8ede80ce2bcd3e249ceeb91ceadd768ee858321920c2508481c2100255febadbd7f3a374e09727d3f5275bd26aac067353a6f00880922261b48f5d741cd4
@@ -1,2 +1,5 @@
1
1
  ## 2016.06.03
2
- * First version.
2
+ * First version.
3
+
4
+ ## 2016.06.30
5
+ * Added metrics and event reporting support
data/README.md CHANGED
@@ -16,6 +16,10 @@ __*ikey*__
16
16
 
17
17
  The Application Insights Instrumentation key.
18
18
 
19
+ __*ai_type*__
20
+
21
+ The type of Application Insights event: "trace", "metric" and "event" are supported
22
+
19
23
  ### Optional Parameters
20
24
  __*ai_message_field*__
21
25
 
@@ -35,6 +39,14 @@ Specifies how to map the values read from *ai_severity_level_field* to Applicati
35
39
 
36
40
  See example below for how to map [Azure diagnostics log level values](https://msdn.microsoft.com/en-us/library/azure/microsoft.windowsazure.diagnostics.loglevel.aspx) to [Application Insights severity values](https://github.com/Microsoft/ApplicationInsights-Ruby/blob/master/lib/application_insights/channel/contracts/severity_level.rb).
37
41
 
42
+ __*ai_metrics_names*__
43
+
44
+ Specifies the names of the event fields to be used as metrics name; the value of each field specified will be reported as metric value. If not specified, no metric will be reported.
45
+
46
+ __*ai_event_name*__
47
+
48
+ Specifies the name of the event to be reported; If not specified, no event will be reported.
49
+
38
50
  __*dev_mode*__
39
51
 
40
52
  If this is set to True, the plugin sends telemetry to Application Insights immediately; otherwise the plugin respects production sending policies defined by other properties.
@@ -10,12 +10,15 @@ class LogStash::Outputs::ApplicationInsights < LogStash::Outputs::Base
10
10
  config_name "applicationinsights"
11
11
 
12
12
  config :ikey, :validate => :string, :required => true
13
+ config :ai_type, :validate => :string, :required => true
13
14
  config :dev_mode, :validate => :boolean, :required => false, :default => false
14
15
  config :ai_message_field, :validate => :string, :required => false, :default => nil
15
16
  config :ai_properties_field, :validate => :string, :required => false, :default => nil
16
17
  config :ai_severity_level_field, :validate => :string, :required => false, :default => nil
17
18
  config :ai_severity_level_mapping, :validate => :hash, :required => false, :default => nil
18
-
19
+ config :ai_metrics_names, :validate => :array, :required => false, :default => nil
20
+ config :ai_event_name, :validate => :string, :required => false, :default => nil
21
+
19
22
  public
20
23
  def register
21
24
  create_client
@@ -25,11 +28,26 @@ class LogStash::Outputs::ApplicationInsights < LogStash::Outputs::Base
25
28
  def multi_receive(events)
26
29
  events.each do |event|
27
30
  begin
28
- ai_message = get_ai_message(event)
29
31
  ai_properties = get_ai_properties(event)
30
- ai_severity = get_ai_severity(event)
32
+ if @ai_type == "trace"
33
+ ai_message = get_field(event, @ai_message_field)
34
+ ai_severity = get_ai_severity(event)
35
+ @client.track_trace(ai_message, ai_severity, { :properties => ai_properties })
36
+ elsif @ai_type == "metric"
37
+ if !@ai_metrics_names.nil? && @ai_metrics_names.any?
38
+ @ai_metrics_names.each do |metric_name|
39
+ metric_value = get_field(event, metric_name)
40
+ if metric_value.nil?
41
+ @logger.warn("#{@metric_name} specified in ai_metrics_names not found in event data.")
42
+ else
43
+ @client.track_metric(metric_name, metric_value.to_f, { :properties => ai_properties })
44
+ end # if
45
+ end # do
46
+ end # if ai_metric_fields
47
+ elsif @ai_type == "event"
48
+ @client.track_event(@ai_event_name, { :properties => ai_properties }) if !@ai_event_name.nil?
49
+ end # if ai_type
31
50
 
32
- @client.track_trace(ai_message, ai_severity, { :properties => ai_properties })
33
51
  @client.flush if @dev_mode
34
52
 
35
53
  rescue => e
@@ -49,13 +67,13 @@ class LogStash::Outputs::ApplicationInsights < LogStash::Outputs::Base
49
67
  @client = TelemetryClient.new(@ikey, telemetry_channel)
50
68
  end # def create_client
51
69
 
52
- def get_ai_message(event)
53
- return nil if @ai_message_field.nil?
70
+ def get_field(event, field_name)
71
+ return nil if field_name.nil?
54
72
 
55
- ai_message = event[@ai_message_field] # Extracts specified field value as the AI Message.
56
- @logger.warn("#{@ai_message_field} specified in ai_message_field not found in event data. AI Message will be null.") if ai_message.nil?
57
- event.remove(@ai_message_field) unless ai_message.nil? # Removes the duplicated AI Message field.
58
- ai_message
73
+ field = event[field_name] # Extracts specified field value as the AI Message.
74
+ @logger.warn("#{field_name} not found in event data.") if field.nil?
75
+ event.remove(field_name) unless field.nil? # Removes the duplicated AI field.
76
+ field
59
77
  end # def get_ai_message
60
78
 
61
79
  def get_ai_properties(event)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-applicationinsights'
3
- s.version = '0.9.0'
3
+ s.version = '0.9.1'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "This plugin sends data to Application Insights."
6
6
  s.description = "This gem is a Logstash plugin. It sends data to Application Insights."
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-applicationinsights
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Microsoft Corporation
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-11 00:00:00.000000000 Z
11
+ date: 2016-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: logstash-core
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
- - - ~>
17
+ - - "~>"
17
18
  - !ruby/object:Gem::Version
18
19
  version: '2.0'
19
- name: logstash-core
20
- prerelease: false
21
20
  type: :runtime
21
+ prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
+ name: application_insights
28
29
  requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ~>
31
+ - - "~>"
31
32
  - !ruby/object:Gem::Version
32
33
  version: 0.5.3
33
- name: application_insights
34
- prerelease: false
35
34
  type: :runtime
35
+ prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.5.3
41
41
  - !ruby/object:Gem::Dependency
42
+ name: logstash-devutils
42
43
  requirement: !ruby/object:Gem::Requirement
43
44
  requirements:
44
- - - '>='
45
+ - - ">="
45
46
  - !ruby/object:Gem::Version
46
47
  version: 0.0.16
47
- name: logstash-devutils
48
- prerelease: false
49
48
  type: :development
49
+ prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.0.16
55
55
  description: This gem is a Logstash plugin. It sends data to Application Insights.
@@ -71,24 +71,24 @@ licenses:
71
71
  metadata:
72
72
  logstash_plugin: 'true'
73
73
  logstash_group: output
74
- post_install_message:
74
+ post_install_message:
75
75
  rdoc_options: []
76
76
  require_paths:
77
77
  - lib
78
78
  required_ruby_version: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - '>='
85
+ - - ">="
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  requirements: []
89
- rubyforge_project:
90
- rubygems_version: 2.4.8
91
- signing_key:
89
+ rubyforge_project:
90
+ rubygems_version: 2.5.1
91
+ signing_key:
92
92
  specification_version: 4
93
93
  summary: This plugin sends data to Application Insights.
94
94
  test_files: