From 2d42825bd2e440a010f00fcbbc2d901929a04ad5 Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Fri, 23 Feb 2024 16:07:33 -0800 Subject: [PATCH 1/3] fix telegraf config related fixes --- .../scripts/tomlparser-prom-customconfig.rb | 20 ++++++++++++++----- .../scripts/tomlparser-osm-config.rb | 2 +- kubernetes/ama-logs.yaml | 4 ---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/build/common/installer/scripts/tomlparser-prom-customconfig.rb b/build/common/installer/scripts/tomlparser-prom-customconfig.rb index a60a9fad4..f35edb2e8 100644 --- a/build/common/installer/scripts/tomlparser-prom-customconfig.rb +++ b/build/common/installer/scripts/tomlparser-prom-customconfig.rb @@ -51,6 +51,10 @@ def get_command_windows(env_variable_name, env_variable_value) return "#{env_variable_name}=#{env_variable_value}\n" end +def is_windows? + return !@os_type.nil? && !@os_type.empty? && @os_type.strip.casecmp("windows") == 0 +end + # Use parser to parse the configmap toml file to a ruby structure def parseConfigMap begin @@ -109,6 +113,12 @@ def createPrometheusPluginsWithNamespaceSetting(monitorKubernetesPods, monitorKu new_contents = new_contents.gsub("$AZMON_TELEGRAF_CUSTOM_PROM_KUBERNETES_FIELD_SELECTOR", "# Commenting this out since new plugins will be created per namespace\n # $AZMON_TELEGRAF_CUSTOM_PROM_KUBERNETES_FIELD_SELECTOR") new_contents = new_contents.gsub("$AZMON_TELEGRAF_CUSTOM_PROM_SCRAPE_SCOPE", "# Commenting this out since new plugins will be created per namespace\n # $AZMON_TELEGRAF_CUSTOM_PROM_SCRAPE_SCOPE") + timeout_config_key = "timeout" + if is_windows? + # For windows, the timeout config key is different because of old version of telegraf + timeout_config_key = "response_timeout" + end + pluginConfigsWithNamespaces = "" monitorKubernetesPodsNamespaces.each do |namespace| if !namespace.nil? @@ -128,7 +138,7 @@ def createPrometheusPluginsWithNamespaceSetting(monitorKubernetesPods, monitorKu metric_version = #{@metricVersion} url_tag = \"#{@urlTag}\" bearer_token = \"#{@bearerToken}\" - response_timeout = \"#{@responseTimeout}\" + #{timeout_config_key} = \"#{@responseTimeout}\" tls_ca = \"#{@tlsCa}\" insecure_skip_verify = #{@insecureSkipVerify}\n" end @@ -262,7 +272,7 @@ def populateSettingValuesFromConfigMap(parsedConfig) end elsif @controller.casecmp(@daemonset) == 0 && ((!@containerType.nil? && @containerType.casecmp(@promSideCar) == 0) || - (!@os_type.nil? && !@os_type.empty? && @os_type.strip.casecmp("windows") == 0) && @sidecarScrapingEnabled.strip.casecmp("true") == 0) && + (is_windows?) && @sidecarScrapingEnabled.strip.casecmp("true") == 0) && !parsedConfig[:prometheus_data_collection_settings][:cluster].nil? #Get prometheus custom config settings for monitor kubernetes pods begin @@ -290,7 +300,7 @@ def populateSettingValuesFromConfigMap(parsedConfig) kubernetesLabelSelectors = (kubernetesLabelSelectors.nil?) ? @defaultCustomPrometheusLabelSelectors : kubernetesLabelSelectors kubernetesFieldSelectors = (kubernetesFieldSelectors.nil?) ? @defaultCustomPrometheusFieldSelectors : kubernetesFieldSelectors - if !@os_type.nil? && !@os_type.empty? && @os_type.strip.casecmp("windows") == 0 + if is_windows? file_name = "/etc/telegraf/telegraf.conf" else file_name = "/opt/telegraf-test-prom-side-car.conf" @@ -346,8 +356,8 @@ def populateSettingValuesFromConfigMap(parsedConfig) file.close puts "config::Successfully created telemetry file for prometheus sidecar" end - elsif !@os_type.nil? && !@os_type.empty? && @os_type.strip.casecmp("windows") == 0 - # Setting the environment variable for starting telegraf only when monitorKubernetesPods is true + elsif is_windows? + # Setting the environment variable for starting telegraf only when monitorKubernetesPods is true file = File.open("setpromenv.txt", "w") if !file.nil? commands = get_command_windows("TELEMETRY_CUSTOM_PROM_MONITOR_PODS", monitorKubernetesPods) diff --git a/build/linux/installer/scripts/tomlparser-osm-config.rb b/build/linux/installer/scripts/tomlparser-osm-config.rb index 2ac5ef387..e2fdcd289 100644 --- a/build/linux/installer/scripts/tomlparser-osm-config.rb +++ b/build/linux/installer/scripts/tomlparser-osm-config.rb @@ -112,7 +112,7 @@ def replaceOsmTelegrafConfigPlaceHolders metric_version = #{@metricVersion} url_tag = \"#{@urlTag}\" bearer_token = \"#{@bearerToken}\" - response_timeout = \"#{@responseTimeout}\" + timeout = \"#{@responseTimeout}\" tls_ca = \"#{@tlsCa}\" insecure_skip_verify = #{@insecureSkipVerify}\n" end diff --git a/kubernetes/ama-logs.yaml b/kubernetes/ama-logs.yaml index 8db2b7bcb..978823b19 100644 --- a/kubernetes/ama-logs.yaml +++ b/kubernetes/ama-logs.yaml @@ -1059,10 +1059,6 @@ spec: # Uncomment below lines for MSI Auth Mode testing # - name: USING_AAD_MSI_AUTH # value: "true" - - name: HOSTNAME - valueFrom: - fieldRef: - fieldPath: spec.nodeName volumeMounts: # Uncomment below lines when telegraf upgraded to 1.28.5 or higher # - name: kube-api-access From 6432aed849ebff08e81399d6da3fd6e116f63eb6 Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Fri, 23 Feb 2024 16:22:18 -0800 Subject: [PATCH 2/3] remove unused bearer_token from config --- build/common/installer/scripts/tomlparser-prom-customconfig.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/build/common/installer/scripts/tomlparser-prom-customconfig.rb b/build/common/installer/scripts/tomlparser-prom-customconfig.rb index f35edb2e8..2b6e4f9df 100644 --- a/build/common/installer/scripts/tomlparser-prom-customconfig.rb +++ b/build/common/installer/scripts/tomlparser-prom-customconfig.rb @@ -137,7 +137,6 @@ def createPrometheusPluginsWithNamespaceSetting(monitorKubernetesPods, monitorKu fielddrop = #{fieldDropSetting} metric_version = #{@metricVersion} url_tag = \"#{@urlTag}\" - bearer_token = \"#{@bearerToken}\" #{timeout_config_key} = \"#{@responseTimeout}\" tls_ca = \"#{@tlsCa}\" insecure_skip_verify = #{@insecureSkipVerify}\n" From 737821bf24e07c51db644369cf7114750c1dd361 Mon Sep 17 00:00:00 2001 From: Ganga Mahesh Siddem Date: Tue, 27 Feb 2024 17:11:39 -0800 Subject: [PATCH 3/3] fix pr feedback --- kubernetes/windows/setup.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/kubernetes/windows/setup.ps1 b/kubernetes/windows/setup.ps1 index e1044b3a6..c399428ea 100644 --- a/kubernetes/windows/setup.ps1 +++ b/kubernetes/windows/setup.ps1 @@ -38,6 +38,7 @@ Write-Host ('Finished Installing Fluentbit') Write-Host ('Installing Telegraf'); try { + # For next telegraf update, make sure to update config changes in telegraf.conf, tomlparser-prom-customconfig.rb and tomlparser-osm-config.rb $telegrafUri='https://dl.influxdata.com/telegraf/releases/telegraf-1.24.2_windows_amd64.zip' Invoke-WebRequest -Uri $telegrafUri -OutFile /installation/telegraf.zip Expand-Archive -Path /installation/telegraf.zip -Destination /installation/telegraf