Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion installer/conf/container.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#custom_metrics_mdm filter plugin
<filter mdm.cadvisorperf**>
type filter_cadvisor2mdm
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westeurope
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westeurope,southafricanorth,centralus,northcentralus,eastus2,koreacentral,eastasia,centralindia,uksouth,canadacentral
metrics_to_collect cpuUsageNanoCores,memoryWorkingSetBytes,memoryRssBytes
log_level info
</filter>
Expand Down
4 changes: 2 additions & 2 deletions installer/conf/kube.conf
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@

<filter mdm.kubepodinventory** mdm.kubenodeinventory**>
type filter_inventory2mdm
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westEurope
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westeurope,southafricanorth,centralus,northcentralus,eastus2,koreacentral,eastasia,centralindia,uksouth,canadacentral
log_level info
</filter>

#custom_metrics_mdm filter plugin for perf data from windows nodes
<filter mdm.cadvisorperf**>
type filter_cadvisor2mdm
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westEurope
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westeurope,southafricanorth,centralus,northcentralus,eastus2,koreacentral,eastasia,centralindia,uksouth,canadacentral
metrics_to_collect cpuUsageNanoCores,memoryWorkingSetBytes
log_level info
</filter>
Expand Down
53 changes: 27 additions & 26 deletions source/code/plugin/out_mdm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,37 +44,38 @@ def start
super
begin
file = File.read(@@azure_json_path)
@data_hash = JSON.parse(file)
aks_resource_id = ENV["AKS_RESOURCE_ID"]
aks_region = ENV["AKS_REGION"]

if aks_resource_id.to_s.empty?
@log.info "Environment Variable AKS_RESOURCE_ID is not set.. "
@can_send_data_to_mdm = false
end
if aks_region.to_s.empty?
@log.info "Environment Variable AKS_REGION is not set.. "
@can_send_data_to_mdm = false
end
aks_region = aks_region.gsub(" ","")

if @can_send_data_to_mdm
@log.info "MDM Metrics supported in #{aks_region} region"
@token_url = @@token_url_template % {tenant_id: @data_hash["tenantId"]}
@cached_access_token = get_access_token
@@post_request_url = @@post_request_url_template % {aks_region: aks_region, aks_resource_id: aks_resource_id}
@post_request_uri = URI.parse(@@post_request_url)
@http_client = Net::HTTP.new(@post_request_uri.host, @post_request_uri.port)
@http_client.use_ssl = true
@log.info "POST Request url: #{@@post_request_url}"
ApplicationInsightsUtility.sendCustomEvent("AKSCustomMetricsMDMPluginStart", {})
end
rescue => e
@log.info "Unable to read file #{@@azure_json_path} #{e}"
@log.info "exception when initializing out_mdm #{e}"
ApplicationInsightsUtility.sendExceptionTelemetry(e, {"FeatureArea" => "MDM"})
@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"]}
@cached_access_token = get_access_token
aks_resource_id = ENV["AKS_RESOURCE_ID"]
aks_region = ENV["AKS_REGION"]

if aks_resource_id.to_s.empty?
@log.info "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.. "
@can_send_data_to_mdm = false
return
end

aks_region = aks_region.gsub(" ","")

@@post_request_url = @@post_request_url_template % {aks_region: aks_region, aks_resource_id: aks_resource_id}
@post_request_uri = URI.parse(@@post_request_url)
@http_client = Net::HTTP.new(@post_request_uri.host, @post_request_uri.port)
@http_client.use_ssl = true
@log.info "POST Request url: #{@@post_request_url}"
ApplicationInsightsUtility.sendCustomEvent("AKSCustomMetricsMDMPluginStart", {})
end

# get the access token only if the time to expiry is less than 5 minutes
Expand Down