Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix telegraf config related fixes #1176

Merged
merged 4 commits into from
Feb 28, 2024
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
21 changes: 15 additions & 6 deletions build/common/installer/scripts/tomlparser-prom-customconfig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
pfrcks marked this conversation as resolved.
Show resolved Hide resolved
timeout_config_key = "response_timeout"
end

pluginConfigsWithNamespaces = ""
monitorKubernetesPodsNamespaces.each do |namespace|
if !namespace.nil?
Expand All @@ -127,8 +137,7 @@ def createPrometheusPluginsWithNamespaceSetting(monitorKubernetesPods, monitorKu
fielddrop = #{fieldDropSetting}
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
Expand Down Expand Up @@ -262,7 +271,7 @@ def populateSettingValuesFromConfigMap(parsedConfig)
end
elsif @controller.casecmp(@daemonset) == 0 &&
(([email protected]? && @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
Expand Down Expand Up @@ -290,7 +299,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"
Expand Down Expand Up @@ -346,8 +355,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)
Expand Down
2 changes: 1 addition & 1 deletion build/linux/installer/scripts/tomlparser-osm-config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions kubernetes/ama-logs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions kubernetes/windows/setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading