logstash-output-splunk_hec 0.2.1 → 0.2.2

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
  SHA256:
3
- metadata.gz: '09f53b9c010a8b0a598df047bd79b44358b8960c512897b58d02b6ca046b1b0c'
4
- data.tar.gz: b6887b783ed1bfae45cc50850d3a59ccfd07e1a00a492462e1d7e518f9bda250
3
+ metadata.gz: f12ba6a4c0c7bd31ea2444db3fa0c169c064f2ca57e3a84e99a6a302f9e730bf
4
+ data.tar.gz: 13b156bbb63461b8d5c5937ac413815e32de9d6912fc6572369c7157e974984f
5
5
  SHA512:
6
- metadata.gz: 77d1fc5fbbef2c3e21367253f9add4451f5c512025d82cb3b21f15d3b2824e76605c301accf6e1eeeacd9fc13328a7770b6fbbbc3f1933af42e70ed69b7c12e6
7
- data.tar.gz: c84e0e56254de9d4829d7aeacdf2bcfe7e3b80bdc949a9cabbe3b7fc23ed5fec4c141ea35fb07bc346f58f498b46010f366b883d1f54f5adf7becc26f50223d4
6
+ metadata.gz: c0f8630726eb385d0b12eff6902889a18522b40dcb3bb9465e8203b26aabe2f0e68d5037a1af34f773f0ddb178a14d19bd953e01dd7ffa6776e3a162752c4763
7
+ data.tar.gz: 43136925203426b59f606b4190b255a2ef9f4fd92a2e6761e553ba0856e486459acf57e84e5717e64ab1c17177b14366c58b4c24309508e6107a2c1193da6bb0
@@ -11,21 +11,23 @@ class LogStash::Outputs::SplunkHec < LogStash::Outputs::Base
11
11
 
12
12
  concurrency :shared
13
13
 
14
- config :token, :validate => :string, :required => true
15
- config :host, :validate => :string, :required => true
14
+ config :hec_token, :validate => :string, :required => true
15
+ config :hec_host, :validate => :string, :required => true
16
+ config :host, :validate => :string, :default => "none"
17
+ config :source, :validate => :string, :default => "none"
18
+ config :sourcetype, :validate => :string, :default => "none"
16
19
  config :port, :validate => :number, :default => 443
17
20
  config :index, :validate => :string, :default => "main"
18
- config :sourcetype, :validate => :string, :default => "_json"
19
21
  config :batch_size, :validate => :number, :default => 100
20
22
  config :flush_interval, :validate => :number, :default => 5
21
23
  config :retry_count, :validate => :number, :default => 3
22
24
 
23
25
  public
24
26
  def register
25
- @http = Net::HTTP.new(@host, @port)
27
+ @http = Net::HTTP.new(@hec_host, @port)
26
28
  @http.use_ssl = true
27
29
  @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
28
- @uri = URI.parse("https://#{@host}:#{@port}/services/collector/event")
30
+ @uri = URI.parse("https://#{@hec_host}:#{@port}/services/collector/event")
29
31
 
30
32
  @event_batch = Concurrent::Array.new
31
33
  @last_flush = Concurrent::AtomicReference.new(Time.now)
@@ -52,12 +54,12 @@ class LogStash::Outputs::SplunkHec < LogStash::Outputs::Base
52
54
 
53
55
  hec_event = {
54
56
  "time" => event.get("@timestamp").to_i,
55
- "host" => event.get("host")&.fetch("name") { Socket.gethostname },
56
- "source" => event.get("source") { "logstash" },
57
- "sourcetype" => @sourcetype,
57
+ "host" => @host != "none" ? @host : event.get("host")&.fetch("name") { Socket.gethostname } || "default_host",
58
+ "source" => @source != "none" ? @source : event.get("source") { "logstash" },
59
+ "sourcetype" => @sourcetype != "none" ? @sourcetype : "_json",
58
60
  "index" => @index,
59
61
  "event" => event_data
60
- }
62
+ }
61
63
 
62
64
  @event_batch << hec_event
63
65
  end
@@ -78,7 +80,7 @@ class LogStash::Outputs::SplunkHec < LogStash::Outputs::Base
78
80
 
79
81
  batch_to_send = @event_batch.slice!(0, @batch_size)
80
82
  request = Net::HTTP::Post.new(@uri.request_uri)
81
- request["Authorization"] = "Splunk #{@token}"
83
+ request["Authorization"] = "Splunk #{@hec_token}"
82
84
  request["Content-Type"] = "application/json"
83
85
  request.body = batch_to_send.map(&:to_json).join("\n")
84
86
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-splunk_hec'
3
- s.version = '0.2.1'
3
+ s.version = '0.2.2'
4
4
  s.licenses = ['Apache-2.0']
5
5
  s.summary = 'Logstash Output Plugin for SplunkHec'
6
6
  s.authors = ['Elisha Mawson']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-splunk_hec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elisha Mawson