logstash-input-meetup 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d9399dae488829c823f32540cccd360732d0f3d1
4
+ data.tar.gz: e93fd5ae05f203222e7c56286afae5a7dc7bee08
5
+ SHA512:
6
+ metadata.gz: 8171b4a9fc6e5fa96188541b0252d294a9d8653c8131d06b4ffbfb8b956488f92a4fff4574eef7eb7e074d27123fdf30eb5f2c96a23abc762f6f6f89a620b55a
7
+ data.tar.gz: ed0f71607dc3cfd998baa947667012fb7ed4fbfb2d3b7b17fc5213426ca48dfd5b2c38e0dd78483acad9a24da2771951b73b34e0d73533c31877b7fc9e78a0e6
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+ gem "logstash", :github => "elasticsearch/logstash", :branch => "1.5"
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012-2014 Elasticsearch <http://www.elasticsearch.org>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ @files=[]
2
+
3
+ task :default do
4
+ system("rake -T")
5
+ end
6
+
7
+ require "logstash/devutils/rake"
@@ -0,0 +1,88 @@
1
+ # encoding: utf-8
2
+ require "logstash/inputs/base"
3
+ require "logstash/namespace"
4
+ require "socket" # for Socket.gethostname
5
+
6
+ # Run command line tools and capture the whole output as an event.
7
+ #
8
+ # Notes:
9
+ #
10
+ # * The `@source` of this event will be the command run.
11
+ # * The `@message` of this event will be the entire stdout of the command
12
+ # as one event.
13
+ #
14
+ class LogStash::Inputs::Meetup < LogStash::Inputs::Base
15
+
16
+ config_name "meetup"
17
+ milestone 1
18
+
19
+ # URLName - the URL name ie `ElasticSearch-Oklahoma-City`
20
+ # Must have one of urlname, venue_id, group_id
21
+ config :urlname, :validate => :string
22
+
23
+ # The venue ID
24
+ # Must have one of `urlname`, `venue_id`, `group_id`
25
+ config :venueid, :validate => :string
26
+
27
+ # The Group ID, multiple may be specified seperated by commas
28
+ # Must have one of `urlname`, `venueid`, `groupid`
29
+ config :groupid, :validate => :string
30
+
31
+ # Interval to run the command. Value is in seconds.
32
+ config :interval, :validate => :number, :required => true
33
+
34
+ # Meetup Key
35
+ config :meetupkey, :validate => :string, :required => true
36
+
37
+ # Event Status'
38
+ config :eventstatus, :validate => :string, :default => "upcoming,past"
39
+
40
+ public
41
+ def register
42
+ require "faraday"
43
+ # group_id
44
+ if groupid
45
+ addon = "group_id=#{ @groupid }"
46
+ # group_urlname
47
+ elsif urlname
48
+ addon = "group_urlname=#{ @urlname }"
49
+ # venue_id
50
+ elsif venueid
51
+ addon = "venue_id=#{ @venueid }"
52
+ else
53
+ # None Selected, raise an error
54
+ addon = ""
55
+ end
56
+ @url = "https://api.meetup.com/2/events.json?key=#{ @meetupkey }&status=#{ @eventstatus }&#{ addon }"
57
+ @logger.info("Registering meetup Input", :url => @url, :interval => @interval)
58
+ end # def register
59
+
60
+ public
61
+ def run(queue)
62
+ Stud.interval(@interval*60) do
63
+ start = Time.now
64
+ @logger.info? && @logger.info("Polling meetup", :url => @url)
65
+
66
+ # Pull down the RSS feed using FTW so we can make use of future cache functions
67
+ response = Faraday.get @url
68
+ result = JSON.parse(response.body)
69
+
70
+ result["results"].each do |rawevent|
71
+ event = LogStash::Event.new(rawevent)
72
+ # Convert the timestamps into Ruby times
73
+ event['created'] = Time.at(event['created'] / 1000, (event['created'] % 1000) * 1000).utc
74
+ event['time'] = Time.at(event['time'] / 1000, (event['time'] % 1000) * 1000).utc
75
+ event['group']['created'] = Time.at(event['group']['created'] / 1000, (event['group']['created'] % 1000) * 1000).utc
76
+ event['updated'] = Time.at(event['updated'] / 1000, (event['updated'] % 1000) * 1000).utc
77
+ event['venue']['lonlat'] = [event['venue']['lon'],event['venue']['lat']] if rawevent.has_key?('venue')
78
+ event['group']['lonlat'] = [event['group']['group_lon'],event['group']['group_lat']] if rawevent.has_key?('group')
79
+ decorate(event)
80
+ queue << event
81
+ end
82
+
83
+ duration = Time.now - start
84
+ @logger.info? && @logger.info("poll completed", :command => @command,
85
+ :duration => duration)
86
+ end # loop
87
+ end # def run
88
+ end # class LogStash::Inputs::Exec
@@ -0,0 +1,29 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'logstash-input-meetup'
4
+ s.version = '0.1.1'
5
+ s.licenses = ['Apache License (2.0)']
6
+ s.summary = "Query and pull events from meetup groups."
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"
8
+ s.authors = ["Elasticsearch"]
9
+ s.email = 'jason.kendall@elasticsearch.com'
10
+ s.homepage = "http://www.elasticsearch.org/guide/en/logstash/current/index.html"
11
+ s.require_paths = ["lib"]
12
+
13
+ # Files
14
+ s.files = `git ls-files`.split($\)+::Dir.glob('vendor/*')
15
+
16
+ # Tests
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+
19
+ # Special flag to let us know this is actually a logstash plugin
20
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
21
+
22
+ # Gem dependencies
23
+ s.add_runtime_dependency 'logstash', '>= 1.4.0', '< 2.0.0'
24
+
25
+ s.add_runtime_dependency 'addressable'
26
+
27
+ s.add_development_dependency 'logstash-devutils'
28
+ end
29
+
@@ -0,0 +1 @@
1
+ # Empty
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-input-meetup
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Elasticsearch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logstash
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.4.0
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.0
23
+ requirement: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: 1.4.0
28
+ - - <
29
+ - !ruby/object:Gem::Version
30
+ version: 2.0.0
31
+ prerelease: false
32
+ type: :runtime
33
+ - !ruby/object:Gem::Dependency
34
+ name: addressable
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirement: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ prerelease: false
46
+ type: :runtime
47
+ - !ruby/object:Gem::Dependency
48
+ name: logstash-devutils
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ prerelease: false
60
+ type: :development
61
+ 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
62
+ email: jason.kendall@elasticsearch.com
63
+ executables: []
64
+ extensions: []
65
+ extra_rdoc_files: []
66
+ files:
67
+ - Gemfile
68
+ - LICENSE
69
+ - Rakefile
70
+ - lib/logstash/inputs/meetup.rb
71
+ - logstash-input-meetup.gemspec
72
+ - spec/inputs/meetup_spec.rb
73
+ homepage: http://www.elasticsearch.org/guide/en/logstash/current/index.html
74
+ licenses:
75
+ - Apache License (2.0)
76
+ metadata:
77
+ logstash_plugin: 'true'
78
+ logstash_group: input
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.2.2
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Query and pull events from meetup groups.
99
+ test_files:
100
+ - spec/inputs/meetup_spec.rb