logstash-input-algolialogs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4b7b99381d1d66c005b7cbdf39e0ea8c557228ef
4
+ data.tar.gz: 1d1cd13d1e3b75a00ed472d542c57eb92a5a3ee0
5
+ SHA512:
6
+ metadata.gz: a55afe4032aadef7e04ce1d2956b3c3d4b15f8eedc73a53e7fec46f81a76e420697029a0bf1f1ee213b0d3722c376f6709a0b37235dc67a758476c1d8f9bb00a
7
+ data.tar.gz: 67ace32bce396881d437a629ddc6d784e160379a54c88589856ade51178578ffb5f978a9b4960bc04833690133204434d44d449f615fa723e1160036e8b6b3e4
@@ -0,0 +1,2 @@
1
+ # logstash-input-example
2
+ Example input plugin. This should help bootstrap your effort to write your own input plugin!
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
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.
@@ -0,0 +1,14 @@
1
+ # Logstash Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elasticsearch/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
+ This plugin get logs from an algolia app (https://www.algolia.com/doc/rest_api#SectionLogs).
10
+
11
+ Main idea is to retrieve logs from algolia and put it in elasticsearch (or elsewhere) after some filters.
12
+ With Kibana or curiosity (https://github.com/pagesjaunes/curiosity).
13
+
14
+ See an example of [conf](https://github.com/ErwanPigneul/logstash-input-algolialogs/blob/master/logstash-input-algolialogs.conf)
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rake"
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+ require "logstash/inputs/base"
3
+ require "logstash/namespace"
4
+ require "stud/interval"
5
+
6
+ # Generate a repeating message.
7
+ #
8
+ # This plugin is intented only as an example.
9
+
10
+ class LogStash::Inputs::Algolialogs < LogStash::Inputs::Base
11
+ config_name "algolialogs"
12
+
13
+ # If undefined, Logstash will complain, even if codec is unused.
14
+ default :codec, "plain"
15
+
16
+ # The application_id of algolia cluster.
17
+ config :application_id , :validate => :string, :required => true
18
+
19
+ # The api_key of algolia cluster (must be an admin key).
20
+ config :api_key , :validate => :string, :required => true
21
+
22
+ # The size of logs to retrieve.
23
+ config :length , :validate => :number, :default => 1000
24
+
25
+ # Set how frequently messages should be sent.
26
+ #
27
+ # The default, `1`, means send a message every second.
28
+ config :interval, :validate => :number, :default => 600
29
+
30
+ public
31
+ def register
32
+ require "algoliasearch"
33
+
34
+ Algolia.init :application_id => @application_id,
35
+ :api_key => @api_key
36
+
37
+ end # def register
38
+
39
+ def run(queue)
40
+ Stud.interval(@interval) do
41
+ logs = Algolia.get_logs(0, @length, true)
42
+ for log in logs["logs"]
43
+ event = LogStash::Event.new(log)
44
+ decorate(event)
45
+ queue << event
46
+ end
47
+ end # loop
48
+ end # def run
49
+
50
+ end # class LogStash::Inputs::Example
@@ -0,0 +1,56 @@
1
+ input {
2
+ algolialogs {
3
+ application_id => "YOUR_APPID"
4
+ api_key => "YOUR_APIKEY"
5
+ length => 1000
6
+ interval => 60
7
+ }
8
+ }
9
+
10
+ filter {
11
+
12
+ # add geoip informations
13
+ geoip {
14
+ source => "ip"
15
+ }
16
+
17
+ # transform params to be searchable
18
+ ruby {
19
+ code => "require 'cgi'
20
+ if (event['query_params'])
21
+ event['query_params'] = CGI::parse(event['query_params'])
22
+ end"
23
+ }
24
+
25
+ # parse headers and keep just necessary
26
+ ruby {
27
+ code => "require 'net/http'
28
+ event['headers'] = {}
29
+ event['query_headers'].each_line { |line|
30
+ params = line.split(': ')
31
+ if (params[0] == 'User-Agent' || params[0] == 'Referer' || params[0] == 'Origin')
32
+ event['headers'][params[0].downcase] = params[1]
33
+ end
34
+ }"
35
+ }
36
+
37
+ # translate user agent
38
+ useragent {
39
+ source => "[headers][user-agent]"
40
+ target => "[headers][useragent]"
41
+ }
42
+
43
+ # remove unusual fields and convert some string to integer
44
+ mutate {
45
+ remove_field => [ "answer", "url", "ip", "[headers][user-agent]", "query_body", "query_headers"]
46
+ convert => { "nb_api_calls" => "integer" }
47
+ convert => { "processing_time_ms" => "integer" }
48
+ convert => { "query_nb_hits" => "integer" }
49
+ }
50
+ }
51
+
52
+ output {
53
+ stdout {
54
+ codec => rubydebug
55
+ }
56
+ }
@@ -0,0 +1,29 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-input-algolialogs'
3
+ s.version = '0.1.0'
4
+ s.licenses = ['Apache License (2.0)']
5
+ s.summary = "Retrieve logs from algolia."
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 gemname. This gem is not a stand-alone program"
7
+ s.authors = ["epigneul"]
8
+ s.email = 'erwan.pigneul@gmail.com'
9
+ s.homepage = "https://github.com/ErwanPigneul/logstash-input-algolialogs"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = `git ls-files`.split($\)
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", '>= 1.4.0', '< 2.0.0'
22
+ s.add_runtime_dependency 'logstash-codec-plain'
23
+ s.add_runtime_dependency 'stud'
24
+ s.add_runtime_dependency 'algoliasearch'
25
+
26
+ s.add_development_dependency 'logstash-devutils'
27
+
28
+
29
+ end
@@ -0,0 +1 @@
1
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-input-algolialogs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - epigneul
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logstash-core
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: logstash-codec-plain
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: stud
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: :runtime
61
+ - !ruby/object:Gem::Dependency
62
+ name: algoliasearch
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirement: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ prerelease: false
74
+ type: :runtime
75
+ - !ruby/object:Gem::Dependency
76
+ name: logstash-devutils
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirement: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ prerelease: false
88
+ type: :development
89
+ 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
90
+ email: erwan.pigneul@gmail.com
91
+ executables: []
92
+ extensions: []
93
+ extra_rdoc_files: []
94
+ files:
95
+ - DEVELOPER.md
96
+ - Gemfile
97
+ - LICENSE
98
+ - README.md
99
+ - Rakefile
100
+ - lib/logstash/inputs/algolialogs.rb
101
+ - logstash-input-algolialogs.conf
102
+ - logstash-input-algolialogs.gemspec
103
+ - spec/inputs/algolialogs_spec.rb
104
+ homepage: https://github.com/ErwanPigneul/logstash-input-algolialogs
105
+ licenses:
106
+ - Apache License (2.0)
107
+ metadata:
108
+ logstash_plugin: 'true'
109
+ logstash_group: input
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.5
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Retrieve logs from algolia.
130
+ test_files:
131
+ - spec/inputs/algolialogs_spec.rb