Class: Fluent::Plugin::AzureLogAnalyticsOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::Plugin::AzureLogAnalyticsOutput
- Defined in:
- lib/fluent/plugin/out_azure-loganalytics.rb
Constant Summary collapse
- DEFAULT_BUFFER_TYPE =
"memory"
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
- #formatted_to_msgpack_binary? ⇒ Boolean
- #multi_workers_ready? ⇒ Boolean
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Instance Method Details
#configure(conf) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/fluent/plugin/out_azure-loganalytics.rb', line 43 def configure(conf) compat_parameters_convert(conf, :buffer) super raise Fluent::ConfigError, 'no customer_id' if @customer_id.empty? raise Fluent::ConfigError, 'no shared_key' if @shared_key.empty? raise Fluent::ConfigError, 'no log_type' if @log_type.empty? if not @log_type.match(/^[[:alpha:]]+$/) raise Fluent::ConfigError, 'log_type supports only alpha characters' end if @add_time_field and @time_field_name.empty? raise Fluent::ConfigError, 'time_field_name must be set if add_time_field is true' end if @add_tag_field and @tag_field_name.empty? raise Fluent::ConfigError, 'tag_field_name must be set if add_tag_field is true' end @timef = Fluent::TimeFormatter.new(@time_format, @localtime) end |
#format(tag, time, record) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/fluent/plugin/out_azure-loganalytics.rb', line 72 def format(tag, time, record) if @add_time_field record[@time_field_name] = @timef.format(time) end if @add_tag_field record[@tag_field_name] = tag end record.to_msgpack end |
#formatted_to_msgpack_binary? ⇒ Boolean
82 83 84 |
# File 'lib/fluent/plugin/out_azure-loganalytics.rb', line 82 def formatted_to_msgpack_binary? true end |
#multi_workers_ready? ⇒ Boolean
86 87 88 |
# File 'lib/fluent/plugin/out_azure-loganalytics.rb', line 86 def multi_workers_ready? true end |
#shutdown ⇒ Object
67 68 69 70 |
# File 'lib/fluent/plugin/out_azure-loganalytics.rb', line 67 def shutdown super # destroy end |
#start ⇒ Object
61 62 63 64 65 |
# File 'lib/fluent/plugin/out_azure-loganalytics.rb', line 61 def start super # start @client=Azure::Loganalytics::Datacollectorapi::Client::new(@customer_id,@shared_key,@endpoint) end |
#write(chunk) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/fluent/plugin/out_azure-loganalytics.rb', line 90 def write(chunk) records = [] chunk.msgpack_each { |record| records.push(record) } begin res = @client.post_data(@log_type, records, @time_generated_field) if not Azure::Loganalytics::Datacollectorapi::Client.is_success(res) log.fatal "DataCollector API request failure: error code: " + "#{res.code}, data=>" + records.to_json end rescue Exception => ex log.fatal "Exception occured in posting to DataCollector API: " + "'#{ex}', data=>" + records.to_json end end |