Class: Fluent::AzureMonitorLogInput

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/in_azuremonitorlog.rb

Instance Method Summary collapse

Constructor Details

#initializeAzureMonitorLogInput

Returns a new instance of AzureMonitorLogInput.



28
29
30
# File 'lib/fluent/plugin/in_azuremonitorlog.rb', line 28

def initialize
  super
end

Instance Method Details

#configure(conf) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/fluent/plugin/in_azuremonitorlog.rb', line 32

def configure(conf)
  super

  provider = MsRestAzure::ApplicationTokenProvider.new(@tenant_id, @client_id, @client_secret)
  credentials = MsRest::TokenCredentials.new(provider)
  @client = Azure::ARM::Monitor::MonitorManagementClient.new(credentials);
  @client.subscription_id = @subscription_id
end

#set_query_options(filter, custom_headers) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fluent/plugin/in_azuremonitorlog.rb', line 54

def set_query_options(filter, custom_headers)
  fail ArgumentError, 'path is nil' if @client.subscription_id.nil?

  request_headers = {}

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'subscriptionId' => @client.subscription_id},
      query_params: {'api-version' => @api_version, '$filter' => filter, '$select' => @select},
      headers: request_headers.merge(custom_headers || {}),
      base_url: @client.base_url
  }
end

#shutdownObject



47
48
49
50
51
52
# File 'lib/fluent/plugin/in_azuremonitorlog.rb', line 47

def shutdown
  super
  @finished = true
  @watcher.terminate
  @watcher.join
end

#startObject



41
42
43
44
45
# File 'lib/fluent/plugin/in_azuremonitorlog.rb', line 41

def start
  super
  @finished = false
  @watcher = Thread.new(&method(:watch))
end