feat(inputs.system): Add operating-system information#18834
Conversation
|
@skartikey @srebhan @Hipska Hi, could you take a look at this PR when you have a moment? |
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
Co-authored-by: Sven Rebhan <36194019+srebhan@users.noreply.github.com>
srebhan
left a comment
There was a problem hiding this comment.
One more thing I noticed. Sorry for the initial noise. :-(
|
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 📦 Click here to get additional PR build artifactsArtifact URLs |
|
@skartikey Thanks for the review! Addressed both comments. Not 100% sure the test approach is exactly what you had in mind. I went with |
That works for me. The os-release-parsed values are now actually verified, which was the main concern, and the separate non-empty checks for arch/kernel_version cover the host-dependent fields. Thanks for the quick turnaround. Approved. |
Summary
This is the second step of the plan agreed in #18533: add an
osvalueto the
includeoption ofinputs.systemthat emits a separatesystem_osmeasurement with operating system release andunameinformation.
The data is gathered through
gopsutilfor cross-platform support andis read with the granular
host.PlatformInformation(),host.KernelVersion()andhost.KernelArch()calls instead ofhost.Info()to avoid unrelated probes for virtualization, boot timeand process counts.
The result is cached for
os_cache_ttl(default5m) between gatherssince these values are effectively static at runtime; setting
os_cache_ttl = "0s"keeps the cache for the lifetime of theprocess, while a tiny positive value such as
"1ns"effectivelydisables the cache and forces a fresh read on every gather. The TTL
handling matches the convention used by
inputs.sqlserver,inputs.logql,inputs.promql,outputs.iotdbandoutputs.parquetwhere a zero duration disables the time bound.Fields emitted by the
system_osmeasurementosruntime.GOOSplatform/etc/os-releaseetc.platform_family/etc/os-releaseetc.platform_version/etc/os-releaseetc.kernel_versionuname -rkernel_archuname -mOn platforms where gopsutil cannot provide a particular value (e.g.
parts of FreeBSD/OpenBSD/Solaris) the corresponding field is left
empty; if no field can be gathered the metric is skipped entirely.
Backward compatibility
The default
includeset is unchanged, so existing deployments keepemitting only the
systemmeasurement and do not see the newsystem_osmetric until they opt in.Example output
Checklist