logstash-output-loggly 0.1.4 → 2.0.0

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
  SHA1:
3
- metadata.gz: aa7dec5eae9b97c811cad614e5077858b62db8fa
4
- data.tar.gz: f7dc0c10c7758d5e0f17e3f0f603cd447a48d6ef
3
+ metadata.gz: 70c1e136a9f7ea7a6739d2c93d08d1874fda32d4
4
+ data.tar.gz: ce562168124bf4137dd0e3a90c7e3c0bb7facbcf
5
5
  SHA512:
6
- metadata.gz: b1a9e7a8ec2fc9a8807488234c79eb8dd5960a9a3dfc2badc1b5eaf227d1548aa2ce67e9759273a99e86b31779837299afa52b9f3aa20955f5e2724c7f04e21b
7
- data.tar.gz: fef1b99e42ebb35fe8fab94f6ac8e82a4ba559772dfe09d5c1041678d6091af287a1179fdf6e22947a77ac23b56649dd7737d0f8dcc1759a518907e163ca63a4
6
+ metadata.gz: 7b238ed543f8d34c700b4b84d3d20e359957bd00f7a99b6e6a7207411ccf1c0e28b61edaa9082d46e4a679da52ea3b9b8f7002027158bca38d505456fae52767
7
+ data.tar.gz: 1064d4d6922999d88c48f98c161bfe2cd7fba0f4b56d242536541fa4c749efefcc6c19821372589db24760569dca640ee35520086fd66dc77e2708d95076e469
data/CHANGELOG.md ADDED
File without changes
data/NOTICE.TXT ADDED
@@ -0,0 +1,5 @@
1
+ Elasticsearch
2
+ Copyright 2012-2015 Elasticsearch
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
data/README.md CHANGED
@@ -1,19 +1,19 @@
1
1
  # Logstash Plugin
2
2
 
3
- This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
3
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
4
4
 
5
5
  It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
6
6
 
7
7
  ## Documentation
8
8
 
9
- Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elasticsearch.org/guide/en/logstash/current/).
9
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
10
10
 
11
11
  - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
12
- - For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
12
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
13
13
 
14
14
  ## Need Help?
15
15
 
16
- Need help? Try #logstash on freenode IRC or the logstash-users@googlegroups.com mailing list.
16
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
17
17
 
18
18
  ## Developing
19
19
 
@@ -83,4 +83,4 @@ Programming is not a required skill. Whatever you've seen about open source and
83
83
 
84
84
  It is more important to the community that you are able to contribute.
85
85
 
86
- For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
86
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -29,8 +29,10 @@ class LogStash::Outputs::Loggly < LogStash::Outputs::Base
29
29
  config_name "loggly"
30
30
 
31
31
  # The hostname to send logs to. This should target the loggly http input
32
- # server which is usually "logs.loggly.com"
33
- config :host, :validate => :string, :default => "logs.loggly.com"
32
+ # server which is usually "logs-01.loggly.com" (Gen2 account).
33
+ # See Loggly HTTP endpoint documentation at
34
+ # https://www.loggly.com/docs/http-endpoint/
35
+ config :host, :validate => :string, :default => "logs-01.loggly.com"
34
36
 
35
37
  # The loggly http input key to send to.
36
38
  # This is usually visible in the Loggly 'Inputs' page as something like this:
@@ -47,6 +49,16 @@ class LogStash::Outputs::Loggly < LogStash::Outputs::Base
47
49
  # Should the log action be sent over https instead of plain http
48
50
  config :proto, :validate => :string, :default => "http"
49
51
 
52
+ # Loggly Tag
53
+ # Tag helps you to find your logs in the Loggly dashboard easily
54
+ # You can make a search in Loggly using tag as "tag:logstash-contrib"
55
+ # or the tag set by you in the config file.
56
+ #
57
+ # You can use %{somefield} to allow for custom tag values.
58
+ # Helpful for leveraging Loggly source groups.
59
+ # https://www.loggly.com/docs/source-groups/
60
+ config :tag, :validate => :string, :default => "logstash"
61
+
50
62
  # Proxy Host
51
63
  config :proxy_host, :validate => :string
52
64
 
@@ -74,21 +86,48 @@ class LogStash::Outputs::Loggly < LogStash::Outputs::Base
74
86
  return
