fluent-plugin-azuremonitorlog 0.0.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 +7 -0
- data/.gitignore +50 -0
- data/Gemfile +4 -0
- data/Gemfile.fluentd.0.12 +4 -0
- data/Gemfile.lock +76 -0
- data/LICENSE +22 -0
- data/README.md +59 -0
- data/Rakefile +11 -0
- data/fluent-plugin-azuremonitorlog.gemspec +22 -0
- data/lib/fluent/plugin/in_azuremonitorlog.rb +132 -0
- data/test/helper.rb +31 -0
- data/test/plugin/test_in_azuremonitorlog.rb +46 -0
- metadata +113 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: bc27eaae665cf1497fcb31b343eab908af3d48a8
|
|
4
|
+
data.tar.gz: ffaa0adb94b8ca19d7c880afc78d78b41dab8846
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a856ecc2e3208d0d1b17dfba8727c8dd846dc33a54dd961ff90479bf61f865bf2b1afc6b7344d55f2916c9bd64a8ac8284d99ca852597482b64c4e241caf49ea
|
|
7
|
+
data.tar.gz: 23f60100301a8a6d9cee11aeb42a488a3635e05c607d20cba64bac299b06cc1a753b57bf02471db6cec4d2a5b1586ca1fc74956587d19919a1ce4a0fcc4aabd8
|
data/.gitignore
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
/.config
|
|
4
|
+
/coverage/
|
|
5
|
+
/InstalledFiles
|
|
6
|
+
/pkg/
|
|
7
|
+
/spec/reports/
|
|
8
|
+
/spec/examples.txt
|
|
9
|
+
/test/tmp/
|
|
10
|
+
/test/version_tmp/
|
|
11
|
+
/tmp/
|
|
12
|
+
|
|
13
|
+
# Used by dotenv library to load environment variables.
|
|
14
|
+
# .env
|
|
15
|
+
|
|
16
|
+
## Specific to RubyMotion:
|
|
17
|
+
.dat*
|
|
18
|
+
.repl_history
|
|
19
|
+
build/
|
|
20
|
+
*.bridgesupport
|
|
21
|
+
build-iPhoneOS/
|
|
22
|
+
build-iPhoneSimulator/
|
|
23
|
+
|
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
|
25
|
+
#
|
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
|
29
|
+
#
|
|
30
|
+
# vendor/Pods/
|
|
31
|
+
|
|
32
|
+
## Documentation cache and generated files:
|
|
33
|
+
/.yardoc/
|
|
34
|
+
/_yardoc/
|
|
35
|
+
/doc/
|
|
36
|
+
/rdoc/
|
|
37
|
+
|
|
38
|
+
## Environment normalization:
|
|
39
|
+
/.bundle/
|
|
40
|
+
/vendor/bundle
|
|
41
|
+
/lib/bundler/man/
|
|
42
|
+
|
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
45
|
+
# Gemfile.lock
|
|
46
|
+
# .ruby-version
|
|
47
|
+
# .ruby-gemset
|
|
48
|
+
|
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
50
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
fluent-plugin-azuremonitorlog (0.0.2)
|
|
5
|
+
azure_mgmt_monitor (~> 0.11.0)
|
|
6
|
+
fluentd (>= 0.10.30)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
azure_mgmt_monitor (0.11.0)
|
|
12
|
+
ms_rest_azure (~> 0.8.0)
|
|
13
|
+
concurrent-ruby (1.0.5)
|
|
14
|
+
cool.io (1.5.1)
|
|
15
|
+
domain_name (0.5.20170404)
|
|
16
|
+
unf (>= 0.0.5, < 1.0.0)
|
|
17
|
+
faraday (0.13.1)
|
|
18
|
+
multipart-post (>= 1.2, < 3)
|
|
19
|
+
faraday-cookie_jar (0.0.6)
|
|
20
|
+
faraday (>= 0.7.4)
|
|
21
|
+
http-cookie (~> 1.0.0)
|
|
22
|
+
fluentd (0.14.21)
|
|
23
|
+
cool.io (>= 1.4.5, < 2.0.0)
|
|
24
|
+
http_parser.rb (>= 0.5.1, < 0.7.0)
|
|
25
|
+
msgpack (>= 0.7.0, < 2.0.0)
|
|
26
|
+
ruby_dig (~> 0.0.2)
|
|
27
|
+
serverengine (>= 2.0.4, < 3.0.0)
|
|
28
|
+
sigdump (~> 0.2.2)
|
|
29
|
+
strptime (~> 0.1.7)
|
|
30
|
+
tzinfo (~> 1.0)
|
|
31
|
+
tzinfo-data (~> 1.0)
|
|
32
|
+
yajl-ruby (~> 1.0)
|
|
33
|
+
http-cookie (1.0.3)
|
|
34
|
+
domain_name (~> 0.5)
|
|
35
|
+
http_parser.rb (0.6.0)
|
|
36
|
+
ms_rest (0.7.1)
|
|
37
|
+
concurrent-ruby (~> 1.0)
|
|
38
|
+
faraday (~> 0.9)
|
|
39
|
+
timeliness (~> 0.3)
|
|
40
|
+
ms_rest_azure (0.8.2)
|
|
41
|
+
concurrent-ruby (~> 1.0)
|
|
42
|
+
faraday (~> 0.9)
|
|
43
|
+
faraday-cookie_jar (~> 0.0.6)
|
|
44
|
+
ms_rest (~> 0.7.0)
|
|
45
|
+
msgpack (1.1.0)
|
|
46
|
+
multipart-post (2.0.0)
|
|
47
|
+
power_assert (1.1.0)
|
|
48
|
+
rake (12.0.0)
|
|
49
|
+
ruby_dig (0.0.2)
|
|
50
|
+
serverengine (2.0.5)
|
|
51
|
+
sigdump (~> 0.2.2)
|
|
52
|
+
sigdump (0.2.4)
|
|
53
|
+
strptime (0.1.9)
|
|
54
|
+
test-unit (3.2.5)
|
|
55
|
+
power_assert
|
|
56
|
+
thread_safe (0.3.6)
|
|
57
|
+
timeliness (0.3.8)
|
|
58
|
+
tzinfo (1.2.3)
|
|
59
|
+
thread_safe (~> 0.1)
|
|
60
|
+
tzinfo-data (1.2017.2)
|
|
61
|
+
tzinfo (>= 1.0.0)
|
|
62
|
+
unf (0.1.4)
|
|
63
|
+
unf_ext
|
|
64
|
+
unf_ext (0.0.7.4)
|
|
65
|
+
yajl-ruby (1.3.0)
|
|
66
|
+
|
|
67
|
+
PLATFORMS
|
|
68
|
+
ruby
|
|
69
|
+
|
|
70
|
+
DEPENDENCIES
|
|
71
|
+
fluent-plugin-azuremonitorlog!
|
|
72
|
+
rake (>= 0.9.2)
|
|
73
|
+
test-unit (>= 3.1.0)
|
|
74
|
+
|
|
75
|
+
BUNDLED WITH
|
|
76
|
+
1.15.4
|
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2017 Microsoft
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# fluent-plugin-azuremonitorlog, a plugin for [Fluentd](http://fluentd.org)
|
|
2
|
+
## Overview
|
|
3
|
+
|
|
4
|
+
***Azure Monitor log*** input plugin.
|
|
5
|
+
|
|
6
|
+
This plugin gets the monitor activity logs from Azure Monitor API to fluentd.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
Install from RubyGems:
|
|
11
|
+
```
|
|
12
|
+
$ gem install fluent-plugin-azuremonitorlog
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
To use this plugin, you need to have Azure Service Principal.<br/>
|
|
16
|
+
Create an Azure Service Principal through [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli?toc=%2fazure%2fazure-resource-manager%2ftoc.json) or [Azure portal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal).
|
|
17
|
+
|
|
18
|
+
## Configuration
|
|
19
|
+
|
|
20
|
+
```config
|
|
21
|
+
<source>
|
|
22
|
+
@type azuremonitorlog
|
|
23
|
+
tag azuremonitorlog
|
|
24
|
+
tenant_id [Azure_Tenant_ID]
|
|
25
|
+
subscription_id [Azure_Subscription_Id]
|
|
26
|
+
client_id [Azure_Client_Id]
|
|
27
|
+
client_secret [Azure_Client_Secret]
|
|
28
|
+
|
|
29
|
+
select [selected fields to query]
|
|
30
|
+
filter [filter the query query] (default: eventChannels eq 'Admin, Operation')
|
|
31
|
+
interval [interval in seconds] (default: 300)
|
|
32
|
+
api_version [api version] (default: 2015-04-01)
|
|
33
|
+
</source>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Documentation for select and filter can be found [here](https://docs.microsoft.com/en-us/rest/api/monitor/ActivityLogs/List#activitylogs_list_uri_parameters)
|
|
37
|
+
|
|
38
|
+
### Example for source config
|
|
39
|
+
|
|
40
|
+
```config
|
|
41
|
+
<source>
|
|
42
|
+
@type azuremonitorlog
|
|
43
|
+
tag azuremonitorlog
|
|
44
|
+
tenant_id [Azure_Tenant_ID]
|
|
45
|
+
subscription_id [Azure_Subscription_Id]
|
|
46
|
+
client_id [Azure_Client_Id]
|
|
47
|
+
client_secret [Azure_Client_Secret]
|
|
48
|
+
select_filter eventName,id,resourceGroupName,resourceProviderName,operationName,status,eventTimestamp,correlationId,submissionTimestamp,level
|
|
49
|
+
</source>
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Contributing
|
|
54
|
+
|
|
55
|
+
1. Fork it
|
|
56
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
57
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
|
58
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
59
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |gem|
|
|
6
|
+
gem.name = "fluent-plugin-azuremonitorlog"
|
|
7
|
+
gem.version = "0.0.1"
|
|
8
|
+
gem.authors = ["Ilana Kantorov"]
|
|
9
|
+
gem.email = ["ilanak@microsoft.com"]
|
|
10
|
+
gem.description = %q{Input plugin for Azure Monitor Activity logs.}
|
|
11
|
+
gem.homepage = "https://github.com/Ilanak/fluent-plugin-azureamonitorlog"
|
|
12
|
+
gem.summary = gem.description
|
|
13
|
+
gem.files = `git ls-files`.split($\)
|
|
14
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
16
|
+
gem.require_paths = ["lib"]
|
|
17
|
+
gem.add_dependency "fluentd", ">= 0.10.30"
|
|
18
|
+
gem.add_dependency "azure_mgmt_monitor", "~> 0.11.0"
|
|
19
|
+
gem.add_development_dependency "rake", ">= 0.9.2"
|
|
20
|
+
gem.add_development_dependency "test-unit", ">= 3.1.0"
|
|
21
|
+
gem.license = 'MIT'
|
|
22
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
require 'fluent/input'
|
|
2
|
+
require 'azure_mgmt_monitor'
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
class Fluent::AzureMonitorLogInput < Fluent::Input
|
|
6
|
+
Fluent::Plugin.register_input("azuremonitorlog", self)
|
|
7
|
+
|
|
8
|
+
# To support log_level option implemented by Fluentd v0.10.43
|
|
9
|
+
unless method_defined?(:log)
|
|
10
|
+
define_method("log") { $log }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# Define `router` method of v0.12 to support v0.10 or earlier
|
|
14
|
+
unless method_defined?(:router)
|
|
15
|
+
define_method("router") { Fluent::Engine }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
config_param :tag, :string
|
|
19
|
+
config_param :tenant_id, :string, :default => nil
|
|
20
|
+
config_param :subscription_id, :string, :default => nil
|
|
21
|
+
config_param :client_id, :string, :default => nil
|
|
22
|
+
config_param :client_secret, :string, :default => nil, :secret => true
|
|
23
|
+
|
|
24
|
+
config_param :select, :string, :default => nil
|
|
25
|
+
config_param :filter, :string, :default => "eventChannels eq 'Admin, Operation'"
|
|
26
|
+
config_param :interval, :integer,:default => 300
|
|
27
|
+
config_param :api_version, :string, :default => '2015-04-01'
|
|
28
|
+
def initialize
|
|
29
|
+
super
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def configure(conf)
|
|
33
|
+
super
|
|
34
|
+
|
|
35
|
+
provider = MsRestAzure::ApplicationTokenProvider.new(@tenant_id, @client_id, @client_secret)
|
|
36
|
+
credentials = MsRest::TokenCredentials.new(provider)
|
|
37
|
+
@client = Azure::ARM::Monitor::MonitorManagementClient.new(credentials);
|
|
38
|
+
@client.subscription_id = @subscription_id
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def start
|
|
42
|
+
super
|
|
43
|
+
@watcher = Thread.new(&method(:watch))
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def shutdown
|
|
47
|
+
super
|
|
48
|
+
@watcher.terminate
|
|
49
|
+
@watcher.join
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def set_query_options(filter, custom_headers)
|
|
53
|
+
fail ArgumentError, 'path is nil' if @client.subscription_id.nil?
|
|
54
|
+
|
|
55
|
+
request_headers = {}
|
|
56
|
+
|
|
57
|
+
# Set Headers
|
|
58
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
|
59
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
|
60
|
+
|
|
61
|
+
{
|
|
62
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
|
63
|
+
path_params: {'subscriptionId' => @client.subscription_id},
|
|
64
|
+
query_params: {'api-version' => @api_version, '$filter' => filter, '$select' => @select},
|
|
65
|
+
headers: request_headers.merge(custom_headers || {}),
|
|
66
|
+
base_url: @client.base_url
|
|
67
|
+
}
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
private
|
|
71
|
+
|
|
72
|
+
def watch
|
|
73
|
+
while true
|
|
74
|
+
log.debug "azure monitorlog: watch thread starting"
|
|
75
|
+
output
|
|
76
|
+
sleep @interval
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def output
|
|
81
|
+
start_time = Time.now - @interval
|
|
82
|
+
end_time = Time.now
|
|
83
|
+
|
|
84
|
+
log.debug "start time: #{start_time}, end time: #{end_time}"
|
|
85
|
+
filter = "eventTimestamp ge '#{start_time}' and eventTimestamp le '#{end_time}'"
|
|
86
|
+
|
|
87
|
+
if !@filter.empty?
|
|
88
|
+
filter += " and #{@filter}"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
monitor_logs_promise = get_monitor_log_async(filter)
|
|
92
|
+
monitor_logs = monitor_logs_promise.value!
|
|
93
|
+
|
|
94
|
+
if !monitor_logs.body['value'].nil? and monitor_logs.body['value'].any?
|
|
95
|
+
monitor_logs.body['value'].each {|val|
|
|
96
|
+
router.emit(@tag, Time.now.to_i, val)
|
|
97
|
+
}
|
|
98
|
+
else
|
|
99
|
+
log.debug "empty"
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def get_monitor_log_async(filter = nil, custom_headers = nil)
|
|
104
|
+
options = set_query_options(filter, custom_headers)
|
|
105
|
+
path_template = '/subscriptions/{subscriptionId}/providers/microsoft.insights/eventtypes/management/values'
|
|
106
|
+
promise = @client.make_request_async(:get, path_template, options)
|
|
107
|
+
|
|
108
|
+
promise = promise.then do |result|
|
|
109
|
+
http_response = result.response
|
|
110
|
+
status_code = http_response.status
|
|
111
|
+
response_content = http_response.body
|
|
112
|
+
unless status_code == 200
|
|
113
|
+
error_model = JSON.load(response_content)
|
|
114
|
+
log.error(error_model['error']['message'])
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
|
118
|
+
# Deserialize Response
|
|
119
|
+
if status_code == 200
|
|
120
|
+
begin
|
|
121
|
+
result.body = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
|
122
|
+
rescue Exception => e
|
|
123
|
+
log.error("Error occurred in parsing the response")
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
result
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
promise.execute
|
|
131
|
+
end
|
|
132
|
+
end
|
data/test/helper.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler'
|
|
3
|
+
require 'fluent/input'
|
|
4
|
+
|
|
5
|
+
begin
|
|
6
|
+
Bundler.setup(:default, :development)
|
|
7
|
+
rescue Bundler::BundlerError => e
|
|
8
|
+
$stderr.puts e.message
|
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
10
|
+
exit e.status_code
|
|
11
|
+
end
|
|
12
|
+
require "test/unit"
|
|
13
|
+
|
|
14
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
|
15
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
16
|
+
require "fluent/test"
|
|
17
|
+
unless ENV.has_key?("VERBOSE")
|
|
18
|
+
nulllogger = Object.new
|
|
19
|
+
nulllogger.instance_eval {|obj|
|
|
20
|
+
def method_missing(method, *args)
|
|
21
|
+
#pass
|
|
22
|
+
end
|
|
23
|
+
}
|
|
24
|
+
$log = nulllogger
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
require "fluent/plugin/in_azuremonitorlog"
|
|
28
|
+
|
|
29
|
+
class Test::Unit::TestCase
|
|
30
|
+
end
|
|
31
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
class AzureMonitorLogInputTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
Fluent::Test.setup
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
### for monitor log
|
|
9
|
+
CONFIG_MONITOR_LOG = %[
|
|
10
|
+
tag azuremonitorlog
|
|
11
|
+
tenant_id test_tenant_id
|
|
12
|
+
subscription_id test_subscription_id
|
|
13
|
+
client_id test_client_id
|
|
14
|
+
client_secret test_client_secret
|
|
15
|
+
select eventName,id,resourceGroupName,resourceProviderName,operationName,status,eventTimestamp,correlationId
|
|
16
|
+
filter eventChannels eq 'Admin, Operation'
|
|
17
|
+
interval 300
|
|
18
|
+
api_version 2015-04-01
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
def create_driver_monitor_log(conf = CONFIG_MONITOR_LOG)
|
|
22
|
+
Fluent::Test::InputTestDriver.new(Fluent::AzureMonitorLogInput).configure(conf)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_configure_monitor_log
|
|
26
|
+
d = create_driver_monitor_log
|
|
27
|
+
assert_equal 'azuremonitorlog', d.instance.tag
|
|
28
|
+
assert_equal 'test_tenant_id', d.instance.tenant_id
|
|
29
|
+
assert_equal 'test_subscription_id', d.instance.subscription_id
|
|
30
|
+
assert_equal 'test_client_id', d.instance.client_id
|
|
31
|
+
assert_equal 'test_client_secret', d.instance.client_secret
|
|
32
|
+
assert_equal 'eventName,id,resourceGroupName,resourceProviderName,operationName,status,eventTimestamp,correlationId', d.instance.select
|
|
33
|
+
assert_equal 'eventChannels eq \'Admin, Operation\'', d.instance.filter
|
|
34
|
+
assert_equal 300, d.instance.interval
|
|
35
|
+
assert_equal '2015-04-01', d.instance.api_version
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_set_query_options
|
|
39
|
+
d = create_driver_monitor_log
|
|
40
|
+
query_options = d.instance.set_query_options(d.instance.filter, {})
|
|
41
|
+
assert_equal '2015-04-01', query_options[:query_params]['api-version']
|
|
42
|
+
assert_equal 'eventChannels eq \'Admin, Operation\'', query_options[:query_params]['$filter']
|
|
43
|
+
assert_equal 'eventName,id,resourceGroupName,resourceProviderName,operationName,status,eventTimestamp,correlationId', query_options[:query_params]['$select']
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: fluent-plugin-azuremonitorlog
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ilana Kantorov
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-10-24 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: fluentd
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 0.10.30
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.10.30
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: azure_mgmt_monitor
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 0.11.0
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 0.11.0
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 0.9.2
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 0.9.2
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: test-unit
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 3.1.0
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 3.1.0
|
|
69
|
+
description: Input plugin for Azure Monitor Activity logs.
|
|
70
|
+
email:
|
|
71
|
+
- ilanak@microsoft.com
|
|
72
|
+
executables: []
|
|
73
|
+
extensions: []
|
|
74
|
+
extra_rdoc_files: []
|
|
75
|
+
files:
|
|
76
|
+
- ".gitignore"
|
|
77
|
+
- Gemfile
|
|
78
|
+
- Gemfile.fluentd.0.12
|
|
79
|
+
- Gemfile.lock
|
|
80
|
+
- LICENSE
|
|
81
|
+
- README.md
|
|
82
|
+
- Rakefile
|
|
83
|
+
- fluent-plugin-azuremonitorlog.gemspec
|
|
84
|
+
- lib/fluent/plugin/in_azuremonitorlog.rb
|
|
85
|
+
- test/helper.rb
|
|
86
|
+
- test/plugin/test_in_azuremonitorlog.rb
|
|
87
|
+
homepage: https://github.com/Ilanak/fluent-plugin-azureamonitorlog
|
|
88
|
+
licenses:
|
|
89
|
+
- MIT
|
|
90
|
+
metadata: {}
|
|
91
|
+
post_install_message:
|
|
92
|
+
rdoc_options: []
|
|
93
|
+
require_paths:
|
|
94
|
+
- lib
|
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
|
+
requirements:
|
|
97
|
+
- - ">="
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '0'
|
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
|
+
requirements:
|
|
102
|
+
- - ">="
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: '0'
|
|
105
|
+
requirements: []
|
|
106
|
+
rubyforge_project:
|
|
107
|
+
rubygems_version: 2.6.14
|
|
108
|
+
signing_key:
|
|
109
|
+
specification_version: 4
|
|
110
|
+
summary: Input plugin for Azure Monitor Activity logs.
|
|
111
|
+
test_files:
|
|
112
|
+
- test/helper.rb
|
|
113
|
+
- test/plugin/test_in_azuremonitorlog.rb
|