Class: LogStash::Outputs::MicrosoftSentinelOutputInternal::LogstashLoganalyticsOutputConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb

Instance Method Summary collapse

Constructor Details

#initialize(client_app_Id, client_app_secret, tenant_id, data_collection_endpoint, dcr_immutable_id, dcr_stream_name, compress_data, create_sample_file, sample_file_path, logger) ⇒ LogstashLoganalyticsOutputConfiguration

Returns a new instance of LogstashLoganalyticsOutputConfiguration.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 4

def initialize(client_app_Id, client_app_secret, tenant_id, data_collection_endpoint, dcr_immutable_id, dcr_stream_name, compress_data, create_sample_file, sample_file_path, logger)
		@client_app_Id = client_app_Id
    @client_app_secret = client_app_secret
    @tenant_id = tenant_id
    @data_collection_endpoint = data_collection_endpoint
    @dcr_immutable_id = dcr_immutable_id
    @dcr_stream_name = dcr_stream_name
    @logger = logger
 @compress_data = compress_data
 @create_sample_file = create_sample_file
 @sample_file_path = sample_file_path

	# Delay between each resending of a message
    @RETRANSMISSION_DELAY = 2
    @MIN_MESSAGE_AMOUNT = 100
    # Maximum of 1 MB per post to Log Analytics Data Collector API V2. 
    # This is a size limit for a single post. 
    # If the data from a single post that exceeds 1 MB, you should split it.
    @loganalytics_api_data_limit = 1 * 1024 * 1024

    # Taking 4K safety buffer
    @MAX_SIZE_BYTES = @loganalytics_api_data_limit - 10000
end

Instance Method Details

#amount_resizingObject



98
99
100
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 98

def amount_resizing
    @amount_resizing
end

#amount_resizing=(new_amount_resizing) ⇒ Object



178
179
180
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 178

def amount_resizing=(new_amount_resizing)
    @amount_resizing = new_amount_resizing
end

#client_app_IdObject



122
123
124
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 122

def client_app_Id
    @client_app_Id
end

#client_app_secretObject



126
127
128
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 126

def client_app_secret
    @client_app_secret
end

#compress_dataObject



198
199
200
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 198

def compress_data
    @compress_data
end

#compress_data=(new_compress_data) ⇒ Object



202
203
204
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 202

def compress_data=(new_compress_data)
    @compress_data = new_compress_data
end

#create_sample_fileObject



206
207
208
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 206

def create_sample_file
    @create_sample_file
end

#create_sample_file=(new_create_sample_file) ⇒ Object



210
211
212
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 210

def create_sample_file=(new_create_sample_file)
    @create_sample_file = new_create_sample_file
end

#data_collection_endpointObject



134
135
136
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 134

def data_collection_endpoint
    @data_collection_endpoint
end

#dcr_immutable_idObject



138
139
140
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 138

def dcr_immutable_id
    @dcr_immutable_id
end

#dcr_stream_nameObject



142
143
144
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 142

def dcr_stream_name
    @dcr_stream_name
end

#decrease_factorObject



118
119
120
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 118

def decrease_factor
    @decrease_factor
end

#decrease_factor=(new_decrease_factor) ⇒ Object



174
175
176
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 174

def decrease_factor=(new_decrease_factor)
    @decrease_factor = new_decrease_factor
end

#key_namesObject



146
147
148
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 146

def key_names
    @key_names
end

#key_names=(new_key_names) ⇒ Object



166
167
168
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 166

def key_names=(new_key_names)
    @key_names = new_key_names
end

#loggerObject



114
115
116
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 114

def logger
    @logger
end

#max_itemsObject



150
151
152
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 150

def max_items
    @max_items
end

#max_items=(new_max_items) ⇒ Object



162
163
164
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 162

def max_items=(new_max_items)
    @max_items = new_max_items
end

#MAX_SIZE_BYTESObject



94
95
96
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 94

def MAX_SIZE_BYTES
    @MAX_SIZE_BYTES
end

#MIN_MESSAGE_AMOUNTObject



158
159
160
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 158

def MIN_MESSAGE_AMOUNT
    @MIN_MESSAGE_AMOUNT
end

#plugin_flush_intervalObject



154
155
156
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 154

