logstash-input-facebook 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: eb5cb9ed962ab389db700b86f304c8c442285298a5d9e6b535337c991850a653
4
+ data.tar.gz: 47ed51e6da2747e0fb6cf37e226c66e0c8ea51d815c88e32985ee58a36321d1e
5
+ SHA512:
6
+ metadata.gz: dd901bd1afe2f4bca18625455afffca1b5295d6fdab95bcc661c64a30f98ec97b5f3df2e4554b7da8ff473fd5ebd1c861595a8ed2705c98e0a9c58b17b381fd4
7
+ data.tar.gz: a3b96af4c035a973f2a8c4145246d71243b0d63014b794c46ae8fb2e4b3958363f8ba0f7be6d44f11cac7177fb8d9fc3e22b42c06b77084e4a0b3284c7a913be
@@ -0,0 +1,2 @@
1
+ ## 0.1.0
2
+ - Plugin created with the logstash plugin generator
@@ -0,0 +1,10 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash along its way.
3
+
4
+ Contributors:
5
+ * -
6
+
7
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
8
+ Logstash, and you aren't on the list above and want to be, please let us know
9
+ and we'll make sure you're here. Contributions from folks like you are what make
10
+ open source awesome.
@@ -0,0 +1,2 @@
1
+ # logstash-input-facebook
2
+ Example input plugin. This should help bootstrap your effort to write your own input plugin!
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem 'koala', '~> 3.0'
data/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Licensed under the Apache License, Version 2.0 (the "License");
2
+ you may not use this file except in compliance with the License.
3
+ You may obtain a copy of the License at
4
+
5
+ http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
@@ -0,0 +1,86 @@
1
+ # Logstash Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
4
+
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
+
7
+ ## Documentation
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.elastic.co/guide/en/logstash/current/).
10
+
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/elastic/docs#asciidoc-guide
13
+
14
+ ## Need Help?
15
+
16
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
17
+
18
+ ## Developing
19
+
20
+ ### 1. Plugin Developement and Testing
21
+
22
+ #### Code
23
+ - To get started, you'll need JRuby with the Bundler gem installed.
24
+
25
+ - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
26
+
27
+ - Install dependencies
28
+ ```sh
29
+ bundle install
30
+ ```
31
+
32
+ #### Test
33
+
34
+ - Update your dependencies
35
+
36
+ ```sh
37
+ bundle install
38
+ ```
39
+
40
+ - Run tests
41
+
42
+ ```sh
43
+ bundle exec rspec
44
+ ```
45
+
46
+ ### 2. Running your unpublished Plugin in Logstash
47
+
48
+ #### 2.1 Run in a local Logstash clone
49
+
50
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
51
+ ```ruby
52
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
53
+ ```
54
+ - Install plugin
55
+ ```sh
56
+ bin/logstash-plugin install --no-verify
57
+ ```
58
+ - Run Logstash with your plugin
59
+ ```sh
60
+ bin/logstash -e 'filter {awesome {}}'
61
+ ```
62
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
63
+
64
+ #### 2.2 Run in an installed Logstash
65
+
66
+ You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
67
+
68
+ - Build your plugin gem
69
+ ```sh
70
+ gem build logstash-filter-awesome.gemspec
71
+ ```
72
+ - Install the plugin from the Logstash home
73
+ ```sh
74
+ bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem
75
+ ```
76
+ - Start Logstash and proceed to test the plugin
77
+
78
+ ## Contributing
79
+
80
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
81
+
82
+ Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
83
+
84
+ It is more important to the community that you are able to contribute.
85
+
86
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+ require "logstash/inputs/base"
3
+ require "logstash/namespace"
4
+ require "stud/interval"
5
+ require "socket" # for Socket.gethostname
6
+ require "koala"
7
+
8
+ # Generate a repeating message.
9
+ #
10
+ # This plugin is intented only as an example.
11
+
12
+ class LogStash::Inputs::Facebook < LogStash::Inputs::Base
13
+
14
+ config_name "facebook"
15
+
16
+ # If undefined, Logstash will complain, even if codec is unused.
17
+ default :codec, "plain"
18
+
19
+ # OAuth token to access the facebook API with
20
+ config :oauth_token, :validate => :string, :required =>true
21
+
22
+ # Set the frecuency.
23
+ config :interval, :validate => :number, :required =>true
24
+
25
+ # Facebook ID of the feed to monitor
26
+ config :facebook_id, :validate => :number, :required =>true
27
+
28
+ # Fields of the feed
29
+ config :fields , :validate => :array , :required =>true
30
+
31
+ public
32
+ def register
33
+ @api = Koala::Facebook::API.new(@oauth_token)
34
+ end # def register
35
+
36
+ def run(queue)
37
+ # we can abort the loop if stop? becomes true
38
+ while !stop?
39
+ feed = @api.get_connections(@facebook_id, "feed" , { limit: 10, fields: @fields })
40
+ feed.each do |p|
41
+ event = LogStash::Event.new(p)
42
+ decorate(event)
43
+ queue << event
44
+ end
45
+
46
+ # because the sleep interval can be big, when shutdown happens
47
+ # we want to be able to abort the sleep
48
+ # Stud.stoppable_sleep will frequently evaluate the given block
49
+ # and abort the sleep(@interval) if the return value is true
50
+ Stud.stoppable_sleep(@interval) { stop? }
51
+ end # loop
52
+ end # def run
53
+
54
+ def stop
55
+ # nothing to do in this case so it is not necessary to define stop
56
+ # examples of common "stop" tasks:
57
+ # * close sockets (unblocking blocking reads/accepts)
58
+ # * cleanup temporary files
59
+ # * terminate spawned threads
60
+ end
61
+ end # class LogStash::Inputs::Facebook
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+ require "logstash/inputs/base"
3
+ require "logstash/namespace"
4
+ require "stud/interval"
5
+ require "socket" # for Socket.gethostname
6
+ require "koala"
7
+
8
+ # Generate a repeating message.
9
+ #
10
+ # This plugin is intented only as an example.
11
+
12
+ class LogStash::Inputs::Facebook < LogStash::Inputs::Base
13
+
14
+ config_name "facebook"
15
+
16
+ # If undefined, Logstash will complain, even if codec is unused.
17
+ default :codec, "plain"
18
+
19
+ # OAuth token to access the facebook API with
20
+ config :oauth_token, :validate => :string, :required =>true
21
+
22
+ # Set the frecuency.
23
+ config :interval, :validate => :number, :required =>true
24
+
25
+ # Facebook ID of the feed to monitor
26
+ config :facebook_id, :validate => :number, :required =>true
27
+
28
+ # Fields of the feed
29
+ config :fields , :validate => :array , :required =>true
30
+
31
+ public
32
+ def register
33
+ @api = Koala::Facebook::API.new(@oauth_token)
34
+ end # def register
35
+
36
+ def run(queue)
37
+ # we can abort the loop if stop? becomes true
38
+ while !stop?
39
+ feed = @api.get_connections(@facebook_id, "feed" , { limit: 10, fields: @fields })
40
+ feed.each do |p|
41
+ event = LogStash::Event.new(p)
42
+ decorate(event)
43
+ queue << event
44
+ end
45
+
46
+ # because the sleep interval can be big, when shutdown happens
47
+ # we want to be able to abort the sleep
48
+ # Stud.stoppable_sleep will frequently evaluate the given block
49
+ # and abort the sleep(@interval) if the return value is true
50
+ Stud.stoppable_sleep(@interval) { stop? }
51
+ end # loop
52
+ end # def run
53
+
54
+ def stop
55
+ # nothing to do in this case so it is not necessary to define stop
56
+ # examples of common "stop" tasks:
57
+ # * close sockets (unblocking blocking reads/accepts)
58
+ # * cleanup temporary files
59
+ # * terminate spawned threads
60
+ end
61
+ end # class LogStash::Inputs::Facebook
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-input-facebook'
3
+ s.version = '1.0.0'
4
+ s.licenses = ['Apache-2.0']
5
+ s.summary = 'This input plugin get the data from a facebook account.'
6
+ s.description = 'This plugin get the feed data from a facebook account.'
7
+ s.homepage = 'https://github.com/felixramirezgarcia/logstash-input-facebook'
8
+ s.authors = ['Felix R G']
9
+ s.email = 'felixramirezgarcia@gmail.com'
10
+ s.require_paths = ['lib']
11
+
12
+ # Files
13
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
14
+ # Tests
15
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
16
+
17
+ # Special flag to let us know this is actually a logstash plugin
18
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
19
+
20
+ # Gem dependencies
21
+ s.add_runtime_dependency "logstash-core", ">= 2.0"
22
+ s.add_runtime_dependency 'logstash-codec-plain'
23
+ s.add_runtime_dependency 'stud', '>= 0.0.22'
24
+ s.add_development_dependency 'logstash-devutils', '>= 0.0.16'
25
+ s.add_runtime_dependency 'koala', '~> 2.4'
26
+
27
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
3
+ require "logstash/inputs/facebook"
4
+
5
+ describe LogStash::Inputs::Facebook do
6
+
7
+ it_behaves_like "an interruptible input plugin" do
8
+ let(:config) { { "interval" => 100 } }
9
+ end
10
+
11
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-input-facebook
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Felix R G
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '2.0'
19
+ name: logstash-core
20
+ prerelease: false
21
+ type: :runtime
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ name: logstash-codec-plain
34
+ prerelease: false
35
+ type: :runtime
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.0.22
47
+ name: stud
48
+ prerelease: false
49
+ type: :runtime
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.22
55
+ - !ruby/object:Gem::Dependency
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 0.0.16
61
+ name: logstash-devutils
62
+ prerelease: false
63
+ type: :development
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.16
69
+ - !ruby/object:Gem::Dependency
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '2.4'
75
+ name: koala
76
+ prerelease: false
77
+ type: :runtime
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.4'
83
+ description: This plugin get the feed data from a facebook account.
84
+ email: felixramirezgarcia@gmail.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - CHANGELOG.md
90
+ - CONTRIBUTORS
91
+ - DEVELOPER.md
92
+ - Gemfile
93
+ - LICENSE
94
+ - README.md
95
+ - lib/logstash/inputs/facebook.rb
96
+ - lib/logstash/inputs/facebook.rb.bk
97
+ - logstash-input-facebook.gemspec
98
+ - spec/inputs/facebook_spec.rb
99
+ homepage: https://github.com/felixramirezgarcia/logstash-input-facebook
100
+ licenses:
101
+ - Apache-2.0
102
+ metadata:
103
+ logstash_plugin: 'true'
104
+ logstash_group: input
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.6.13
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: This input plugin get the data from a facebook account.
125
+ test_files:
126
+ - spec/inputs/facebook_spec.rb