Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First commit - adding Logstash plug-ins for Azure.
- Loading branch information
0 parents
commit 1f38791
Showing
43 changed files
with
1,378 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
## Ignore Visual Studio temporary files, build results, and | ||
## files generated by popular Visual Studio add-ons. | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
*.sln.docstates | ||
|
||
# Build results | ||
|
||
[Dd]ebug/ | ||
[Rr]elease/ | ||
x64/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
|
||
# MSTest test Results | ||
[Tt]est[Rr]esult*/ | ||
[Bb]uild[Ll]og.* | ||
|
||
*_i.c | ||
*_p.c | ||
*_i.h | ||
*.ilk | ||
*.meta | ||
*.obj | ||
*.pch | ||
*.pdb | ||
*.pgc | ||
*.pgd | ||
*.rsp | ||
*.sbr | ||
*.tlb | ||
*.tli | ||
*.tlh | ||
*.tmp | ||
*.tmp_proj | ||
*.log | ||
*.vspscc | ||
*.vssscc | ||
.builds | ||
*.pidb | ||
*.log | ||
*.svclog | ||
*.scc | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
*.aps | ||
*.ncb | ||
*.opensdf | ||
*.sdf | ||
*.cachefile | ||
|
||
# Visual Studio profiler | ||
*.psess | ||
*.vsp | ||
*.vspx | ||
|
||
# Guidance Automation Toolkit | ||
*.gpState | ||
|
||
# ReSharper is a .NET coding add-in | ||
_ReSharper*/ | ||
*.[Rr]e[Ss]harper | ||
*.DotSettings.user | ||
|
||
# Click-Once directory | ||
publish/ | ||
|
||
# Publish Web Output | ||
*.Publish.xml | ||
*.pubxml | ||
*.azurePubxml | ||
|
||
# NuGet Packages Directory | ||
## TODO: If you have NuGet Package Restore enabled, uncomment the next line | ||
packages/ | ||
## TODO: If the tool you use requires repositories.config, also uncomment the next line | ||
!packages/repositories.config | ||
|
||
# Windows Azure Build Output | ||
csx/ | ||
*.build.csdef | ||
|
||
# Windows Store app package directory | ||
AppPackages/ | ||
|
||
# Others | ||
sql/ | ||
*.Cache | ||
ClientBin/ | ||
[Ss]tyle[Cc]op.* | ||
![Ss]tyle[Cc]op.targets | ||
~$* | ||
*~ | ||
*.dbmdl | ||
*.[Pp]ublish.xml | ||
|
||
*.publishsettings | ||
|
||
# RIA/Silverlight projects | ||
Generated_Code/ | ||
|
||
# Backup & report files from converting an old project file to a newer | ||
# Visual Studio version. Backup files are not needed, because we have git ;-) | ||
_UpgradeReport_Files/ | ||
Backup*/ | ||
UpgradeLog*.XML | ||
UpgradeLog*.htm | ||
|
||
# SQL Server files | ||
App_Data/*.mdf | ||
App_Data/*.ldf | ||
|
||
# ========================= | ||
# Windows detritus | ||
# ========================= | ||
|
||
# Windows image file caches | ||
Thumbs.db | ||
ehthumbs.db | ||
|
||
# Folder config file | ||
Desktop.ini | ||
|
||
# Recycle Bin used on file shares | ||
$RECYCLE.BIN/ | ||
|
||
# Mac desktop service store files | ||
.DS_Store | ||
|
||
_NCrunch* | ||
|
||
# Ruby gem build output | ||
*.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
======================================================================================== | ||
Microsoft Azure Diagnostics Tools | ||
Logstash plug-ins | ||
======================================================================================== | ||
|
||
Copyright (c) Microsoft. All rights reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); you | ||
may not use this file except in compliance with the License. You may | ||
obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
implied. See the License for the specific language governing permissions | ||
and limitations under the License. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source 'https://rubygems.org' | ||
gemspec | ||
gem 'azure', '~> 0.7.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
Copyright (c) Microsoft. All rights reserved. | ||
Microsoft would like to thank its contributors, a list | ||
of whom are at http://aka.ms/entlib-contributors | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); you | ||
may not use this file except in compliance with the License. You may | ||
obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
implied. See the License for the specific language governing permissions | ||
and limitations under the License. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Notice | ||
This plugin is a part of [Microsoft Azure Diagnostics with ELK](https://github.com/mspnp/semantic-logging/tree/v3/ELK). | ||
|
||
[See more documentation.](https://github.com/mspnp/semantic-logging/blob/v3/ELK/md/LogstashExtensions.md#azure-wad-table) | ||
|
||
# Logstash Plugin | ||
|
||
This is a plugin for [Logstash](https://github.com/elasticsearch/logstash). | ||
|
||
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. | ||
|
||
## Documentation | ||
|
||
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/). | ||
|
||
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive | ||
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide | ||
|
||
## Need Help? | ||
|
||
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum. | ||
|
||
## Developing | ||
|
||
### 1. Plugin Developement and Testing | ||
|
||
#### Code | ||
- To get started, you'll need JRuby with the Bundler gem installed. | ||
|
||
- 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). | ||
|
||
- Install dependencies | ||
```sh | ||
bundle install | ||
``` | ||
|
||
#### Test | ||
|
||
- Update your dependencies | ||
|
||
```sh | ||
bundle install | ||
``` | ||
|
||
- Run tests | ||
|
||
```sh | ||
bundle exec rspec | ||
``` | ||
|
||
### 2. Running your unpublished Plugin in Logstash | ||
|
||
#### 2.1 Run in a local Logstash clone | ||
|
||
- Edit Logstash `Gemfile` and add the local plugin path, for example: | ||
```ruby | ||
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome" | ||
``` | ||
- Install plugin | ||
```sh | ||
bin/plugin install --no-verify | ||
``` | ||
- Run Logstash with your plugin | ||
```sh | ||
bin/logstash -e 'filter {awesome {}}' | ||
``` | ||
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash. | ||
|
||
#### 2.2 Run in an installed Logstash | ||
|
||
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: | ||
|
||
- Build your plugin gem | ||
```sh | ||
gem build logstash-filter-awesome.gemspec | ||
``` | ||
- Install the plugin from the Logstash home | ||
```sh | ||
bin/plugin install /your/local/plugin/logstash-filter-awesome.gem | ||
``` | ||
- Start Logstash and proceed to test the plugin | ||
|
||
## Contributing | ||
|
||
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin. | ||
|
||
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. | ||
|
||
It is more important to the community that you are able to contribute. | ||
|
||
For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require "logstash/devutils/rake" |
96 changes: 96 additions & 0 deletions
96
Logstash/logstash-input-azureblob/lib/logstash/inputs/azureblob.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# encoding: utf-8 | ||
require "logstash/inputs/base" | ||
require "logstash/namespace" | ||
|
||
require "azure" | ||
require "securerandom" | ||
|
||
# Reads events from Azure Blobs | ||
class LogStash::Inputs::Azureblob < LogStash::Inputs::Base | ||
|
||
config_name "azureblob" | ||
milestone 0 | ||
|
||
default :codec, "json_lines" | ||
|
||
config :storage_account_name, :validate => :string | ||
config :storage_access_key, :validate => :string | ||
|
||
config :container, :validate => :string | ||
config :sleep_time, :validate => :number, :default => 10 | ||
|
||
def initialize(*args) | ||
super(*args) | ||
end # def initialize | ||
|
||
public | ||
def register | ||
Azure.configure do |config| | ||
config.storage_account_name = @storage_account_name | ||
config.storage_access_key = @storage_access_key | ||
end | ||
@azure_blob = Azure::Blob::BlobService.new | ||
end # def register | ||
|
||
def list_blob_names | ||
blob_names = Set.new [] | ||
loop do | ||
continuation_token = NIL | ||
entries = @azure_blob.list_blobs(@container, { :timeout => 10, :marker => continuation_token}) | ||
entries.each do |entry| | ||
blob_names << entry.name | ||
end | ||
continuation_token = entries.continuation_token | ||
break if continuation_token.empty? | ||
end | ||
return blob_names | ||
end # def list_blobs | ||
|
||
def acquire_lock(blob_name) | ||
@azure_blob.create_page_blob(@container, blob_name, 512) | ||
@azure_blob.acquire_lease(@container, blob_name,{:duration=>60, :timeout=>10, :proposed_lease_id=>SecureRandom.uuid}) | ||
return true | ||
rescue LogStash::ShutdownSignal => e | ||
raise e | ||
rescue => e | ||
@logger.error("Caught exception while locking", :exception => e) | ||
return false | ||
end # def acquire_lock | ||
|
||
def lock_blob(blob_names) | ||
real_blob_names = blob_names.select { |name| !name.end_with?(".lock") } | ||
real_blob_names.each do |blob_name| | ||
if !blob_names.include?(blob_name + ".lock") | ||
if acquire_lock(blob_name + ".lock") | ||
return blob_name | ||
end | ||
end | ||
end | ||
return NIL | ||
end # def lock_blob | ||
|
||
def process(output_queue) | ||
blob_names = list_blob_names | ||
blob_name = lock_blob(blob_names) | ||
return if !blob_name | ||
blob, content = @azure_blob.get_blob(@container, blob_name) | ||
@codec.decode(content) do |event| | ||
output_queue << event | ||
end | ||
rescue LogStash::ShutdownSignal => e | ||
raise e | ||
rescue => e | ||
@logger.error("Oh My, An error occurred.", :exception => e) | ||
end # def process | ||
|
||
public | ||
def run(output_queue) | ||
while true | ||
process(output_queue) | ||
end # loop | ||
end # def run | ||
|
||
public | ||
def teardown | ||
end # def teardown | ||
end # class LogStash::Inputs::Azuretopic |
24 changes: 24 additions & 0 deletions
24
Logstash/logstash-input-azureblob/logstash-input-azureblob.gemspec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Gem::Specification.new do |s| | ||
s.name = 'logstash-input-azureblob' | ||
s.version = '0.9.3' | ||
s.licenses = ['Apache License (2.0)'] | ||
s.summary = "This plugin will collect Microsoft Azure Diagnostics data from Azure Storage." | ||
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." | ||
s.authors = ["Microsoft Corporation"] | ||
s.email = 'azdiag@microsoft.com' | ||
s.homepage = "https://github.com/juliusl/logstash-input-azurewadtable" | ||
s.require_paths = ["lib"] | ||
|
||
# Files | ||
s.files = `git ls-files`.split($\) | ||
# Tests | ||
s.test_files = s.files.grep(%r{^(test|spec|features)/}) | ||
|
||
# Special flag to let us know this is actually a logstash plugin | ||
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" } | ||
|
||
# Gem dependencies | ||
s.add_runtime_dependency 'logstash-core', '>= 1.4.0', '< 2.0.0' | ||
s.add_runtime_dependency 'azure', '~> 0.7.1' | ||
s.add_development_dependency 'logstash-devutils' | ||
end |
1 change: 1 addition & 0 deletions
1
Logstash/logstash-input-azureblob/spec/inputs/azureblob_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require "logstash/devutils/rspec/spec_helper" |
Empty file.
Oops, something went wrong.