Skip to content

Commit 9a8808d

Browse files
authored
Gangams/windows telegraf update (#1359)
* update to latest available telegraf version for windows * fix configpath format
1 parent 346906c commit 9a8808d

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

build/common/installer/scripts/tomlparser-prom-customconfig.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,6 @@ def createPrometheusPluginsWithNamespaceSetting(monitorKubernetesPods, monitorKu
114114
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")
115115

116116
timeout_config_key = "timeout"
117-
if is_windows?
118-
# For windows, the timeout config key is different because of old version of telegraf
119-
timeout_config_key = "response_timeout"
120-
end
121-
122117
pluginConfigsWithNamespaces = ""
123118
monitorKubernetesPodsNamespaces.each do |namespace|
124119
if !namespace.nil?

build/windows/installer/conf/telegraf.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
#Prometheus Custom Metrics
125125
[[inputs.prometheus]]
126126
interval = "$AZMON_TELEGRAF_CUSTOM_PROM_INTERVAL"
127-
127+
128128
## Scrape Kubernetes pods for the following prometheus annotations:
129129
## - prometheus.io/scrape: Enable scraping for this pod
130130
## - prometheus.io/scheme: If the metrics endpoint is secured then you will need to
@@ -150,7 +150,7 @@
150150
# bearer_token_string = "abc_123"
151151

152152
## Specify timeout duration for slower prometheus clients (default is 3s)
153-
response_timeout = "15s"
153+
timeout = "15s"
154154

155155
## Optional TLS Config
156156
tls_ca = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"

kubernetes/windows/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ ENV APPLICATIONINSIGHTS_AUTH "NzAwZGM5OGYtYTdhZC00NThkLWI5NWMtMjA3ZjM3NmM3YmRi"
102102
ENV AZMON_COLLECT_ENV False
103103
ENV CI_CERT_LOCATION "C://oms.crt"
104104
ENV CI_KEY_LOCATION "C://oms.key"
105+
ENV TELEGRAF_CONFIG_PATH "/etc/telegraf/telegraf.conf"
105106

106107
# Delete unnecessary files
107108
RUN powershell -Command "Remove-Item -Recurse -Force 'C:\ruby31\share\doc\ruby\html\js'; \

kubernetes/windows/main.ps1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,15 @@ function Start-Telegraf {
812812
Write-Host "Failed to set environment variable NODE_IP for target 'machine' since it is either null or empty"
813813
}
814814

815+
$telegrafConfigPath = [System.Environment]::GetEnvironmentVariable("TELEGRAF_CONFIG_PATH", "process")
816+
if (![string]::IsNullOrEmpty($telegrafConfigPath)) {
817+
[System.Environment]::SetEnvironmentVariable("TELEGRAF_CONFIG_PATH", $telegrafConfigPath, "machine")
818+
Write-Host "Successfully set environment variable TELEGRAF_CONFIG_PATH - $($telegrafConfigPath) for target 'machine'..."
819+
}
820+
else {
821+
Write-Host "Failed to set environment variable TELEGRAF_CONFIG_PATH for target 'machine' since it is either null or empty"
822+
}
823+
815824
$hostName = [System.Environment]::GetEnvironmentVariable("HOSTNAME", "process")
816825
Write-Host "nodename: $($hostName)"
817826
Write-Host "replacing nodename in telegraf config"
@@ -843,8 +852,8 @@ function Start-Telegraf {
843852
}
844853
Write-Host "Running telegraf service in test mode"
845854
C:\opt\telegraf\telegraf.exe --config "C:\etc\telegraf\telegraf.conf" --test
846-
Write-Host "Starting telegraf service"
847-
C:\opt\telegraf\telegraf.exe --service start
855+
Write-Host "Starting telegraf service with auto restart"
856+
C:\opt\telegraf\telegraf.exe --service-auto-restart
848857

849858
# Trying to start telegraf again if it did not start due to fluent bit not being ready at startup
850859
Get-Service telegraf | findstr Running

kubernetes/windows/setup.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Write-Host ('Finished Installing Fluentbit')
4242
Write-Host ('Installing Telegraf');
4343
try {
4444
# For next telegraf update, make sure to update config changes in telegraf.conf, tomlparser-prom-customconfig.rb and tomlparser-osm-config.rb
45-
$telegrafUri='https://dl.influxdata.com/telegraf/releases/telegraf-1.24.2_windows_amd64.zip'
45+
$telegrafUri='https://dl.influxdata.com/telegraf/releases/telegraf-1.33.1_windows_amd64.zip'
4646
Invoke-WebRequest -Uri $telegrafUri -OutFile /installation/telegraf.zip
4747
Expand-Archive -Path /installation/telegraf.zip -Destination /installation/telegraf
4848
Move-Item -Path /installation/telegraf/*/* -Destination /opt/telegraf/ -ErrorAction SilentlyContinue

0 commit comments

Comments
 (0)