75
87
  end
76
88
 
77
- # Send the event over http.
78
- url = URI.parse("#{@proto}://#{@host}/inputs/#{event.sprintf(@key)}")
89
+ key = event.sprintf(@key)
90
+ tag = event.sprintf(@tag)
91
+
92
+ # For those cases where %{somefield} doesn't exist
93
+ # we should ship logs with the default tag value.
94
+ tag = 'logstash' if /^%{\w+}/.match(tag)
95
+
96
+ # Send event
97
+ send_event("#{@proto}://#{@host}/inputs/#{key}/tag/#{tag}", format_message(event))
98
+ end # def receive
99
+
100
+ public
101
+ def format_message(event)
102
+ event.to_json
103
+ end
104
+
105
+ private
106
+ def send_event(url, message)
107
+ url = URI.parse(url)
79
108
  @logger.info("Loggly URL", :url => url)
80
- http = Net::HTTP::Proxy(@proxy_host, @proxy_port, @proxy_user, @proxy_password.value).new(url.host, url.port)
109
+
110
+ http = Net::HTTP::Proxy(@proxy_host,
111
+ @proxy_port,
112
+ @proxy_user,
113
+ @proxy_password.value).new(url.host, url.port)
114
+
81
115
  if url.scheme == 'https'
82
116
  http.use_ssl = true
83
117
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
84
118
  end
119
+
120
+ # post message
85
121
  request = Net::HTTP::Post.new(url.path)
86
- request.body = event.to_json
122
+ request.body = message
87
123
  response = http.request(request)
124
+
88
125
  if response.is_a?(Net::HTTPSuccess)
89
126
  @logger.info("Event send to Loggly OK!")
90
127
  else
91
128
  @logger.warn("HTTP error", :error => response.error!)
92
129
  end
93
- end # def receive
130
+ end # def send_event
131
+
94
132
  end # class LogStash::Outputs::Loggly
133
+
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-loggly'
4
- s.version = '0.1.4'
4
+ s.version = '2.0.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Got a loggly account? Use logstash to ship logs to Loggly!"
7
7
  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 gemname. This gem is not a stand-alone program"
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.require_paths = ["lib"]
12
12
 
13
13
  # Files
14
- s.files = `git ls-files`.split($\)+::Dir.glob('vendor/*')
14
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
15
15
 
16
16
  # Tests
17
17
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
@@ -20,8 +20,9 @@ Gem::Specification.new do |s|
20
20
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
21
21
 
22
22
  # Gem dependencies
23
- s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
23
+ s.add_runtime_dependency "logstash-core", "~> 2.0.0.snapshot"
24
24
 
25
25
  s.add_development_dependency 'logstash-devutils'
26
+ s.add_development_dependency 'logstash-codec-plain'
26
27
  end
27
28
 
