mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 08:36:55 +03:00
The commit introduces the `vm_os_info` metric, which is exposed by all VM binaries by default. It provides visibility into the operating system version on which VictoriaMetrics is running, helping with troubleshooting environment-specific issues, like known kernel or fs bugs. FIxes https://github.com/VictoriaMetrics/VictoriaMetrics/issues/10481 PR https://github.com/VictoriaMetrics/VictoriaMetrics/pull/10746 Co-authored-by: Max Kotliar <mkotlyar@victoriametrics.com>
22 lines
603 B
Go
22 lines
603 B
Go
package osinfo
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
|
|
"github.com/VictoriaMetrics/metrics"
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
var windowsRelease string
|
|
|
|
func ExposeAsMetric() {
|
|
ver := windows.RtlGetVersion()
|
|
if ver == nil {
|
|
logger.Warnf("os info wont be exposed as vm_os_info metric; windows.RtlGetVersion returned nil version")
|
|
return
|
|
}
|
|
windowsRelease = fmt.Sprintf("%d.%d.%d", ver.MajorVersion, ver.MinorVersion, ver.BuildNumber)
|
|
_ = metrics.GetOrCreateGauge(fmt.Sprintf(`vm_os_info{os="windows", release=%q}`, windowsRelease), func() float64 { return 1 })
|
|
}
|