logstash-output-scalyr 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f02a9ffc8738ad5eef45acc94337eaa36f3e567883429b761691318f40de5eda
4
- data.tar.gz: 124d1ced3db2cbf8ad6a38b196f1697f75b2852bc9b55585c19dc6a87a72469a
3
+ metadata.gz: 90d9ce5222a3ea4241a086f8d57ed969afa5af0edb4dfbe47d55af214318d354
4
+ data.tar.gz: f948a285cfdc401090c66133423bad1db96678c108ba7d508bd76010eb9cf5ac
5
5
  SHA512:
6
- metadata.gz: aa3669f7d0fe767ae50b7e4ac82448d2cd08ca850276b66b2b9d9dd4d0a06f17d32e45b07a1b4980dc41211b314e307c447d9b26bf8adb10e5db5c7c65677e13
7
- data.tar.gz: 62d214449bba6046617016291a2da8be3df21a6505f891ec0afc2d647b777e80fb64db01b0882565e591e4aa7de6fd2ad3d5eab921669c801521a1f85235c4db
6
+ metadata.gz: 4c32b4fc84c642fe54918869479b288adc5f709a4b5d151b27cf52e75f00c4eeb6b96134ae210b935ea9aed628692ad77aa47322b2d72d5b75ba48f1526dd554
7
+ data.tar.gz: d572c2fcfbdc3a0b9c2fbd3af035803a75de55d2f8f95abc4ce398fecb7fb290b7e90cedf9b771e7d5dcd4fd5759d7fdd312f7ea00f27b9df680ccfed9b79689
data/README.md CHANGED
@@ -10,7 +10,7 @@ You can view documentation for this plugin [on the Scalyr website](https://app.s
10
10
  # Quick start
11
11
 
12
12
  1. Build the gem, run `gem build logstash-output-scalyr.gemspec`
13
- 2. Install the gem into a Logstash installation, run `/usr/share/logstash/bin/logstash-plugin install logstash-output-scalyr-0.1.4.gem` or follow the latest official instructions on working with plugins from Logstash.
13
+ 2. Install the gem into a Logstash installation, run `/usr/share/logstash/bin/logstash-plugin install logstash-output-scalyr-0.1.5.gem` or follow the latest official instructions on working with plugins from Logstash.
14
14
  3. Configure the output plugin (e.g. add it to a pipeline .conf)
15
15
  4. Restart Logstash
16
16
 
@@ -110,6 +110,7 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
110
110
 
111
111
  public
112
112
  def register
113
+ @node_hostname = Socket.gethostname
113
114
 
114
115
  if @log_constants and not @log_constants.all? { |x| x.is_a? String }
115
116
  raise LogStash::ConfigurationError, "All elements of 'log_constants' must be strings."
@@ -157,7 +158,7 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
157
158
  # Note: Use strings rather than symbols for the key, because keys coming
158
159
  # from the config file will be strings
159
160
  unless @server_attributes.key? 'serverHost'
160
- @server_attributes['serverHost'] = Socket.gethostname
161
+ @server_attributes['serverHost'] = @node_hostname
161
162
  end
162
163
  end
163
164
 
@@ -361,16 +362,25 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
361
362
 
362
363
  # Rename user-specified serverHost field -> 'serverHost'
363
364
  rename.call(@serverhost_field, 'serverHost')
364
- record.delete(@serverhost_field)
365
365
 
366
366
  # Rename user-specified logfile field -> 'logfile'
367
367
  rename.call(@logfile_field, 'logfile')
368
- record.delete(@logfile_field)
368
+
369
+ # Set a default parser is none is present in the event
370
+ if record['parser'].to_s.empty?
371
+ record['parser'] = "logstashParser"
372
+ end
373
+
369
374
  # Set logfile field if empty and serverHost is supplied
370
375
  if record['logfile'].to_s.empty? and serverHost
371
376
  record['logfile'] = "/logstash/#{serverHost}"
372
377
  end
373
378
 
379
+ # Set a default if no serverHost value is present.
380
+ if serverHost.nil?
381
+ record['serverHost'] = "Logstash"
382
+ end
383
+
374
384
  log_identifier = nil
375
385
  add_log = false
376
386
  if serverHost
@@ -562,6 +572,7 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
562
572
 
563
573
  if !@last_status_transmit_time
564
574
  status_event[:attrs]['message'] = "Started Scalyr LogStash output plugin."
575
+ status_event[:attrs]['serverHost'] = @node_hostname
565
576
  else
566
577
  cur_time = Time.now()
567
578
  return if (cur_time.to_i - @last_status_transmit_time.to_i) < 300
@@ -575,6 +586,7 @@ class LogStash::Outputs::Scalyr < LogStash::Outputs::Base
575
586
  cnt += 1
576
587
  end
577
588
  status_event[:attrs]['message'] = msg
589
+ status_event[:attrs]['serverHost'] = @node_hostname
578
590
  end
579
591
  multi_event_request = create_multi_event_request([status_event], nil, nil)
580
592
  @client_session.post_add_events(multi_event_request[:body])
@@ -227,7 +227,7 @@ class ClientSession
227
227
 
228
228
  post = Net::HTTP::Post.new uri_path
229
229
  post.add_field('Content-Type', 'application/json')
230
- version = 'output-logstash-scalyr 0.1.4'
230
+ version = 'output-logstash-scalyr 0.1.5'
231
231
  post.add_field('User-Agent', version + ';' + RUBY_VERSION + ';' + RUBY_PLATFORM)
232
232
 
233
233
  if not encoding.nil?
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-scalyr'
3
- s.version = '0.1.4'
3
+ s.version = '0.1.5'
4
4
  s.licenses = ['Apache-2.0']
5
5
  s.summary = "Scalyr output plugin for Logstash"
6
6
  s.description = "Sends log data collected by Logstash to Scalyr (https://www.scalyr.com)"
@@ -116,9 +116,11 @@ describe LogStash::Outputs::Scalyr do
116
116
  'seq' => 3,
117
117
  'source_file' => 'my file 3',
118
118
  'source_host' => 'my host 3',
119
+ 'serverHost' => 'Logstash',
119
120
  "tag_prefix_t1" => "true",
120
121
  "tag_prefix_t2" => "true",
121
122
  "tag_prefix_t3" => "true",
123
+ "parser" => "logstashParser",
122
124
  })
123
125
  end
124
126
  end
@@ -139,7 +141,9 @@ describe LogStash::Outputs::Scalyr do
139
141
  'seq' => 3,
140
142
  'source_file' => 'my file 3',
141
143
  'source_host' => 'my host 3',
144
+ 'serverHost' => 'Logstash',
142
145
  "tags" => ["t1", "t2", "t3"],
146
+ "parser" => "logstashParser",
143
147
  })
144
148
  end
145
149
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-scalyr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edward Chee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-10 00:00:00.000000000 Z
11
+ date: 2020-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement