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

Gangams/windows telegraf update #1359

Merged
merged 6 commits into from
Feb 21, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ def createPrometheusPluginsWithNamespaceSetting(monitorKubernetesPods, monitorKu
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?
Expand Down
4 changes: 2 additions & 2 deletions build/windows/installer/conf/telegraf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
#Prometheus Custom Metrics
[[inputs.prometheus]]
interval = "$AZMON_TELEGRAF_CUSTOM_PROM_INTERVAL"

## Scrape Kubernetes pods for the following prometheus annotations:
## - prometheus.io/scrape: Enable scraping for this pod
## - prometheus.io/scheme: If the metrics endpoint is secured then you will need to
Expand All @@ -150,7 +150,7 @@
# bearer_token_string = "abc_123"

## Specify timeout duration for slower prometheus clients (default is 3s)
response_timeout = "15s"
timeout = "15s"

## Optional TLS Config
tls_ca = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
Expand Down
1 change: 1 addition & 0 deletions kubernetes/windows/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ ENV APPLICATIONINSIGHTS_AUTH "NzAwZGM5OGYtYTdhZC00NThkLWI5NWMtMjA3ZjM3NmM3YmRi"
ENV AZMON_COLLECT_ENV False
ENV CI_CERT_LOCATION "C://oms.crt"
ENV CI_KEY_LOCATION "C://oms.key"
ENV TELEGRAF_CONFIG_PATH "/etc/telegraf/telegraf.conf"

# Delete unnecessary files
RUN powershell -Command "Remove-Item -Recurse -Force 'C:\ruby31\share\doc\ruby\html\js'; \
Expand Down
13 changes: 11 additions & 2 deletions kubernetes/windows/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,15 @@ function Start-Telegraf {
Write-Host "Failed to set environment variable NODE_IP for target 'machine' since it is either null or empty"
}

$telegrafConfigPath = [System.Environment]::GetEnvironmentVariable("TELEGRAF_CONFIG_PATH", "process")
if (![string]::IsNullOrEmpty($telegrafConfigPath)) {
[System.Environment]::SetEnvironmentVariable("TELEGRAF_CONFIG_PATH", $telegrafConfigPath, "machine")
Write-Host "Successfully set environment variable TELEGRAF_CONFIG_PATH - $($telegrafConfigPath) for target 'machine'..."
}
else {
Write-Host "Failed to set environment variable TELEGRAF_CONFIG_PATH for target 'machine' since it is either null or empty"
}

$hostName = [System.Environment]::GetEnvironmentVariable("HOSTNAME", "process")
Write-Host "nodename: $($hostName)"
Write-Host "replacing nodename in telegraf config"
Expand Down Expand Up @@ -843,8 +852,8 @@ function Start-Telegraf {
}
Write-Host "Running telegraf service in test mode"
C:\opt\telegraf\telegraf.exe --config "C:\etc\telegraf\telegraf.conf" --test
Write-Host "Starting telegraf service"
C:\opt\telegraf\telegraf.exe --service start
Write-Host "Starting telegraf service with auto restart"
C:\opt\telegraf\telegraf.exe --service-auto-restart

# Trying to start telegraf again if it did not start due to fluent bit not being ready at startup
Get-Service telegraf | findstr Running
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/windows/setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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'
$telegrafUri='https://dl.influxdata.com/telegraf/releases/telegraf-1.33.1_windows_amd64.zip'
Invoke-WebRequest -Uri $telegrafUri -OutFile /installation/telegraf.zip
Expand-Archive -Path /installation/telegraf.zip -Destination /installation/telegraf
Move-Item -Path /installation/telegraf/*/* -Destination /opt/telegraf/ -ErrorAction SilentlyContinue
Expand Down
Loading