rack-logstash-writer 1.0.8 → 1.0.9

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
  SHA1:
3
- metadata.gz: 2834072c7db69eee168bf9e594ab769700e5c5bc
4
- data.tar.gz: 4ce942aa199028576f30d3835837e2e41577b662
3
+ metadata.gz: e3aada1afff771015b494f076de19c83084bb21e
4
+ data.tar.gz: 452c8a19da077cbc514e6215248aa76f6bf019b4
5
5
  SHA512:
6
- metadata.gz: 5e60cec96a27abb6bcde2e7af3f3a9013cb2d9c16eaff20211bd5e4e7766d4a927f288cb34bfa6d4af2dfe52b5cbc912ed26b87fafb11b890d94a9ddd3606272
7
- data.tar.gz: 851ff915b6f8e7b79b6614205221f4c46bf05f57dfe5b6c25d70955cd8b8524ebc1f4d33058c8d1dee4de653e4a9aecce39304ae1edefacc9eea461b0ae2cda4
6
+ metadata.gz: 780f10c76e20bd779caf400aedf518b472e41557f617cbb8d3369630f3533ead53e382f329abbf666a60554146b722db5743c5603f7f78f48a2fe47c6a9626fd
7
+ data.tar.gz: 5ac34507e109f17f643803f81d87974524e5adea95dda42d58d5298991fa689cdb2ff20ae969ea3b60ab61513a19d5b046902bf699064f99e8ed1e563e192f96
@@ -15,22 +15,14 @@ class JSONServerError
15
15
  end
16
16
  end
17
17
 
18
- prc = Proc.new do |env|
19
- data = {}
20
- if env["REMOTE_HOST"] =='localhost'
21
- soc = Socket.ip_address_list.map {|s| s.ip_address}.reject {|s| s=='127.0.0.1'}.select {|s| 16 >(s.size) && (s.size)>10}.first
22
- data[:host] = "ip-#{soc.gsub(".","-")}"
23
- end
24
- data[:service_name] = Dir.pwd.split("/").last
25
- data
26
- end
18
+ proc {|env| {service: Dir.pwd.split("/").last}}
27
19
 
28
20
  use Rack::LogstashWriter , {url: "file:///home/org/Desktop/logsample", # or another examples "udp://localhost:5228" # "tcp://localhost:5228"
29
21
  request_headers: {'head1'=>'head1'},
30
22
  response_headers: {'head1'=>'head1'},
31
23
  statuses: [*(500..600)] ,
32
24
  body_len: 50 ,
33
- body_regex: {service_name: 'service_namev:(.*).*[,]?.*}' , proc: prc}
25
+ body_regex: {service_name: 'service_namev:(.*).*[,]?.*}' , proc: Proc.new {|env| {service: Dir.pwd.split("/").last}}}
34
26
  }
35
27
 
36
28
  map '/hello.json' do
@@ -10,7 +10,7 @@ require ::File.expand_path('../lib/sinatra', __FILE__)
10
10
  prc = Proc.new {|env| p env}
11
11
  use Rack::LogstashWriter, {url: "tcp://localhost:5228" ,statuses: [*(200..600)], body_len: 100, response_headers: {'message' => 'This-is-a-message-man'},
12
12
  request_headers: {'User-agent'=>'ua-nimrod'}, #"udp://localhost:5228" # "file:///home/org/Desktop/logsample"
13
- body_regex: {service_name: 'service_namev:(.*).*[,]?.*}' , proc: prc}
13
+ body_regex: {service_name: 'service_namev:(.*).*[,]?.*}' , proc: Proc.new {|env| {service: Dir.pwd.split("/").last}}}
14
14
  }
15
15
 
16
16
  run Sinatra::Application
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class LogstashWriter
3
- VERSION = "1.0.8"
3
+ VERSION = "1.0.9"
4
4
  end
5
5
  end
@@ -80,6 +80,11 @@ module Rack
80
80
 
81
81
  data[:error_msg] = env["sinatra.error"] if env.has_key?("sinatra.error")
82
82
 
83
+ if data[:host] =='localhost'
84
+ soc = Socket.ip_address_list.map {|s| s.ip_address}.reject {|s| s=='127.0.0.1'}.select {|s| 16 >(s.size) && (s.size)>10}.first
85
+ data[:host] = "ip-#{soc.gsub(".","-")}"
86
+ end
87
+
83
88
  @options[:body_regex].each { |k,v| data[k] = data[:body].to_s.match(/#{v}/).captures[0].gsub("\\","").gsub("\"","") rescue data[k]= "" } if !@options[:body_regex].nil?
84
89
 
85
90
  severity = "DEBUG"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-logstash-writer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - or garfunkel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-10 00:00:00.000000000 Z
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake