diff --git a/README.md b/README.md index f72a16f1e..0a0b9ce08 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,13 @@ additional questions or comments. ## Release History Note : The agent version(s) below has dates (ciprod), which indicate the agent build dates (not release dates) + +### 03/12/2019 - Version microsoft/oms:ciprod03122019 +- Fix for closing response.Body in outoms +- Update Mem_Buf_Limit to 5m for fluentbit +- Tail only files that were modified since 5 minutes +- Remove some unwanted logs that are chatty in outoms +- Fix for MDM disablement for AKS-Engine ### 02/21/2019 - Version microsoft/oms:ciprod02212019 - Container logs enrichment optimization diff --git a/installer/conf/td-agent-bit.conf b/installer/conf/td-agent-bit.conf index f01857cd7..78a7b2dde 100644 --- a/installer/conf/td-agent-bit.conf +++ b/installer/conf/td-agent-bit.conf @@ -10,16 +10,17 @@ Path /var/log/containers/*.log DB /var/log/omsagent-fblogs.db Parser docker - Mem_Buf_Limit 30m + Mem_Buf_Limit 5m Path_Key filepath Skip_Long_Lines On + Ignore_Older 5m [INPUT] Name tail Tag oms.container.log.flbplugin.* Path /var/log/containers/omsagent*.log DB /var/opt/microsoft/docker-cimprov/state/omsagent-ai.db - Mem_Buf_Limit 30m + Mem_Buf_Limit 2m Path_Key filepath Skip_Long_Lines On @@ -28,6 +29,4 @@ EnableTelemetry true TelemetryPushIntervalSeconds 300 Match oms.container.log.* - AgentVersion ciprod02212019 - - + AgentVersion ciprod03122019 \ No newline at end of file diff --git a/source/code/go/src/plugins/oms.go b/source/code/go/src/plugins/oms.go index d913c6c32..36cf20273 100644 --- a/source/code/go/src/plugins/oms.go +++ b/source/code/go/src/plugins/oms.go @@ -246,16 +246,11 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { if val, ok := imageIDMap[containerID]; ok { stringMap["Image"] = val - } else { - Log("ContainerId %s not present in Name Map ", containerID) - } + } if val, ok := nameIDMap[containerID]; ok { stringMap["Name"] = val - } else { - Log("ContainerId %s not present in Image Map ", containerID) - } - + } dataItem := DataItem{ ID: stringMap["Id"], @@ -319,6 +314,8 @@ func PostDataHelper(tailPluginRecords []map[interface{}]interface{}) int { return output.FLB_RETRY } + defer resp.Body.Close() + numRecords := len(dataItems) Log("Successfully flushed %d records in %s", numRecords, elapsed) ContainerLogTelemetryMutex.Lock() diff --git a/source/code/plugin/CustomMetricsUtils.rb b/source/code/plugin/CustomMetricsUtils.rb index d06c9ad91..a19580630 100644 --- a/source/code/plugin/CustomMetricsUtils.rb +++ b/source/code/plugin/CustomMetricsUtils.rb @@ -9,8 +9,8 @@ class << self def check_custom_metrics_availability(custom_metric_regions) aks_region = ENV['AKS_REGION'] aks_resource_id = ENV['AKS_RESOURCE_ID'] - if aks_region.to_s.empty? && aks_resource_id.to_s.empty? - false # This will also take care of AKS-Engine Scenario. AKS_REGION/AKS_RESOURCE_ID is not set for AKS-Engine. Only ACS_RESOURCE_NAME is set + if aks_region.to_s.empty? || aks_resource_id.to_s.empty? + return false # This will also take care of AKS-Engine Scenario. AKS_REGION/AKS_RESOURCE_ID is not set for AKS-Engine. Only ACS_RESOURCE_NAME is set end custom_metrics_regions_arr = custom_metric_regions.split(',') diff --git a/source/code/plugin/out_mdm.rb b/source/code/plugin/out_mdm.rb index 6bde98534..274f450fd 100644 --- a/source/code/plugin/out_mdm.rb +++ b/source/code/plugin/out_mdm.rb @@ -29,6 +29,7 @@ def initialize @cached_access_token = String.new @last_post_attempt_time = Time.now @first_post_attempt_made = false + @can_send_data_to_mdm = true end def configure(conf) @@ -39,7 +40,13 @@ def configure(conf) def start super - file = File.read(@@azure_json_path) + begin + file = File.read(@@azure_json_path) + rescue => e + @log.info "Unable to read file #{@@azure_json_path} #{e}" + @can_send_data_to_mdm = false + return + end # Handle the case where the file read fails. Send Telemetry and exit the plugin? @data_hash = JSON.parse(file) @token_url = @@token_url_template % {tenant_id: @data_hash['tenantId']} @@ -48,11 +55,13 @@ def start aks_region = ENV['AKS_REGION'] if aks_resource_id.to_s.empty? @log.info "Environment Variable AKS_RESOURCE_ID is not set.. " - raise Exception.new "Environment Variable AKS_RESOURCE_ID is not set!!" + @can_send_data_to_mdm = false + return end if aks_region.to_s.empty? @log.info "Environment Variable AKS_REGION is not set.. " - raise Exception.new "Environment Variable AKS_REGION is not set!!" + @can_send_data_to_mdm = false + return end @@post_request_url = @@post_request_url_template % {aks_region: aks_region, aks_resource_id: aks_resource_id} @@ -115,14 +124,18 @@ def format(tag, time, record) # 'chunk' is a buffer chunk that includes multiple formatted records def write(chunk) begin - if !@first_post_attempt_made || (Time.now > @last_post_attempt_time + retry_mdm_post_wait_minutes*60) + if (!@first_post_attempt_made || (Time.now > @last_post_attempt_time + retry_mdm_post_wait_minutes*60)) && @can_send_data_to_mdm post_body = [] chunk.msgpack_each {|(tag, record)| post_body.push(record.to_json) } send_to_mdm post_body else - @log.info "Last Failed POST attempt to MDM was made #{((Time.now - @last_post_attempt_time)/60).round(1)} min ago. This is less than the current retry threshold of #{@retry_mdm_post_wait_minutes} min. NO-OP" + if !@can_send_data_to_mdm + @log.info "Cannot send data to MDM since all required conditions were not met" + else + @log.info "Last Failed POST attempt to MDM was made #{((Time.now - @last_post_attempt_time)/60).round(1)} min ago. This is less than the current retry threshold of #{@retry_mdm_post_wait_minutes} min. NO-OP" + end end rescue Exception => e @log.info "Exception when writing to MDM: #{e}"