def plugin_flush_interval
    @plugin_flush_interval
end

#plugin_flush_interval=(new_plugin_flush_interval) ⇒ Object



170
171
172
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 170

def plugin_flush_interval=(new_plugin_flush_interval)
    @plugin_flush_interval = new_plugin_flush_interval
end

Raises:

  • (ArgumentError)


78
79
80
81
82
83
84
85
86
87
88
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 78

def print_missing_parameter_message_and_raise(param_name)
    @logger.error("Missing a required setting for the microsoft-sentinel-log-analytics-logstash-output-plugin output plugin:
  output {
microsoft-sentinel-log-analytics-logstash-output-plugin {
  #{param_name} => # SETTING MISSING
  ...
}
  }
")
    raise ArgumentError, "The setting #{param_name} is required."
end

#proxy_aadObject



106
107
108
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 106

def proxy_aad
    @proxy_aad
end

#proxy_aad=(new_proxy_aad) ⇒ Object



186
187
188
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 186

def proxy_aad=(new_proxy_aad)
    @proxy_aad = new_proxy_aad
end

#proxy_endpointObject



110
111
112
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 110

def proxy_endpoint
    @proxy_endpoint
end

#proxy_endpoint=(new_proxy_endpoint) ⇒ Object



190
191
192
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 190

def proxy_endpoint=(new_proxy_endpoint)
    @proxy_endpoint = new_proxy_endpoint
end

#RETRANSMISSION_DELAYObject



90
91
92
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 90

def RETRANSMISSION_DELAY
    @RETRANSMISSION_DELAY
end

#retransmission_timeObject



102
103
104
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 102

def retransmission_time
    @retransmission_time
end

#retransmission_time=(new_retransmission_time) ⇒ Object



194
195
196
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 194

def retransmission_time=(new_retransmission_time)
    @retransmission_time = new_retransmission_time
end

#sample_file_pathObject



214
215
216
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 214

def sample_file_path
    @sample_file_path
end

#sample_file_path=(new_sample_file_path) ⇒ Object



218
219
220
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 218

def sample_file_path=(new_sample_file_path)
    @sample_file_path = new_sample_file_path
end

#tenant_idObject



130
131
132
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 130

def tenant_id
    @tenant_id
end

#validate_configurationObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/logstash/sentinel_la/logstashLoganalyticsConfiguration.rb', line 28

def validate_configuration()
  if @create_sample_file
      begin
          if @sample_file_path.nil?
              print_missing_parameter_message_and_raise("sample_file_path")
          end
          if @sample_file_path.strip == ""
              raise ArgumentError, "The setting sample_file_path cannot be empty"
          end
          begin
              file = java.io.File.new(@sample_file_path)
              if !file.exists
                  raise "Path not exists"
              end
          rescue Exception
              raise ArgumentError, "The path #{@sample_file_path} does not exist."
          end
      end
  else
      required_configs = { "client_app_Id" => @client_app_Id,
                          "client_app_secret" => @client_app_secret,
                          "tenant_id" => @tenant_id,
                          "data_collection_endpoint" => @data_collection_endpoint,
                          "dcr_immutable_id" => @dcr_immutable_id,
                          "dcr_stream_name" => @dcr_stream_name }
      required_configs.each { |name, conf|
          if conf.nil?
              print_missing_parameter_message_and_raise(name)
          end
          if conf.empty?
              raise ArgumentError, "Malformed configuration , the following arguments can not be null or empty.[client_app_Id, client_app_secret, tenant_id, data_collection_endpoint, dcr_immutable_id, dcr_stream_name]"
          end
      }

      if @retransmission_time < 0
          raise ArgumentError, "retransmission_time must be a positive integer."
      end
      if @max_items < @MIN_MESSAGE_AMOUNT
          raise ArgumentError, "Setting max_items to value must be greater then #{@MIN_MESSAGE_AMOUNT}."
      end
      if @key_names.length > 500
          raise ArgumentError, 'There are over 500 key names listed to be included in the events sent to Azure Loganalytics, which exceeds the limit of columns that can be define in each table in log analytics.'
      end
  end
    @logger.info("Azure Loganalytics configuration was found valid.")
    # If all validation pass then configuration is valid
    return  true
end