-
Notifications
You must be signed in to change notification settings - Fork 260
feat: windows-exporter into windows vhd build #8516
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
4ad14f0
85a6a6b
1d1f938
94a6d6a
33a62df
b533a02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -325,6 +325,12 @@ if (Test-Path -Path 'c:\AzureData\windows\securetlsbootstrapfunc.ps1') { | |
| Write-Log "Windows Secure TLS Bootstrap function script not found, skipping dot-source" | ||
| } | ||
|
|
||
| if (Test-Path -Path 'c:\AzureData\windows\windowsexporterfunc.ps1') { | ||
| . c:\AzureData\windows\windowsexporterfunc.ps1 | ||
| } else { | ||
| Write-Log "Windows Exporter function script not found, skipping dot-source" | ||
| } | ||
|
|
||
| if (Test-Path -Path 'c:\AzureData\windows\windowsciliumnetworkingfunc.ps1') { | ||
| . c:\AzureData\windows\windowsciliumnetworkingfunc.ps1 | ||
| } else { | ||
|
|
@@ -508,6 +514,16 @@ function BasePrep { | |
| Install-GmsaPlugin -GmsaPackageUrl $global:WindowsGmsaPackageUrl | ||
| } | ||
|
|
||
| # Register aks-windows-exporter when its assets are baked into the VHD. | ||
| # Wrapped in Get-Command guard for bidirectional compat with older VHDs that don't | ||
| # carry windowsexporterfunc.ps1 in the CSE script package. | ||
| if (Get-Command -Name Install-WindowsExporter -ErrorAction SilentlyContinue) { | ||
| Logs-To-Event -TaskName "AKS.WindowsCSE.InstallWindowsExporter" -TaskMessage "Install aks-windows-exporter if VHD-baked" | ||
| Install-WindowsExporter | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused. Are we installing and configuring windows exporter during VHD Bake time or during Node Provisioning time? This PR seems to do both. But it only does the installation during node provisioning time if the script to install windows exporter is on the VHD already - which means it will have been done during VHD bake time.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the func being calling "Install-WindowsExporter" might be a bit strong here. During VHD build we add the binarys and config. Then during CSE we use NSSM to create the aks-windows-exporter service(?) and start it and make sure it's healthy. maybe registering/setup would be better than install here |
||
| } else { | ||
| Write-Log "Install-WindowsExporter not available; aks-vm-extension will manage windows-exporter" | ||
| } | ||
|
|
||
| Write-Log "BasePrep completed successfully" | ||
| Logs-To-Event -TaskName "AKS.WindowsCSE.BasePrep" -TaskMessage "BasePrep completed successfully" | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| web: | ||
| listen-address: ":19182" | ||
| collectors: | ||
| # explicitly enabled for version: https://github.com/prometheus-community/windows_exporter/tree/v0.31.2 | ||
| # NOTE: `cpu_info`, `container` and `process` collectors are added to default collectors | ||
| enabled: "cpu,logical_disk,memory,net,os,physical_disk,service,system,cpu_info,container,process" | ||
| collector: | ||
| service: | ||
| include: "aks-windows-exporter|kubelet|kubeproxy|containerd|hns|csi-proxy" | ||
| log: | ||
| level: debug | ||
|
chmill-zz marked this conversation as resolved.
chmill-zz marked this conversation as resolved.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
|
|
||
| function Invoke-WindowsExporterRequest { | ||
| param([Parameter(Mandatory=$true)][string]$Path) | ||
|
|
||
| try { | ||
| $response = Invoke-WebRequest -UseBasicParsing -Uri "http://localhost:19182/$Path" -TimeoutSec 10 -ErrorAction Stop | ||
| return [string]$response.Content | ||
| } | ||
| catch { | ||
| return "" | ||
| } | ||
| } | ||
|
|
||
| function Get-Health { | ||
| $result = Invoke-WindowsExporterRequest -Path "health" | ||
| if ($null -ne $result -and $result.Contains("ok")) { | ||
| return $result | ||
| } else { | ||
| return "" | ||
| } | ||
| } | ||
|
|
||
| function Get-Version { | ||
| $result = Invoke-WindowsExporterRequest -Path "version" | ||
| if ($null -ne $result -and $result.Contains("version")) { | ||
| # {"version":"v0.25.1","revision":"f70fa009de541dc99ed210aa7e67c9550133ef02","branch":"HEAD","buildUser":"cloudtest@781d70d7c000002","buildDate":"20240223-08:06:57","goVersion":"go1.21.3"} | ||
| $version = $result -replace ".*""version"":""([^""]+)"".*", '$1' | ||
| return $version | ||
| } else { | ||
| return "" | ||
| } | ||
|
chmill-zz marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| function Get-MetricsExample { | ||
| # The result may be too large in production node. I suggest to call it only when testing. | ||
| $result = Invoke-WindowsExporterRequest -Path "metrics" | ||
| $example = "windows_process_cpu_time_total" | ||
| if ($result -match $example) { | ||
| $example = $result -split "`n" | Where-Object {$_ -match $example} | Select-Object -Last 1 | ||
| return $example | ||
| } else { | ||
| return "" | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.