logstash-output-splunk_hec 0.3.0 → 0.3.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
  SHA256:
3
- metadata.gz: 77f41ae7b26b099e92fdef3e0cf4e41855a681bfa94f903d04d95a5907cb6a52
4
- data.tar.gz: 525a3432cfddbf1a40fc951a62efd198f7901cb497fe750bce967a042c1d12ea
3
+ metadata.gz: d8e13e0d8fc9710b93c781847aea608d0465c1d1da0c09515672c03933c8ffaa
4
+ data.tar.gz: b153c7ec6cbf0c3089d88017d97d6fe0a255c84ce934f62f5f6690b8fa0a7a5c
5
5
  SHA512:
6
- metadata.gz: f72c3bef105aa5604165b8ee718728cee25b4563292eb6459eaa7235bbed6da512770d1f60db9fa7a2eab8e128a3875e3d1a56aa12269728a3952556d00acea2
7
- data.tar.gz: fdb77029972571cc683511113f89e599c963f47a381295b9dd87f4e50f7662e43b9cd05a6dbae3bcd9c0a0c239db31baf2667f535ac5bd8d68bccf149767a268
6
+ metadata.gz: a322311348c0a03d7b5ab34e6c172ef0b0c1871ac449bcbbdeb89dedcc17aacc2e09d6dc1fb2b12ec56aace9931b2785ad7f6c473aff4eae808704f3a46bbf64
7
+ data.tar.gz: f4a705ec8d6ca6ffe75efa6e2193c27f5bee4d8a05a06dc7a9c08e55802dd61ed1eeaf7725995102c351f126107960b8b9b6702160f482ca3dbd00e9001527da
@@ -48,15 +48,24 @@ class LogStash::Outputs::SplunkHec < LogStash::Outputs::Base
48
48
  event_data.delete("@version")
49
49
  hec_event = {
50
50
  "time" => event.get("@timestamp").to_i,
51
- "host" => @host != "none" ? @host : event.get("host")&.fetch("name") { Socket.gethostname } || "default_host",
52
- "source" => @source != "none" ? @source : event.get("source") { "logstash" },
53
- "sourcetype" => @sourcetype != "none" ? @sourcetype : "_json",
54
- "index" => @index,
51
+ "host" => interpolate_field(@host, event),
52
+ "source" => interpolate_field(@source, event),
53
+ "sourcetype" => interpolate_field(@sourcetype, event),
54
+ "index" => interpolate_field(@index, event),
55
55
  "event" => event_data
56
56
  }
57
57
  @event_batch << hec_event
58
58
  end
59
59
 
60
+ private
61
+ def interpolate_field(field, event)
62
+ return field if field == "none"
63
+ event.sprintf(field)
64
+ rescue => e
65
+ @logger.warn("Error interpolating field", :field => field, :error => e.message)
66
+ field
67
+ end
68
+
60
69
  private
61
70
  def batch_full?
62
71
  @event_batch.size >= @batch_size
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-splunk_hec'
3
- s.version = '0.3.0'
3
+ s.version = '0.3.1'
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-splunk_hec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elisha Mawson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-29 00:00:00.000000000 Z
11
+ date: 2024-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core-plugin-api