Skip to content

Commit

Permalink
grwehner/mdm custom metric regions (#471)
Browse files Browse the repository at this point in the history
Remove custom metrics region check for public cloud
  • Loading branch information
gracewehner authored Nov 23, 2020
1 parent ca18850 commit 18c27dd
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 34 deletions.
2 changes: 0 additions & 2 deletions build/linux/installer/conf/container.conf
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@
#custom_metrics_mdm filter plugin
<filter mdm.cadvisorperf**>
type filter_cadvisor2mdm
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westeurope,southafricanorth,centralus,northcentralus,eastus2,koreacentral,eastasia,centralindia,uksouth,canadacentral,francecentral,japaneast,australiaeast,eastus2,westus,australiasoutheast,brazilsouth,germanywestcentral,northcentralus,switzerlandnorth
metrics_to_collect cpuUsageNanoCores,memoryWorkingSetBytes,memoryRssBytes,pvUsedBytes
log_level info
</filter>

<filter oms.mdm.container.perf.telegraf**>
type filter_telegraf2mdm
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westeurope,southafricanorth,centralus,northcentralus,eastus2,koreacentral,eastasia,centralindia,uksouth,canadacentral,francecentral,japaneast,australiaeast,eastus2,westus,australiasoutheast,brazilsouth,germanywestcentral,northcentralus,switzerlandnorth
log_level debug
</filter>

Expand Down
3 changes: 0 additions & 3 deletions build/linux/installer/conf/kube.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
tag oms.containerinsights.KubePodInventory
run_interval 60
log_level debug
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westeurope,southafricanorth,centralus,northcentralus,eastus2,koreacentral,eastasia,centralindia,uksouth,canadacentral,francecentral,japaneast,australiaeast,eastus2,westus,australiasoutheast,brazilsouth,germanywestcentral,northcentralus,switzerlandnorth
</source>

#Kubernetes events
Expand Down Expand Up @@ -66,14 +65,12 @@

<filter mdm.kubenodeinventory**>
type filter_inventory2mdm
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westeurope,southafricanorth,centralus,northcentralus,eastus2,koreacentral,eastasia,centralindia,uksouth,canadacentral,francecentral,japaneast,australiaeast,eastus2,westus,australiasoutheast,brazilsouth,germanywestcentral,northcentralus,switzerlandnorth
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,southafricanorth,centralus,northcentralus,eastus2,koreacentral,eastasia,centralindia,uksouth,canadacentral,francecentral,japaneast,australiaeast,eastus2,westus,australiasoutheast,brazilsouth,germanywestcentral,northcentralus,switzerlandnorth
metrics_to_collect cpuUsageNanoCores,memoryWorkingSetBytes,pvUsedBytes
log_level info
</filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ data:
tag oms.containerinsights.KubePodInventory
run_interval 60
log_level debug
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westeurope,southafricanorth,centralus,northcentralus,eastus2,koreacentral,eastasia,centralindia,uksouth,canadacentral,francecentral,japaneast,australiaeast,eastus2,westus,australiasoutheast,brazilsouth,germanywestcentral,northcentralus,switzerlandnorth
</source>
#Kubernetes events
Expand Down Expand Up @@ -70,14 +69,12 @@ data:
</source>
<filter mdm.kubenodeinventory**>
type filter_inventory2mdm
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westeurope,southafricanorth,centralus,northcentralus,eastus2,koreacentral,eastasia,centralindia,uksouth,canadacentral,francecentral,japaneast,australiaeast,eastus2,westus,australiasoutheast,brazilsouth,germanywestcentral,northcentralus,switzerlandnorth
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,southafricanorth,centralus,northcentralus,eastus2,koreacentral,eastasia,centralindia,uksouth,canadacentral,francecentral,japaneast,australiaeast,eastus2,westus,australiasoutheast,brazilsouth,germanywestcentral,northcentralus,switzerlandnorth
metrics_to_collect cpuUsageNanoCores,memoryWorkingSetBytes
log_level info
</filter>
Expand Down
11 changes: 11 additions & 0 deletions kubernetes/linux/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ else
echo "LA Onboarding:Workspace Id not mounted, skipping the telemetry check"
fi

# Set environment variable for if public cloud by checking the workspace domain.
if [ -z $domain ]; then
ClOUD_ENVIRONMENT="unknown"
elif [ $domain == "opinsights.azure.com" ]; then
CLOUD_ENVIRONMENT="public"
else
CLOUD_ENVIRONMENT="national"
fi
export CLOUD_ENVIRONMENT=$CLOUD_ENVIRONMENT
echo "export CLOUD_ENVIRONMENT=$CLOUD_ENVIRONMENT" >> ~/.bashrc

#Parse the configmap to set the right environment variables.
/opt/microsoft/omsagent/ruby/bin/ruby tomlparser.rb

Expand Down
3 changes: 0 additions & 3 deletions kubernetes/omsagent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ data:
tag oms.containerinsights.KubePodInventory
run_interval 60
log_level debug
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westeurope,southafricanorth,centralus,northcentralus,eastus2,koreacentral,eastasia,centralindia,uksouth,canadacentral,francecentral,japaneast,australiaeast,eastus2,westus,australiasoutheast,brazilsouth,germanywestcentral,northcentralus,switzerlandnorth
</source>
#Kubernetes events
Expand Down Expand Up @@ -117,14 +116,12 @@ data:
<filter mdm.kubenodeinventory**>
type filter_inventory2mdm
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westeurope,southafricanorth,centralus,northcentralus,eastus2,koreacentral,eastasia,centralindia,uksouth,canadacentral,francecentral,japaneast,australiaeast,eastus2,westus,australiasoutheast,brazilsouth,germanywestcentral,northcentralus,switzerlandnorth
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,southafricanorth,centralus,northcentralus,eastus2,koreacentral,eastasia,centralindia,uksouth,canadacentral,francecentral,japaneast,australiaeast,eastus2,westus,australiasoutheast,brazilsouth,germanywestcentral,northcentralus,switzerlandnorth
metrics_to_collect cpuUsageNanoCores,memoryWorkingSetBytes,pvUsedBytes
log_level info
</filter>
Expand Down
6 changes: 6 additions & 0 deletions kubernetes/windows/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,21 @@ function Start-FileSystemWatcher {

function Set-EnvironmentVariables {
$domain = "opinsights.azure.com"
$cloud_environment = "public"
if (Test-Path /etc/omsagent-secret/DOMAIN) {
# TODO: Change to omsagent-secret before merging
$domain = Get-Content /etc/omsagent-secret/DOMAIN
$cloud_environment = "national"
}

# Set DOMAIN
[System.Environment]::SetEnvironmentVariable("DOMAIN", $domain, "Process")
[System.Environment]::SetEnvironmentVariable("DOMAIN", $domain, "Machine")

# Set CLOUD_ENVIRONMENT
[System.Environment]::SetEnvironmentVariable("CLOUD_ENVIRONMENT", $cloud_environment, "Process")
[System.Environment]::SetEnvironmentVariable("CLOUD_ENVIRONMENT", $cloud_environment, "Machine")

$wsID = ""
if (Test-Path /etc/omsagent-secret/WSID) {
# TODO: Change to omsagent-secret before merging
Expand Down
2 changes: 0 additions & 2 deletions scripts/preview/health/omsagent-template-aks-engine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,12 @@ data:
<filter mdm.kubepodinventory** mdm.kubenodeinventory**>
type filter_inventory2mdm
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westEurope
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
metrics_to_collect cpuUsageNanoCores,memoryWorkingSetBytes
log_level info
</filter>
Expand Down
2 changes: 0 additions & 2 deletions scripts/preview/health/omsagent-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,12 @@ data:
<filter mdm.kubepodinventory** mdm.kubenodeinventory**>
type filter_inventory2mdm
custom_metrics_azure_regions eastus,southcentralus,westcentralus,westus2,southeastasia,northeurope,westEurope
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
metrics_to_collect cpuUsageNanoCores,memoryWorkingSetBytes
log_level info
</filter>
Expand Down
12 changes: 3 additions & 9 deletions source/plugins/ruby/CustomMetricsUtils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,15 @@ def initialize
end

class << self
def check_custom_metrics_availability(custom_metric_regions)
def check_custom_metrics_availability
aks_region = ENV['AKS_REGION']
aks_resource_id = ENV['AKS_RESOURCE_ID']
aks_cloud_environment = ENV['CLOUD_ENVIRONMENT']
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(',')
custom_metrics_regions_hash = custom_metrics_regions_arr.map {|x| [x.downcase,true]}.to_h

if custom_metrics_regions_hash.key?(aks_region.downcase)
true
else
false
end
return aks_cloud_environment.to_s.downcase == 'public'
end
end
end
3 changes: 1 addition & 2 deletions source/plugins/ruby/filter_cadvisor2mdm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class CAdvisor2MdmFilter < Filter

config_param :enable_log, :integer, :default => 0
config_param :log_path, :string, :default => "/var/opt/microsoft/docker-cimprov/log/filter_cadvisor2mdm.log"
config_param :custom_metrics_azure_regions, :string
config_param :metrics_to_collect, :string, :default => "Constants::CPU_USAGE_NANO_CORES,Constants::MEMORY_WORKING_SET_BYTES,Constants::MEMORY_RSS_BYTES,Constants::PV_USED_BYTES"

@@hostName = (OMS::Common.get_hostname)
Expand All @@ -42,7 +41,7 @@ def configure(conf)
def start
super
begin
@process_incoming_stream = CustomMetricsUtils.check_custom_metrics_availability(@custom_metrics_azure_regions)
@process_incoming_stream = CustomMetricsUtils.check_custom_metrics_availability
@metrics_to_collect_hash = build_metrics_hash
@log.debug "After check_custom_metrics_availability process_incoming_stream #{@process_incoming_stream}"
@@containerResourceUtilTelemetryTimeTracker = DateTime.now.to_time.to_i
Expand Down
3 changes: 1 addition & 2 deletions source/plugins/ruby/filter_inventory2mdm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class Inventory2MdmFilter < Filter

config_param :enable_log, :integer, :default => 0
config_param :log_path, :string, :default => '/var/opt/microsoft/docker-cimprov/log/filter_inventory2mdm.log'
config_param :custom_metrics_azure_regions, :string

@@node_count_metric_name = 'nodesCount'
@@pod_count_metric_name = 'podCount'
Expand Down Expand Up @@ -98,7 +97,7 @@ def configure(conf)

def start
super
@process_incoming_stream = CustomMetricsUtils.check_custom_metrics_availability(@custom_metrics_azure_regions)
@process_incoming_stream = CustomMetricsUtils.check_custom_metrics_availability
@log.debug "After check_custom_metrics_availability process_incoming_stream #{@process_incoming_stream}"
end

Expand Down
3 changes: 1 addition & 2 deletions source/plugins/ruby/filter_telegraf2mdm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Telegraf2MdmFilter < Filter

config_param :enable_log, :integer, :default => 0
config_param :log_path, :string, :default => "/var/opt/microsoft/docker-cimprov/log/filter_telegraf2mdm.log"
config_param :custom_metrics_azure_regions, :string

@process_incoming_stream = true

Expand All @@ -36,7 +35,7 @@ def configure(conf)
def start
super
begin
@process_incoming_stream = CustomMetricsUtils.check_custom_metrics_availability(@custom_metrics_azure_regions)
@process_incoming_stream = CustomMetricsUtils.check_custom_metrics_availability
@log.debug "After check_custom_metrics_availability process_incoming_stream #{@process_incoming_stream}"
rescue => errorStr
@log.info "Error initializing plugin #{errorStr}"
Expand Down
3 changes: 1 addition & 2 deletions source/plugins/ruby/in_kube_podinventory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ def initialize

config_param :run_interval, :time, :default => 60
config_param :tag, :string, :default => "oms.containerinsights.KubePodInventory"
config_param :custom_metrics_azure_regions, :string

def configure(conf)
super
@inventoryToMdmConvertor = Inventory2MdmConvertor.new(@custom_metrics_azure_regions)
@inventoryToMdmConvertor = Inventory2MdmConvertor.new()
end

def start
Expand Down
4 changes: 2 additions & 2 deletions source/plugins/ruby/podinventory_to_mdm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ class Inventory2MdmConvertor
@@pod_phase_values = ["Running", "Pending", "Succeeded", "Failed", "Unknown"]
@process_incoming_stream = false

def initialize(custom_metrics_azure_regions)
def initialize()
@log_path = "/var/opt/microsoft/docker-cimprov/log/mdm_metrics_generator.log"
@log = Logger.new(@log_path, 1, 5000000)
@pod_count_hash = {}
@no_phase_dim_values_hash = {}
@pod_count_by_phase = {}
@pod_uids = {}
@process_incoming_stream = CustomMetricsUtils.check_custom_metrics_availability(custom_metrics_azure_regions)
@process_incoming_stream = CustomMetricsUtils.check_custom_metrics_availability
@log.debug "After check_custom_metrics_availability process_incoming_stream #{@process_incoming_stream}"
@log.debug { "Starting podinventory_to_mdm plugin" }
end
Expand Down

0 comments on commit 18c27dd

Please sign in to comment.