logstash-output-sentry 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 +4 -4
- data/README.md +73 -0
- data/lib/logstash/outputs/sentry.rb +28 -15
- data/logstash-output-sentry.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54c19ff3430ad6d13ff04e3c2e5a58a30c6ad287
|
4
|
+
data.tar.gz: cf9c838f8a464bdccd64b2e17dfbb54291f85909
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 813f2ee9004e7ce6dff127d48965182f27a6847d7612718f86db8df653f405f10456bbe6504447d38ebe2d706d19f051a69bee264636244621955aa07ca83621
|
7
|
+
data.tar.gz: 7323fd8ddfa2141e1e40cb9b348765918c2b9513b79a7c7bc1e62ec913261cd4744e2c2c63ea9f38d69b7ec83bb0aae7a67bbedfba3dd3de16289ea35f49d1dc
|
data/README.md
CHANGED
@@ -97,6 +97,79 @@ sentry {
|
|
97
97
|
}
|
98
98
|
```
|
99
99
|
|
100
|
+
* You can also set the project id, key, level tag, and secret in a filter to allow for a cleaner dynamic config
|
101
|
+
```ruby
|
102
|
+
input {
|
103
|
+
syslog {
|
104
|
+
port => 514
|
105
|
+
type => "syslog"
|
106
|
+
}
|
107
|
+
|
108
|
+
tcp {
|
109
|
+
port => 1514
|
110
|
+
type => "cisco-ios"
|
111
|
+
}
|
112
|
+
|
113
|
+
tcp {
|
114
|
+
port => 2514
|
115
|
+
type => "application"
|
116
|
+
}
|
117
|
+
}
|
118
|
+
filter {
|
119
|
+
if [type] == "syslog" {
|
120
|
+
mutate {
|
121
|
+
add_field => {
|
122
|
+
"[@metadata][sentry][msg]" => "%{host}"
|
123
|
+
"[@metadata][sentry][severity]" => "%{severity}"
|
124
|
+
"[@metadata][sentry][host]" => "192.168.1.101"
|
125
|
+
"[@metadata][sentry][pid]" => "2"
|
126
|
+
"[@metadata][sentry][key]" => "d3921923d34a4344878f7b83e2061229"
|
127
|
+
"[@metadata][sentry][secret]" => "d0163ef306c04148aee49fe4ce7621b1"
|
128
|
+
}
|
129
|
+
}
|
130
|
+
}
|
131
|
+
else if [type] == "cisco-ios" {
|
132
|
+
mutate {
|
133
|
+
add_field => {
|
134
|
+
"[@metadata][sentry][msg]" => "%{host}"
|
135
|
+
"[@metadata][sentry][severity]" => "%{severity}"
|
136
|
+
"[@metadata][sentry][host]" => "192.168.1.101"
|
137
|
+
"[@metadata][sentry][pid]" => "3"
|
138
|
+
"[@metadata][sentry][key]" => "d398098q2349883e206178098"
|
139
|
+
"[@metadata][sentry][secret]" => "da098d890f098d09809f6098c87e0"
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
else if [type] == "application" {
|
144
|
+
mutate {
|
145
|
+
add_field => {
|
146
|
+
"[@metadata][sentry][msg]" => "%{host}"
|
147
|
+
"[@metadata][sentry][severity]" => "%{severity}"
|
148
|
+
"[@metadata][sentry][host]" => "192.168.1.150"
|
149
|
+
"[@metadata][sentry][pid]" => "4"
|
150
|
+
"[@metadata][sentry][key]" => "d39dc435326d987d5678e98d76cf78098"
|
151
|
+
"[@metadata][sentry][secret]" => "07d09876d543d2a345e43c4e567d"
|
152
|
+
}
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
output {
|
157
|
+
elasticsearch {
|
158
|
+
hosts => ["192.168.1.200:9200"]
|
159
|
+
document_type => "%{type}"
|
160
|
+
}
|
161
|
+
sentry {
|
162
|
+
fields_to_tags => true
|
163
|
+
host => "%{[@metadata][sentry][host]}"
|
164
|
+
key => "%{[@metadata][sentry][key]}"
|
165
|
+
level_tag => "%{[@metadata][sentry][severity]}"
|
166
|
+
msg => "[@metadata][sentry][msg]"
|
167
|
+
project_id => "%{[@metadata][sentry][pid]}"
|
168
|
+
secret => "%{[@metadata][sentry][secret]}"
|
169
|
+
}
|
170
|
+
}
|
171
|
+
```
|
172
|
+
|
100
173
|
## Contributing
|
101
174
|
|
102
175
|
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
@@ -34,8 +34,8 @@ class LogStash::Outputs::Sentry < LogStash::Outputs::Base
|
|
34
34
|
# This sets the message value in Sentry (the title of your event)
|
35
35
|
config :msg, :validate => :string, :default => 'Message from logstash', :required => false
|
36
36
|
|
37
|
-
# This sets the level value in Sentry (the level tag)
|
38
|
-
config :level_tag, :validate => :string, :default => 'error'
|
37
|
+
# This sets the level value in Sentry (the level tag), allow usage of event dynamic value
|
38
|
+
config :level_tag, :validate => :string, :default => 'error'
|
39
39
|
|
40
40
|
# If set to true automatically map all logstash defined fields to Sentry extra fields.
|
41
41
|
# As an example, the logstash event:
|
@@ -67,21 +67,34 @@ class LogStash::Outputs::Sentry < LogStash::Outputs::Base
|
|
67
67
|
|
68
68
|
public
|
69
69
|
def register
|
70
|
-
|
71
|
-
require '
|
70
|
+
#I took this out becuase it fails when I try sending in the project_id or host as part of the event for a dynamic config
|
71
|
+
# require 'net/https'
|
72
|
+
# require 'uri'
|
72
73
|
|
73
|
-
@url = "%{proto}://#{host}/api/#{project_id}/store/" % { :proto => use_ssl ? 'https' : 'http' }
|
74
|
-
@uri = URI.parse(@url)
|
74
|
+
# @url = "%{proto}://#{host}/api/#{project_id}/store/" % { :proto => use_ssl ? 'https' : 'http' }
|
75
|
+
# @uri = URI.parse(@url)
|
75
76
|
|
76
|
-
@client = Net::HTTP.new(@uri.host, @uri.port)
|
77
|
-
@client.use_ssl = use_ssl
|
78
|
-
@client.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
77
|
+
# @client = Net::HTTP.new(@uri.host, @uri.port)
|
78
|
+
# @client.use_ssl = use_ssl
|
79
|
+
# @client.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
79
80
|
|
80
|
-
@logger.debug('Client', :client => @client.inspect)
|
81
|
+
# @logger.debug('Client', :client => @client.inspect)
|
81
82
|
end
|
82
83
|
|
83
84
|
public
|
84
85
|
def receive(event)
|
86
|
+
require 'net/https'
|
87
|
+
require 'uri'
|
88
|
+
|
89
|
+
url = "%{proto}://#{event.sprintf(@host)}/api/#{event.sprintf(@project_id)}/store/" % { :proto => use_ssl ? 'https' : 'http' }
|
90
|
+
uri = URI.parse(url)
|
91
|
+
|
92
|
+
client = Net::HTTP.new(uri.host, uri.port)
|
93
|
+
client.use_ssl = use_ssl
|
94
|
+
client.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
95
|
+
|
96
|
+
@logger.debug('Client', :client => client.inspect)
|
97
|
+
|
85
98
|
return unless output?(event)
|
86
99
|
|
87
100
|
require 'securerandom'
|
@@ -98,7 +111,7 @@ class LogStash::Outputs::Sentry < LogStash::Outputs::Base
|
|
98
111
|
:event_id => SecureRandom.uuid.gsub('-', ''),
|
99
112
|
:timestamp => event['@timestamp'],
|
100
113
|
:message => message_to_send,
|
101
|
-
:level =>
|
114
|
+
:level => event.sprintf(@level_tag),
|
102
115
|
:platform => 'logstash',
|
103
116
|
:server_name => event['host'],
|
104
117
|
:extra => event.to_hash,
|
@@ -113,16 +126,16 @@ class LogStash::Outputs::Sentry < LogStash::Outputs::Base
|
|
113
126
|
auth_header = "Sentry sentry_version=5," +
|
114
127
|
"sentry_client=raven_logstash/1.0," +
|
115
128
|
"sentry_timestamp=#{event['@timestamp'].to_i}," +
|
116
|
-
"sentry_key=#{@key}," +
|
117
|
-
"sentry_secret=#{@secret}"
|
129
|
+
"sentry_key=#{event.sprintf(@key)}," +
|
130
|
+
"sentry_secret=#{event.sprintf(@secret)}"
|
118
131
|
|
119
|
-
|
132
|
+
request = Net::HTTP::Post.new(uri.path)
|
120
133
|
|
121
134
|
begin
|
122
135
|
request.body = packet.to_json
|
123
136
|
request.add_field('X-Sentry-Auth', auth_header)
|
124
137
|
|
125
|
-
response =
|
138
|
+
response = client.request(request)
|
126
139
|
|
127
140
|
@logger.info('Sentry response', :request => request.inspect, :response => response.inspect)
|
128
141
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-sentry'
|
3
|
-
s.version = '0.3.
|
3
|
+
s.version = '0.3.1'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = 'This output plugin sends messages to any sentry server.'
|
6
6
|
s.description = 'This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install logstash-output-sentry. This gem is not a stand-alone program.'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-sentry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Matos Odut
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.5.1
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: This output plugin sends messages to any sentry server.
|