@@ -1 +1,65 @@
1
- require "logstash/devutils/rspec/spec_helper"
1
+ # encoding: utf-8
2
+ require 'logstash/devutils/rspec/spec_helper'
3
+ require 'logstash/outputs/loggly'
4
+
5
+ describe 'outputs/loggly' do
6
+ let(:config) { { 'key' => 'abcdef123456' } }
7
+
8
+ let(:event) do
9
+ LogStash::Event.new(
10
+ 'message' => 'fanastic log entry',
11
+ 'source' => 'someapp',
12
+ 'type' => 'nginx',
13
+ '@timestamp' => LogStash::Timestamp.now)
14
+ end
15
+
16
+ context 'when initializing' do
17
+ subject { LogStash::Outputs::Loggly.new(config) }
18
+
19
+ it 'should register' do
20
+ expect { subject.register }.to_not raise_error
21
+ end
22
+
23
+ it 'should have default config values' do
24
+ insist { subject.proto } == 'http'
25
+ insist { subject.host } == 'logs-01.loggly.com'
26
+ insist { subject.tag } == 'logstash'
27
+ end
28
+ end
29
+
30
+ context 'when outputting messages' do
31
+ it 'should support field interpolation on key' do
32
+ # add a custom key value for Loggly config
33
+ event['token'] = 'xxxxxxx1234567'
34
+ config['key'] = '%{token}'
35
+
36
+ output = LogStash::Outputs::Loggly.new(config)
37
+ allow(output).to receive(:send_event).with('http://logs-01.loggly.com/inputs/xxxxxxx1234567/tag/logstash',
38
+ event.to_json)
39
+ output.receive(event)
40
+ end
41
+
42
+ it 'should set the default tag to logstash' do
43
+ output = LogStash::Outputs::Loggly.new(config)
44
+ allow(output).to receive(:send_event).with('http://logs-01.loggly.com/inputs/abcdef123456/tag/logstash',
45
+ event.to_json)
46
+ output.receive(event)
47
+ end
48
+
49
+ it 'should support field interpolation for tag' do
50
+ config['tag'] = '%{source}'
51
+ output = LogStash::Outputs::Loggly.new(config)
52
+ allow(output).to receive(:send_event).with('http://logs-01.loggly.com/inputs/abcdef123456/tag/someapp',
53
+ event.to_json)
54
+ output.receive(event)
55
+ end
56
+
57
+ it 'should default tag to logstash if interpolated field does not exist' do
58
+ config['tag'] = '%{foobar}'
59
+ output = LogStash::Outputs::Loggly.new(config)
60
+ allow(output).to receive(:send_event).with('http://logs-01.loggly.com/inputs/abcdef123456/tag/logstash',
61
+ event.to_json)
62
+ output.receive(event)
63
+ end
64
+ end
65
+ end
metadata CHANGED
@@ -1,64 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-loggly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-20 00:00:00.000000000 Z
11
+ date: 2015-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- requirement: !ruby/object:Gem::Requirement
14
+ name: logstash-core
15
+ version_requirements: !ruby/object:Gem::Requirement
15
16
  requirements:
16
- - - '>='
17
+ - - ~>
17
18
  - !ruby/object:Gem::Version
18
- version: 1.4.0
19
- - - <
19
+ version: 2.0.0.snapshot
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ~>
20
23
  - !ruby/object:Gem::Version
21
- version: 2.0.0
22
- name: logstash-core
24
+ version: 2.0.0.snapshot
23
25
  prerelease: false
24
26
  type: :runtime
27
+ - !ruby/object:Gem::Dependency
28
+ name: logstash-devutils
25
29
  version_requirements: !ruby/object:Gem::Requirement
26
30
  requirements:
27
31
  - - '>='
28
32
  - !ruby/object:Gem::Version
29
- version: 1.4.0
30
- - - <
31
- - !ruby/object:Gem::Version
32
- version: 2.0.0
33
- - !ruby/object:Gem::Dependency
33
+ version: '0'
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
36
36
  - - '>='
37
37
  - !ruby/object:Gem::Version
38
38
  version: '0'
39
- name: logstash-devutils
40
39
  prerelease: false
41
40
  type: :development
41
+ - !ruby/object:Gem::Dependency
42
+ name: logstash-codec-plain
42
43
  version_requirements: !ruby/object:Gem::Requirement
43
44
  requirements:
44
45
  - - '>='
45
46
  - !ruby/object:Gem::Version
46
47
  version: '0'
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ prerelease: false
54
+ type: :development
47
55
  description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
48
56
  email: info@elastic.co
49
57
  executables: []
50
58
  extensions: []
51
59
  extra_rdoc_files: []
52
60
  files:
53
- - .gitignore
61
+ - lib/logstash/outputs/loggly.rb
62
+ - spec/outputs/loggly_spec.rb
63
+ - logstash-output-loggly.gemspec
64
+ - CHANGELOG.md
65
+ - README.md
54
66
  - CONTRIBUTORS
55
67
  - Gemfile
56
68
  - LICENSE
57
- - README.md
58
- - Rakefile
59
- - lib/logstash/outputs/loggly.rb
60
- - logstash-output-loggly.gemspec
61
- - spec/outputs/loggly_spec.rb
69
+ - NOTICE.TXT
62
70
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
63
71
  licenses:
64
72
  - Apache License (2.0)
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- Gemfile.lock
3
- .bundle
4
- vendor
data/Rakefile DELETED
@@ -1,7 +0,0 @@
1
- @files=[]
2
-
3
- task :default do
4
- system("rake -T")
5
- end
6
-
7
- require "logstash/devutils/rake"