mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-10-17 18:19:04 +02:00
Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Claude <noreply@anthropic.com>
4.3 KiB
4.3 KiB
mscluster agent notes
- All subcollectors read through ClusAPI
(
internal/headers/clusapi) instead of theroot\MSClusterWMI provider (ClusWMI.dll). The WMI provider is a thin layer over ClusAPI: most WMI properties are common properties fromCLUSCTL_<OBJECT>_GET_RO_COMMON_PROPERTIESandCLUSCTL_<OBJECT>_GET_COMMON_PROPERTIES;Characteristics,FlagsandStatecome from their own control codes andGetCluster<Object>State. Some WMI values are synthesized or never filled (published as 0 from NULL); the parity tests show which ones, and the collector reproduces them. - Keep WMI types when publishing:
sint32properties (for exampleFailbackWindowStart) are converted from the raw 32-bit value withint32,uint32properties keep the unsigned bit pattern. Unknown states (-1) are values, as in WMI, not errors. - Each subcollector owns its own
clusapi.Cluster. AClusterruns one call at a time without holding its lock: ClusAPI RPCs cannot be cancelled, so a second call fails withclusapi.ErrBusy, andCloseleaves the handle to the running call.callSourcestops waiting at the scrape budget, so one stuck RPC does not holdCollectand the other subcollectors. closeSourcesdrops a source even when itsClosefails, soBuildcan recreate it. Grafana Alloy callsBuild/Closerepeatedly.- Every subcollector has a fixture test that checks gathered metric families
and a parity test against its WMI class. The CI cluster (
setup-msclusterin.github/workflows/ci.yml) is a single node without storage or administrative access point. It has online, offline and failed resources in two groups (CIResources,CIFailedResources) on a private network of an internal Hyper-V switch; the parity tests require them. It has no clustered disks, so shared volume parity still compares empty sets. The "Cluster Group" also holds an offline "Health Service" resource without Storage Spaces Direct. It answersCLUSCTL_RESOURCE_GET_CLASS_INFOwith only 4 bytes, like the Health resource of S2D clusters (#2669). S2D itself cannot be enabled on the runner: it claims every VHDX disk of the other steps, andSet-ClusterStorageSpacesDirectDisk -CanBeClaimed $falseremoves those disks from the host instead of leaving them alone. Disks from a loopback iSCSI target (withS2DBusTypeslimited to iSCSI) appear beforeNew-Cluster, but the session and the target are gone after it: once the node is clustered, the iSCSI Target Server only serves clustered targets. A clustered target needs a cluster disk for its files, andGet-ClusterAvailableDiskdoes not list a host-mounted VHDX. - Property lists returned by the cluster service end with an extra
CLUSPROP_SYNTAX_ENDMARKafter the last value list; fixtures built only from the documentation miss this. The parser validates only the structure and accepts zero padding.TestDumpPropertyListslogs real lists as hex whenWINDOWS_EXPORTER_TEST_CLUSAPI_DUMPis set on a cluster node. - Each
Clusterowns one control buffer (controlScratch). Like the handle, it belongs to the running call, so calls never share it and nosync.Poolis needed.ParsePropertiesreturnsProperty.Dataslices into it: copy values out (copyResourceProperties,readCommonProperties) before the next control, and never keep a parsed list past that point.getzeroes the bytes, so a reused buffer reads like a new one. clusapi.Openreports an unconfigured cluster or a missing ClusAPI witherrors.ErrUnsupported; the shared collector test treats that as an unsupported role on hosts wheremsclusteris not a required fixture.- Use
ClusterOpenEnumand theOpen*Exfunctions (Windows Server 2008 R2+), notClusterOpenEnumEx(Windows Server 2016+), to keep Windows Server 2012 R2 support. - Cluster, network, node, group and resource metrics are reused between
scrapes through
internal/metriccachewhen every input is unchanged. A cache value must hold every input of the cached series: field values and whether each field is published (appendObjectFieldsKey, which resolves the build-dependent rules ofobjectField), owner node and node names. Objects with missing fields are not cached, so they report the same errors on every scrape. Shared volume sizes change constantly and are not cached.