logstash-filter-weblookup 0.1.0 → 0.1.1
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 +4 -4
- data/lib/logstash/filters/weblookup.rb +28 -12
- data/logstash-filter-weblookup.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c96b1c02dc9936abcbed2834158d6df2d37b65423b92e0ddc0fb676b77c4b00
|
4
|
+
data.tar.gz: 49283b96b0ab8c0f00638c965897e01c0a6f29d8a413b7275bbe650c804849fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fba0a7b28e64f24b4cc9733a161a7a368579edc0f0de2317992ee530811c196d11bef2f8fc2a328745f7c9b7cb531748d27f4632486171659f3fecfb0c0f5f26
|
7
|
+
data.tar.gz: 50517ea043a5b254db9e74ffed413d2cdaf0f6b4c3bb3ee1ce3890288b69be7fc1bc9591b50fec9649f49b18d96b99fe6d3df73673194060bcba44f4ce51179f
|
@@ -42,7 +42,11 @@ class LogStash::Filters::Webookup < LogStash::Filters::Base
|
|
42
42
|
config :use_redis, :validate => :boolean, :required => false, :default => false
|
43
43
|
config :redis_path, :validate => :string, :required => false
|
44
44
|
config :redis_expiry, :validate => :number, :required => false, :default => 604800
|
45
|
+
|
46
|
+
# Optional simplify the message by moving a field to be the new root of the message
|
45
47
|
config :normalize, :validate => :boolean, :required => false, :default => false
|
48
|
+
config :newroot, :validate => :string, :required => false
|
49
|
+
config :roottostrip, :validate => :string, :required => false
|
46
50
|
|
47
51
|
HTTP_OPTIONS = {
|
48
52
|
keep_alive_timeout: 300
|
@@ -68,6 +72,7 @@ def register
|
|
68
72
|
@logger.error("Configuration error, there must be an equal amount of destinations and fields, defaulting to using the field as a root for the new values. e.g. if the lookup is done on the value of [\"ClientIP\"] the destination will be [\"ClientIP\"][\"Key\"]")
|
69
73
|
destinations=fields
|
70
74
|
end
|
75
|
+
# add case destination is empty to put the result in under the same field
|
71
76
|
end
|
72
77
|
|
73
78
|
# http connectionpool
|
@@ -79,7 +84,7 @@ def register
|
|
79
84
|
# find the key where the value is <item>, otherwise just use the value
|
80
85
|
@params = @uri.query_values(Hash)
|
81
86
|
@params.each do |key, value|
|
82
|
-
if value
|
87
|
+
if value == "\<item\>"
|
83
88
|
@ip=key
|
84
89
|
@params.delete(key)
|
85
90
|
logger.info("the ip key in the uri is #{@ip}")
|
@@ -107,6 +112,9 @@ def filter(event)
|
|
107
112
|
event.set("["+destinations[index]+"]", json)
|
108
113
|
end
|
109
114
|
end
|
115
|
+
if @normalize
|
116
|
+
replant(event, @newroot)
|
117
|
+
end
|
110
118
|
# filter_matched should go in the last line of our successful code
|
111
119
|
filter_matched(event)
|
112
120
|
end # def filter
|
@@ -152,29 +160,37 @@ def find(item)
|
|
152
160
|
return res
|
153
161
|
end
|
154
162
|
|
163
|
+
# for legacy
|
155
164
|
def normalize(event)
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
165
|
+
event.set("net", JSON.parse(net))
|
166
|
+
event.get("[records][properties]").each {|k, v| event.set(k, v) }
|
167
|
+
event.remove("[records]")
|
168
|
+
event.remove("[message]")
|
169
|
+
return event
|
170
|
+
end
|
171
|
+
|
172
|
+
def replant(event, newroot)
|
173
|
+
@logger.debug("event: #{event.get(newroot)}")
|
174
|
+
event.get(newroot).each {|k, v| event.set(k, v) }
|
175
|
+
event.remove(@roottostrip)
|
176
|
+
return event
|
161
177
|
end
|
162
178
|
|
163
179
|
# From https://github.com/angel9484/logstash-filter-lookup
|
164
|
-
|
180
|
+
def json_loader(data)
|
165
181
|
get_map.merge!(JSON.parse(File.read(data)))
|
166
|
-
|
182
|
+
end
|
167
183
|
|
168
|
-
|
184
|
+
def csv_loader(data)
|
169
185
|
data = CSV.read(data).inject(Hash.new) do |acc, v|
|
170
186
|
acc[v[0]] = v[1]
|
171
187
|
acc
|
172
188
|
end
|
173
189
|
get_map.merge!(data)
|
174
|
-
|
190
|
+
end
|
175
191
|
|
176
|
-
|
192
|
+
def yml_loader(data)
|
177
193
|
get_map.merge!(YAML.load_file(data))
|
178
|
-
|
194
|
+
end
|
179
195
|
|
180
196
|
end # class LogStash::Filters::Lookup
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-filter-weblookup'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.1'
|
4
4
|
s.licenses = ['Apache-2.0']
|
5
5
|
s.summary = 'This logstash filter plugin takes one or more fields and enriches with a lookup value from a list, redis cache or webservice'
|
6
6
|
s.description = <<-EOF
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-weblookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Geertsma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|