diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cbfe4941..bde26b08 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -91,5 +91,5 @@ jobs: uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0 with: # renovate: github=golangci/golangci-lint - version: v2.1.6 + version: v2.2.1 args: "--max-same-issues=0" diff --git a/.golangci.yaml b/.golangci.yaml index 7f83057b..c230469a 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -19,11 +19,13 @@ linters: - lll - maintidx - mnd + - noinlineerr - paralleltest - tagliatelle - testpackage - varnamelen - wrapcheck + - wsl settings: forbidigo: forbid: @@ -62,6 +64,13 @@ linters: disable: - fieldalignment - shadow + revive: + rules: + - name: var-naming + arguments: + - [ ] # AllowList - do not remove as args for the rule are positional and won't work without lists first + - [ ] # DenyList + - - skip-package-name-checks: true sloglint: no-mixed-args: true kv-only: false diff --git a/cmd/windows_exporter/0_service.go b/cmd/windows_exporter/0_service.go index 2fb61bcf..ec054adb 100644 --- a/cmd/windows_exporter/0_service.go +++ b/cmd/windows_exporter/0_service.go @@ -102,6 +102,7 @@ type windowsExporterService struct{} // Execute is the entry point for the Windows service manager. func (s *windowsExporterService) Execute(_ []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (bool, uint32) { changes <- svc.Status{State: svc.StartPending} + // Send a signal to the main function that the service is running. changes <- svc.Status{State: svc.Running, Accepts: svc.AcceptStop | svc.AcceptShutdown} for { @@ -179,6 +180,7 @@ func logToFile(msg string) { // https://github.com/DataDog/datadog-agent/blob/46740e82ef40a04c4be545ed8c16a4b0d1f046cf/pkg/util/winutil/servicemain/servicemain.go#L128 func isWindowsService() (bool, error) { var currentProcess windows.PROCESS_BASIC_INFORMATION + infoSize := uint32(unsafe.Sizeof(currentProcess)) err := windows.NtQueryInformationProcess(windows.CurrentProcess(), windows.ProcessBasicInformation, unsafe.Pointer(¤tProcess), infoSize, &infoSize) diff --git a/cmd/windows_exporter/main_test.go b/cmd/windows_exporter/main_test.go index 7681d47a..99612354 100644 --- a/cmd/windows_exporter/main_test.go +++ b/cmd/windows_exporter/main_test.go @@ -189,7 +189,6 @@ func waitUntilListening(tb testing.TB, network, address string) error { } var winErr windows.Errno - if errors.As(err, &winErr) { return fmt.Errorf("listener not listening: %w (#%d)", winErr, uint32(winErr)) } diff --git a/internal/collector/ad/ad.go b/internal/collector/ad/ad.go index 0ad49cbf..c3f3b142 100644 --- a/internal/collector/ad/ad.go +++ b/internal/collector/ad/ad.go @@ -532,30 +532,35 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { c.perfDataObject[0].AbANRPerSec, "ambiguous_name_resolution", ) + ch <- prometheus.MustNewConstMetric( c.addressBookOperationsTotal, prometheus.CounterValue, c.perfDataObject[0].AbBrowsesPerSec, "browse", ) + ch <- prometheus.MustNewConstMetric( c.addressBookOperationsTotal, prometheus.CounterValue, c.perfDataObject[0].AbMatchesPerSec, "find", ) + ch <- prometheus.MustNewConstMetric( c.addressBookOperationsTotal, prometheus.CounterValue, c.perfDataObject[0].AbPropertyReadsPerSec, "property_read", ) + ch <- prometheus.MustNewConstMetric( c.addressBookOperationsTotal, prometheus.CounterValue, c.perfDataObject[0].AbSearchesPerSec, "search", ) + ch <- prometheus.MustNewConstMetric( c.addressBookOperationsTotal, prometheus.CounterValue, @@ -580,22 +585,26 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.GaugeValue, c.perfDataObject[0].AtqEstimatedQueueDelay/1000, ) + ch <- prometheus.MustNewConstMetric( c.atqOutstandingRequests, prometheus.GaugeValue, c.perfDataObject[0].AtqOutstandingQueuedRequests, ) + ch <- prometheus.MustNewConstMetric( c.atqAverageRequestLatency, prometheus.GaugeValue, c.perfDataObject[0].AtqRequestLatency, ) + ch <- prometheus.MustNewConstMetric( c.atqCurrentThreads, prometheus.GaugeValue, c.perfDataObject[0].AtqThreadsLDAP, "ldap", ) + ch <- prometheus.MustNewConstMetric( c.atqCurrentThreads, prometheus.GaugeValue, @@ -609,12 +618,14 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { c.perfDataObject[0].BaseSearchesPerSec, "base", ) + ch <- prometheus.MustNewConstMetric( c.searchesTotal, prometheus.CounterValue, c.perfDataObject[0].SubtreeSearchesPerSec, "subtree", ) + ch <- prometheus.MustNewConstMetric( c.searchesTotal, prometheus.CounterValue, @@ -628,18 +639,21 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { c.perfDataObject[0].DatabaseAddsPerSec, "add", ) + ch <- prometheus.MustNewConstMetric( c.databaseOperationsTotal, prometheus.CounterValue, c.perfDataObject[0].DatabaseDeletesPerSec, "delete", ) + ch <- prometheus.MustNewConstMetric( c.databaseOperationsTotal, prometheus.CounterValue, c.perfDataObject[0].DatabaseModifiesPerSec, "modify", ) + ch <- prometheus.MustNewConstMetric( c.databaseOperationsTotal, prometheus.CounterValue, @@ -653,48 +667,56 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { c.perfDataObject[0].DigestBindsPerSec, "digest", ) + ch <- prometheus.MustNewConstMetric( c.bindsTotal, prometheus.CounterValue, c.perfDataObject[0].DsClientBindsPerSec, "ds_client", ) + ch <- prometheus.MustNewConstMetric( c.bindsTotal, prometheus.CounterValue, c.perfDataObject[0].DsServerBindsPerSec, "ds_server", ) + ch <- prometheus.MustNewConstMetric( c.bindsTotal, prometheus.CounterValue, c.perfDataObject[0].ExternalBindsPerSec, "external", ) + ch <- prometheus.MustNewConstMetric( c.bindsTotal, prometheus.CounterValue, c.perfDataObject[0].FastBindsPerSec, "fast", ) + ch <- prometheus.MustNewConstMetric( c.bindsTotal, prometheus.CounterValue, c.perfDataObject[0].NegotiatedBindsPerSec, "negotiate", ) + ch <- prometheus.MustNewConstMetric( c.bindsTotal, prometheus.CounterValue, c.perfDataObject[0].NTLMBindsPerSec, "ntlm", ) + ch <- prometheus.MustNewConstMetric( c.bindsTotal, prometheus.CounterValue, c.perfDataObject[0].SimpleBindsPerSec, "simple", ) + ch <- prometheus.MustNewConstMetric( c.bindsTotal, prometheus.CounterValue, @@ -708,6 +730,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { float64(uint64(c.perfDataObject[0].DRAHighestUSNCommittedHighPart)<<32)+c.perfDataObject[0].DRAHighestUSNCommittedLowPart, "committed", ) + ch <- prometheus.MustNewConstMetric( c.replicationHighestUsn, prometheus.CounterValue, @@ -746,6 +769,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { c.perfDataObject[0].DRAInboundBytesNotCompressedWithinSitePerSec, "inbound", ) + ch <- prometheus.MustNewConstMetric( c.intraSiteReplicationDataBytesTotal, prometheus.CounterValue, @@ -770,6 +794,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].DRAInboundObjectsAppliedPerSec, ) + ch <- prometheus.MustNewConstMetric( c.replicationInboundObjectsFilteredTotal, prometheus.CounterValue, @@ -781,6 +806,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].DRAInboundPropertiesAppliedPerSec, ) + ch <- prometheus.MustNewConstMetric( c.replicationInboundPropertiesFilteredTotal, prometheus.CounterValue, @@ -792,6 +818,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.GaugeValue, c.perfDataObject[0].DRAPendingReplicationOperations, ) + ch <- prometheus.MustNewConstMetric( c.replicationPendingSynchronizations, prometheus.GaugeValue, @@ -803,11 +830,13 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].DRASyncRequestsMade, ) + ch <- prometheus.MustNewConstMetric( c.replicationSyncRequestsSuccessTotal, prometheus.CounterValue, c.perfDataObject[0].DRASyncRequestsSuccessful, ) + ch <- prometheus.MustNewConstMetric( c.replicationSyncRequestsSchemaMismatchFailureTotal, prometheus.CounterValue, @@ -820,6 +849,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { c.perfDataObject[0].DsClientNameTranslationsPerSec, "client", ) + ch <- prometheus.MustNewConstMetric( c.nameTranslationsTotal, prometheus.CounterValue, @@ -832,6 +862,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.GaugeValue, c.perfDataObject[0].DsMonitorListSize, ) + ch <- prometheus.MustNewConstMetric( c.changeMonitorUpdatesPending, prometheus.GaugeValue, @@ -843,6 +874,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].DsNameCacheHitRate, ) + ch <- prometheus.MustNewConstMetric( c.nameCacheLookupsTotal, prometheus.CounterValue, @@ -856,6 +888,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "read", "replication_agent", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -863,6 +896,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "read", "knowledge_consistency_checker", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -870,6 +904,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "read", "local_security_authority", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -877,6 +912,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "read", "name_service_provider_interface", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -884,6 +920,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "read", "directory_service_api", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -891,6 +928,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "read", "security_account_manager", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -898,6 +936,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "read", "other", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -905,6 +944,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "search", "replication_agent", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -912,6 +952,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "search", "knowledge_consistency_checker", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -919,6 +960,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "search", "ldap", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -926,6 +968,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "search", "local_security_authority", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -933,6 +976,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "search", "name_service_provider_interface", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -940,6 +984,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "search", "directory_service_api", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -947,6 +992,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "search", "security_account_manager", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -954,6 +1000,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "search", "other", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -961,6 +1008,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "write", "replication_agent", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -968,6 +1016,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "write", "knowledge_consistency_checker", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -975,6 +1024,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "write", "ldap", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -982,6 +1032,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "write", "local_security_authority", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -989,6 +1040,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "write", "name_service_provider_interface", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -996,6 +1048,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "write", "directory_service_api", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -1003,6 +1056,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { "write", "security_account_manager", ) + ch <- prometheus.MustNewConstMetric( c.directoryOperationsTotal, prometheus.CounterValue, @@ -1022,16 +1076,19 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].DsSecurityDescriptorSubOperationsPerSec, ) + ch <- prometheus.MustNewConstMetric( c.securityDescriptorPropagationEventsQueued, prometheus.GaugeValue, c.perfDataObject[0].DsSecurityDescriptorPropagationsEvents, ) + ch <- prometheus.MustNewConstMetric( c.securityDescriptorPropagationAccessWaitTotalSeconds, prometheus.GaugeValue, c.perfDataObject[0].DsSecurityDescriptorPropagatorAverageExclusionTime, ) + ch <- prometheus.MustNewConstMetric( c.securityDescriptorPropagationItemsQueuedTotal, prometheus.CounterValue, @@ -1049,12 +1106,14 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].LdapClosedConnectionsPerSec, ) + ch <- prometheus.MustNewConstMetric( c.ldapOpenedConnectionsTotal, prometheus.CounterValue, c.perfDataObject[0].LdapNewConnectionsPerSec, "ldap", ) + ch <- prometheus.MustNewConstMetric( c.ldapOpenedConnectionsTotal, prometheus.CounterValue, @@ -1085,11 +1144,13 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].LdapUDPOperationsPerSec, ) + ch <- prometheus.MustNewConstMetric( c.ldapWritesTotal, prometheus.CounterValue, c.perfDataObject[0].LdapWritesPerSec, ) + ch <- prometheus.MustNewConstMetric( c.ldapClientSessions, prometheus.GaugeValue, @@ -1107,6 +1168,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].PhantomsCleanedPerSec, ) + ch <- prometheus.MustNewConstMetric( c.phantomObjectsVisitedTotal, prometheus.CounterValue, @@ -1119,18 +1181,21 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { c.perfDataObject[0].SamGlobalGroupMembershipEvaluationsPerSec, "global", ) + ch <- prometheus.MustNewConstMetric( c.samGroupMembershipEvaluationsTotal, prometheus.CounterValue, c.perfDataObject[0].SamDomainLocalGroupMembershipEvaluationsPerSec, "domain_local", ) + ch <- prometheus.MustNewConstMetric( c.samGroupMembershipEvaluationsTotal, prometheus.CounterValue, c.perfDataObject[0].SamUniversalGroupMembershipEvaluationsPerSec, "universal", ) + ch <- prometheus.MustNewConstMetric( c.samGroupMembershipGlobalCatalogEvaluationsTotal, prometheus.CounterValue, @@ -1142,6 +1207,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].SamNonTransitiveMembershipEvaluationsPerSec, ) + ch <- prometheus.MustNewConstMetric( c.samGroupMembershipEvaluationsTransitiveTotal, prometheus.CounterValue, @@ -1154,6 +1220,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { c.perfDataObject[0].SamAccountGroupEvaluationLatency, "account_group", ) + ch <- prometheus.MustNewConstMetric( c.samGroupEvaluationLatency, prometheus.GaugeValue, @@ -1166,6 +1233,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].SamSuccessfulComputerCreationsPerSecIncludesAllRequests, ) + ch <- prometheus.MustNewConstMetric( c.samComputerCreationSuccessfulRequestsTotal, prometheus.CounterValue, @@ -1177,6 +1245,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].SamUserCreationAttemptsPerSec, ) + ch <- prometheus.MustNewConstMetric( c.samUserCreationSuccessfulRequestsTotal, prometheus.CounterValue, @@ -1188,6 +1257,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].SamDisplayInformationQueriesPerSec, ) + ch <- prometheus.MustNewConstMetric( c.samEnumerationsTotal, prometheus.CounterValue, @@ -1211,6 +1281,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].TombstonesGarbageCollectedPerSec, ) + ch <- prometheus.MustNewConstMetric( c.tombstonesObjectsVisitedTotal, prometheus.CounterValue, diff --git a/internal/collector/adcs/adcs.go b/internal/collector/adcs/adcs.go index f013b513..9ec98305 100644 --- a/internal/collector/adcs/adcs.go +++ b/internal/collector/adcs/adcs.go @@ -186,72 +186,84 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { data.RequestsPerSecond, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.requestProcessingTime, prometheus.GaugeValue, utils.MilliSecToSec(data.RequestProcessingTime), data.Name, ) + ch <- prometheus.MustNewConstMetric( c.retrievalsPerSecond, prometheus.CounterValue, data.RetrievalsPerSecond, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.retrievalProcessingTime, prometheus.GaugeValue, utils.MilliSecToSec(data.RetrievalProcessingTime), data.Name, ) + ch <- prometheus.MustNewConstMetric( c.failedRequestsPerSecond, prometheus.CounterValue, data.FailedRequestsPerSecond, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.issuedRequestsPerSecond, prometheus.CounterValue, data.IssuedRequestsPerSecond, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.pendingRequestsPerSecond, prometheus.CounterValue, data.PendingRequestsPerSecond, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.requestCryptographicSigningTime, prometheus.GaugeValue, utils.MilliSecToSec(data.RequestCryptographicSigningTime), data.Name, ) + ch <- prometheus.MustNewConstMetric( c.requestPolicyModuleProcessingTime, prometheus.GaugeValue, utils.MilliSecToSec(data.RequestPolicyModuleProcessingTime), data.Name, ) + ch <- prometheus.MustNewConstMetric( c.challengeResponsesPerSecond, prometheus.CounterValue, data.ChallengeResponsesPerSecond, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.challengeResponseProcessingTime, prometheus.GaugeValue, utils.MilliSecToSec(data.ChallengeResponseProcessingTime), data.Name, ) + ch <- prometheus.MustNewConstMetric( c.signedCertificateTimestampListsPerSecond, prometheus.CounterValue, data.SignedCertificateTimestampListsPerSecond, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.signedCertificateTimestampListProcessingTime, prometheus.GaugeValue, diff --git a/internal/collector/container/container.go b/internal/collector/container/container.go index 20a086af..0f496557 100644 --- a/internal/collector/container/container.go +++ b/internal/collector/container/container.go @@ -437,6 +437,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe 1, containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, "false", ) + ch <- prometheus.MustNewConstMetric( c.usageCommitBytes, prometheus.GaugeValue, @@ -444,6 +445,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.usageCommitPeakBytes, prometheus.GaugeValue, @@ -451,6 +453,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.usagePrivateWorkingSetBytes, prometheus.GaugeValue, @@ -458,6 +461,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.runtimeTotal, prometheus.CounterValue, @@ -465,6 +469,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.runtimeUser, prometheus.CounterValue, @@ -472,6 +477,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.runtimeKernel, prometheus.CounterValue, @@ -479,6 +485,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.readCountNormalized, prometheus.CounterValue, @@ -486,6 +493,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.readSizeBytes, prometheus.CounterValue, @@ -493,6 +501,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.writeCountNormalized, prometheus.CounterValue, @@ -500,6 +509,7 @@ func (c *Collector) collectHCSContainer(ch chan<- prometheus.Metric, containerDe containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.writeSizeBytes, prometheus.CounterValue, @@ -558,6 +568,7 @@ func (c *Collector) collectNetworkMetrics(ch chan<- prometheus.Metric) error { } var endpointStats iphlpapi.MIB_IF_ROW2 + endpointStats.InterfaceLuid = luid if err := iphlpapi.GetIfEntry2Ex(&endpointStats); err != nil { @@ -597,24 +608,28 @@ func (c *Collector) collectNetworkMetrics(ch chan<- prometheus.Metric) error { float64(endpointStats.OutOctets), containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId, ) + ch <- prometheus.MustNewConstMetric( c.packetsReceived, prometheus.CounterValue, float64(endpointStats.InUcastPkts+endpointStats.InNUcastPkts), containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId, ) + ch <- prometheus.MustNewConstMetric( c.packetsSent, prometheus.CounterValue, float64(endpointStats.OutUcastPkts+endpointStats.OutNUcastPkts), containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId, ) + ch <- prometheus.MustNewConstMetric( c.droppedPacketsIncoming, prometheus.CounterValue, float64(endpointStats.InDiscards+endpointStats.InErrors), containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, endpointId, ) + ch <- prometheus.MustNewConstMetric( c.droppedPacketsOutgoing, prometheus.CounterValue, @@ -768,6 +783,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID 1, containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, "true", ) + ch <- prometheus.MustNewConstMetric( c.usageCommitBytes, prometheus.GaugeValue, @@ -775,6 +791,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.usageCommitPeakBytes, prometheus.GaugeValue, @@ -782,6 +799,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.usagePrivateWorkingSetBytes, prometheus.GaugeValue, @@ -789,6 +807,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.runtimeTotal, prometheus.CounterValue, @@ -796,6 +815,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.runtimeUser, prometheus.CounterValue, @@ -803,6 +823,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.runtimeKernel, prometheus.CounterValue, @@ -810,6 +831,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.readCountNormalized, prometheus.CounterValue, @@ -817,6 +839,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.readSizeBytes, prometheus.CounterValue, @@ -824,6 +847,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.writeCountNormalized, prometheus.CounterValue, @@ -831,6 +855,7 @@ func (c *Collector) collectJobContainer(ch chan<- prometheus.Metric, containerID containerInfo.id, containerInfo.namespace, containerInfo.pod, containerInfo.container, ) + ch <- prometheus.MustNewConstMetric( c.writeSizeBytes, prometheus.CounterValue, diff --git a/internal/collector/cpu/cpu.go b/internal/collector/cpu/cpu.go index 4d2dd06e..31266ef1 100644 --- a/internal/collector/cpu/cpu.go +++ b/internal/collector/cpu/cpu.go @@ -234,12 +234,14 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { coreData.C1TimeSeconds, core, "c1", ) + ch <- prometheus.MustNewConstMetric( c.cStateSecondsTotal, prometheus.CounterValue, coreData.C2TimeSeconds, core, "c2", ) + ch <- prometheus.MustNewConstMetric( c.cStateSecondsTotal, prometheus.CounterValue, @@ -253,24 +255,28 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { coreData.IdleTimeSeconds, core, "idle", ) + ch <- prometheus.MustNewConstMetric( c.timeTotal, prometheus.CounterValue, coreData.InterruptTimeSeconds, core, "interrupt", ) + ch <- prometheus.MustNewConstMetric( c.timeTotal, prometheus.CounterValue, coreData.DpcTimeSeconds, core, "dpc", ) + ch <- prometheus.MustNewConstMetric( c.timeTotal, prometheus.CounterValue, coreData.PrivilegedTimeSeconds, core, "privileged", ) + ch <- prometheus.MustNewConstMetric( c.timeTotal, prometheus.CounterValue, @@ -284,18 +290,21 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { coreData.InterruptsTotal, core, ) + ch <- prometheus.MustNewConstMetric( c.dpcsTotal, prometheus.CounterValue, coreData.DpcQueuedPerSecond, core, ) + ch <- prometheus.MustNewConstMetric( c.clockInterruptsTotal, prometheus.CounterValue, coreData.ClockInterruptsTotal, core, ) + ch <- prometheus.MustNewConstMetric( c.idleBreakEventsTotal, prometheus.CounterValue, @@ -316,30 +325,35 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { coreData.ProcessorFrequencyMHz, core, ) + ch <- prometheus.MustNewConstMetric( c.processorPerformance, prometheus.CounterValue, coreData.ProcessorPerformance, core, ) + ch <- prometheus.MustNewConstMetric( c.processorMPerf, prometheus.CounterValue, counterProcessorMPerfValues.Value(), core, ) + ch <- prometheus.MustNewConstMetric( c.processorRTC, prometheus.CounterValue, counterProcessorRTCValues.Value(), core, ) + ch <- prometheus.MustNewConstMetric( c.processorUtility, prometheus.CounterValue, coreData.ProcessorUtilityRate, core, ) + ch <- prometheus.MustNewConstMetric( c.processorPrivilegedUtility, prometheus.CounterValue, diff --git a/internal/collector/cpu_info/cpu_info.go b/internal/collector/cpu_info/cpu_info.go index db6f2c14..5964be7c 100644 --- a/internal/collector/cpu_info/cpu_info.go +++ b/internal/collector/cpu_info/cpu_info.go @@ -194,36 +194,42 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { strconv.Itoa(int(processor.Family)), strings.TrimRight(processor.Name, " "), ) + ch <- prometheus.MustNewConstMetric( c.cpuCoreCount, prometheus.GaugeValue, float64(processor.NumberOfCores), strings.TrimRight(processor.DeviceID, " "), ) + ch <- prometheus.MustNewConstMetric( c.cpuEnabledCoreCount, prometheus.GaugeValue, float64(processor.NumberOfEnabledCore), strings.TrimRight(processor.DeviceID, " "), ) + ch <- prometheus.MustNewConstMetric( c.cpuLogicalProcessorsCount, prometheus.GaugeValue, float64(processor.NumberOfLogicalProcessors), strings.TrimRight(processor.DeviceID, " "), ) + ch <- prometheus.MustNewConstMetric( c.cpuThreadCount, prometheus.GaugeValue, float64(processor.ThreadCount), strings.TrimRight(processor.DeviceID, " "), ) + ch <- prometheus.MustNewConstMetric( c.cpuL2CacheSize, prometheus.GaugeValue, float64(processor.L2CacheSize), strings.TrimRight(processor.DeviceID, " "), ) + ch <- prometheus.MustNewConstMetric( c.cpuL3CacheSize, prometheus.GaugeValue, diff --git a/internal/collector/diskdrive/diskdrive.go b/internal/collector/diskdrive/diskdrive.go index 2ecca7bc..74f986f9 100644 --- a/internal/collector/diskdrive/diskdrive.go +++ b/internal/collector/diskdrive/diskdrive.go @@ -245,6 +245,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { if availNum == int(disk.Availability) { isCurrentState = 1.0 } + ch <- prometheus.MustNewConstMetric( c.availability, prometheus.GaugeValue, diff --git a/internal/collector/dns/dns.go b/internal/collector/dns/dns.go index 5cf846cf..5d444bec 100644 --- a/internal/collector/dns/dns.go +++ b/internal/collector/dns/dns.go @@ -357,6 +357,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error { c.perfDataObject[0].AxfrRequestReceived, "full", ) + ch <- prometheus.MustNewConstMetric( c.zoneTransferRequestsReceived, prometheus.CounterValue, @@ -370,12 +371,14 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error { c.perfDataObject[0].AxfrRequestSent, "full", ) + ch <- prometheus.MustNewConstMetric( c.zoneTransferRequestsSent, prometheus.CounterValue, c.perfDataObject[0].IxfrRequestSent, "incremental", ) + ch <- prometheus.MustNewConstMetric( c.zoneTransferRequestsSent, prometheus.CounterValue, @@ -389,6 +392,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error { c.perfDataObject[0].AxfrResponseReceived, "full", ) + ch <- prometheus.MustNewConstMetric( c.zoneTransferResponsesReceived, prometheus.CounterValue, @@ -403,6 +407,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error { "full", "tcp", ) + ch <- prometheus.MustNewConstMetric( c.zoneTransferSuccessReceived, prometheus.CounterValue, @@ -410,6 +415,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error { "incremental", "tcp", ) + ch <- prometheus.MustNewConstMetric( c.zoneTransferSuccessReceived, prometheus.CounterValue, @@ -424,6 +430,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error { c.perfDataObject[0].AxfrSuccessSent, "full", ) + ch <- prometheus.MustNewConstMetric( c.zoneTransferSuccessSent, prometheus.CounterValue, @@ -443,30 +450,35 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error { c.perfDataObject[0].CachingMemory, "caching", ) + ch <- prometheus.MustNewConstMetric( c.memoryUsedBytes, prometheus.GaugeValue, c.perfDataObject[0].DatabaseNodeMemory, "database_node", ) + ch <- prometheus.MustNewConstMetric( c.memoryUsedBytes, prometheus.GaugeValue, c.perfDataObject[0].NbStatMemory, "nbstat", ) + ch <- prometheus.MustNewConstMetric( c.memoryUsedBytes, prometheus.GaugeValue, c.perfDataObject[0].RecordFlowMemory, "record_flow", ) + ch <- prometheus.MustNewConstMetric( c.memoryUsedBytes, prometheus.GaugeValue, c.perfDataObject[0].TcpMessageMemory, "tcp_message", ) + ch <- prometheus.MustNewConstMetric( c.memoryUsedBytes, prometheus.GaugeValue, @@ -480,23 +492,27 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error { c.perfDataObject[0].DynamicUpdateNoOperation, "noop", ) + ch <- prometheus.MustNewConstMetric( c.dynamicUpdatesReceived, prometheus.CounterValue, c.perfDataObject[0].DynamicUpdateWrittenToDatabase, "written", ) + ch <- prometheus.MustNewConstMetric( c.dynamicUpdatesQueued, prometheus.GaugeValue, c.perfDataObject[0].DynamicUpdateQueued, ) + ch <- prometheus.MustNewConstMetric( c.dynamicUpdatesFailures, prometheus.CounterValue, c.perfDataObject[0].DynamicUpdateRejected, "rejected", ) + ch <- prometheus.MustNewConstMetric( c.dynamicUpdatesFailures, prometheus.CounterValue, @@ -509,6 +525,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].NotifyReceived, ) + ch <- prometheus.MustNewConstMetric( c.notifySent, prometheus.CounterValue, @@ -520,11 +537,13 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].RecursiveQueries, ) + ch <- prometheus.MustNewConstMetric( c.recursiveQueryFailures, prometheus.CounterValue, c.perfDataObject[0].RecursiveQueryFailure, ) + ch <- prometheus.MustNewConstMetric( c.recursiveQuerySendTimeouts, prometheus.CounterValue, @@ -537,6 +556,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error { c.perfDataObject[0].TcpQueryReceived, "tcp", ) + ch <- prometheus.MustNewConstMetric( c.queries, prometheus.CounterValue, @@ -550,6 +570,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error { c.perfDataObject[0].TcpResponseSent, "tcp", ) + ch <- prometheus.MustNewConstMetric( c.responses, prometheus.CounterValue, @@ -569,6 +590,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error { c.perfDataObject[0].WinsLookupReceived, "forward", ) + ch <- prometheus.MustNewConstMetric( c.winsQueries, prometheus.CounterValue, @@ -582,6 +604,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error { c.perfDataObject[0].WinsResponseSent, "forward", ) + ch <- prometheus.MustNewConstMetric( c.winsResponses, prometheus.CounterValue, @@ -594,6 +617,7 @@ func (c *Collector) collectMetrics(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].SecureUpdateFailure, ) + ch <- prometheus.MustNewConstMetric( c.secureUpdateReceived, prometheus.CounterValue, diff --git a/internal/collector/exchange/exchange.go b/internal/collector/exchange/exchange.go index e2ee5800..3daea496 100644 --- a/internal/collector/exchange/exchange.go +++ b/internal/collector/exchange/exchange.go @@ -66,11 +66,6 @@ var ConfigDefaults = Config{ } type Collector struct { - config Config - - collectorFns []func(ch chan<- prometheus.Metric) error - closeFns []func() - collectorADAccessProcesses collectorActiveSync collectorAutoDiscover @@ -81,6 +76,11 @@ type Collector struct { collectorRpcClientAccess collectorTransportQueues collectorWorkloadManagementWorkloads + + config Config + + collectorFns []func(ch chan<- prometheus.Metric) error + closeFns []func() } func New(config *Config) *Collector { diff --git a/internal/collector/exchange/exchange_active_sync.go b/internal/collector/exchange/exchange_active_sync.go index 71daba67..4e4317b0 100644 --- a/internal/collector/exchange/exchange_active_sync.go +++ b/internal/collector/exchange/exchange_active_sync.go @@ -82,11 +82,13 @@ func (c *Collector) collectActiveSync(ch chan<- prometheus.Metric) error { prometheus.CounterValue, data.RequestsPerSec, ) + ch <- prometheus.MustNewConstMetric( c.pingCommandsPending, prometheus.GaugeValue, data.PingCommandsPending, ) + ch <- prometheus.MustNewConstMetric( c.syncCommandsPerSec, prometheus.CounterValue, diff --git a/internal/collector/exchange/exchange_ad_access_processes.go b/internal/collector/exchange/exchange_ad_access_processes.go index c4c82f09..e8b81137 100644 --- a/internal/collector/exchange/exchange_ad_access_processes.go +++ b/internal/collector/exchange/exchange_ad_access_processes.go @@ -113,24 +113,28 @@ func (c *Collector) collectADAccessProcesses(ch chan<- prometheus.Metric) error utils.MilliSecToSec(data.LdapReadTime), labelName, ) + ch <- prometheus.MustNewConstMetric( c.ldapSearchTime, prometheus.CounterValue, utils.MilliSecToSec(data.LdapSearchTime), labelName, ) + ch <- prometheus.MustNewConstMetric( c.ldapWriteTime, prometheus.CounterValue, utils.MilliSecToSec(data.LdapWriteTime), labelName, ) + ch <- prometheus.MustNewConstMetric( c.ldapTimeoutErrorsPerSec, prometheus.CounterValue, data.LdapTimeoutErrorsPerSec, labelName, ) + ch <- prometheus.MustNewConstMetric( c.longRunningLDAPOperationsPerMin, prometheus.CounterValue, diff --git a/internal/collector/exchange/exchange_http_proxy.go b/internal/collector/exchange/exchange_http_proxy.go index df77a5b5..eb4ddf45 100644 --- a/internal/collector/exchange/exchange_http_proxy.go +++ b/internal/collector/exchange/exchange_http_proxy.go @@ -111,30 +111,35 @@ func (c *Collector) collectHTTPProxy(ch chan<- prometheus.Metric) error { utils.MilliSecToSec(data.MailboxServerLocatorAverageLatency), labelName, ) + ch <- prometheus.MustNewConstMetric( c.averageAuthenticationLatency, prometheus.GaugeValue, data.AverageAuthenticationLatency, labelName, ) + ch <- prometheus.MustNewConstMetric( c.averageCASProcessingLatency, prometheus.GaugeValue, utils.MilliSecToSec(data.AverageCASProcessingLatency), labelName, ) + ch <- prometheus.MustNewConstMetric( c.mailboxServerProxyFailureRate, prometheus.GaugeValue, data.MailboxServerProxyFailureRate, labelName, ) + ch <- prometheus.MustNewConstMetric( c.outstandingProxyRequests, prometheus.GaugeValue, data.OutstandingProxyRequests, labelName, ) + ch <- prometheus.MustNewConstMetric( c.proxyRequestsPerSec, prometheus.CounterValue, diff --git a/internal/collector/exchange/exchange_outlook_web_access.go b/internal/collector/exchange/exchange_outlook_web_access.go index 96ea1e42..8467ac4b 100644 --- a/internal/collector/exchange/exchange_outlook_web_access.go +++ b/internal/collector/exchange/exchange_outlook_web_access.go @@ -74,6 +74,7 @@ func (c *Collector) collectOWA(ch chan<- prometheus.Metric) error { prometheus.GaugeValue, data.CurrentUniqueUsers, ) + ch <- prometheus.MustNewConstMetric( c.owaRequestsPerSec, prometheus.CounterValue, diff --git a/internal/collector/exchange/exchange_rpc_client_access.go b/internal/collector/exchange/exchange_rpc_client_access.go index d72777bf..e738cd26 100644 --- a/internal/collector/exchange/exchange_rpc_client_access.go +++ b/internal/collector/exchange/exchange_rpc_client_access.go @@ -107,26 +107,31 @@ func (c *Collector) collectRpcClientAccess(ch chan<- prometheus.Metric) error { prometheus.GaugeValue, utils.MilliSecToSec(data.RpcAveragedLatency), ) + ch <- prometheus.MustNewConstMetric( c.rpcRequests, prometheus.GaugeValue, data.RpcRequests, ) + ch <- prometheus.MustNewConstMetric( c.activeUserCount, prometheus.GaugeValue, data.ActiveUserCount, ) + ch <- prometheus.MustNewConstMetric( c.connectionCount, prometheus.GaugeValue, data.ConnectionCount, ) + ch <- prometheus.MustNewConstMetric( c.rpcOperationsPerSec, prometheus.CounterValue, data.RpcOperationsPerSec, ) + ch <- prometheus.MustNewConstMetric( c.userCount, prometheus.GaugeValue, diff --git a/internal/collector/exchange/exchange_transport_queues.go b/internal/collector/exchange/exchange_transport_queues.go index 01abd415..4f672037 100644 --- a/internal/collector/exchange/exchange_transport_queues.go +++ b/internal/collector/exchange/exchange_transport_queues.go @@ -215,108 +215,126 @@ func (c *Collector) collectTransportQueues(ch chan<- prometheus.Metric) error { data.ExternalActiveRemoteDeliveryQueueLength, labelName, ) + ch <- prometheus.MustNewConstMetric( c.internalActiveRemoteDeliveryQueueLength, prometheus.GaugeValue, data.InternalActiveRemoteDeliveryQueueLength, labelName, ) + ch <- prometheus.MustNewConstMetric( c.activeMailboxDeliveryQueueLength, prometheus.GaugeValue, data.ActiveMailboxDeliveryQueueLength, labelName, ) + ch <- prometheus.MustNewConstMetric( c.retryMailboxDeliveryQueueLength, prometheus.GaugeValue, data.RetryMailboxDeliveryQueueLength, labelName, ) + ch <- prometheus.MustNewConstMetric( c.unreachableQueueLength, prometheus.GaugeValue, data.UnreachableQueueLength, labelName, ) + ch <- prometheus.MustNewConstMetric( c.externalLargestDeliveryQueueLength, prometheus.GaugeValue, data.ExternalLargestDeliveryQueueLength, labelName, ) + ch <- prometheus.MustNewConstMetric( c.internalLargestDeliveryQueueLength, prometheus.GaugeValue, data.InternalLargestDeliveryQueueLength, labelName, ) + ch <- prometheus.MustNewConstMetric( c.poisonQueueLength, prometheus.GaugeValue, data.PoisonQueueLength, labelName, ) + ch <- prometheus.MustNewConstMetric( c.messagesQueuedForDeliveryTotal, prometheus.CounterValue, data.MessagesQueuedForDeliveryTotal, labelName, ) + ch <- prometheus.MustNewConstMetric( c.messagesSubmittedTotal, prometheus.CounterValue, data.MessagesSubmittedTotal, labelName, ) + ch <- prometheus.MustNewConstMetric( c.messagesDelayedTotal, prometheus.CounterValue, data.MessagesDelayedTotal, labelName, ) + ch <- prometheus.MustNewConstMetric( c.messagesCompletedDeliveryTotal, prometheus.CounterValue, data.MessagesCompletedDeliveryTotal, labelName, ) + ch <- prometheus.MustNewConstMetric( c.aggregateShadowQueueLength, prometheus.GaugeValue, data.AggregateShadowQueueLength, labelName, ) + ch <- prometheus.MustNewConstMetric( c.submissionQueueLength, prometheus.GaugeValue, data.SubmissionQueueLength, labelName, ) + ch <- prometheus.MustNewConstMetric( c.delayQueueLength, prometheus.GaugeValue, data.DelayQueueLength, labelName, ) + ch <- prometheus.MustNewConstMetric( c.itemsCompletedDeliveryTotal, prometheus.CounterValue, data.ItemsCompletedDeliveryTotal, labelName, ) + ch <- prometheus.MustNewConstMetric( c.itemsQueuedForDeliveryExpiredTotal, prometheus.CounterValue, data.ItemsQueuedForDeliveryExpiredTotal, labelName, ) + ch <- prometheus.MustNewConstMetric( c.itemsQueuedForDeliveryTotal, prometheus.CounterValue, data.ItemsQueuedForDeliveryTotal, labelName, ) + ch <- prometheus.MustNewConstMetric( c.itemsResubmittedTotal, prometheus.CounterValue, diff --git a/internal/collector/exchange/exchange_workload_management.go b/internal/collector/exchange/exchange_workload_management.go index 0c99b4cc..b259fcf9 100644 --- a/internal/collector/exchange/exchange_workload_management.go +++ b/internal/collector/exchange/exchange_workload_management.go @@ -103,24 +103,28 @@ func (c *Collector) collectWorkloadManagementWorkloads(ch chan<- prometheus.Metr data.ActiveTasks, labelName, ) + ch <- prometheus.MustNewConstMetric( c.completedTasks, prometheus.CounterValue, data.CompletedTasks, labelName, ) + ch <- prometheus.MustNewConstMetric( c.queuedTasks, prometheus.CounterValue, data.QueuedTasks, labelName, ) + ch <- prometheus.MustNewConstMetric( c.yieldedTasks, prometheus.CounterValue, data.YieldedTasks, labelName, ) + ch <- prometheus.MustNewConstMetric( c.isActive, prometheus.GaugeValue, diff --git a/internal/collector/fsrmquota/fsrmquota.go b/internal/collector/fsrmquota/fsrmquota.go index ed438f40..b1d6d30a 100644 --- a/internal/collector/fsrmquota/fsrmquota.go +++ b/internal/collector/fsrmquota/fsrmquota.go @@ -190,6 +190,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { path, template, ) + ch <- prometheus.MustNewConstMetric( c.size, prometheus.GaugeValue, @@ -197,6 +198,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { path, template, ) + ch <- prometheus.MustNewConstMetric( c.usage, prometheus.GaugeValue, @@ -204,12 +206,14 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { path, template, ) + ch <- prometheus.MustNewConstMetric( c.description, prometheus.GaugeValue, 1.0, path, template, Description, ) + ch <- prometheus.MustNewConstMetric( c.disabled, prometheus.GaugeValue, @@ -217,6 +221,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { path, template, ) + ch <- prometheus.MustNewConstMetric( c.matchesTemplate, prometheus.GaugeValue, @@ -224,6 +229,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { path, template, ) + ch <- prometheus.MustNewConstMetric( c.softLimit, prometheus.GaugeValue, diff --git a/internal/collector/gpu/gpu.go b/internal/collector/gpu/gpu.go index c059f62f..a91e051f 100644 --- a/internal/collector/gpu/gpu.go +++ b/internal/collector/gpu/gpu.go @@ -335,12 +335,14 @@ func (c *Collector) collectGpuAdapterMemoryMetrics(ch chan<- prometheus.Metric) dedicatedUsage, key.Phys, ) + ch <- prometheus.MustNewConstMetric( c.gpuAdapterMemorySharedUsage, prometheus.GaugeValue, sharedUsageMap[key], key.Phys, ) + ch <- prometheus.MustNewConstMetric( c.gpuAdapterMemoryTotalCommitted, prometheus.GaugeValue, @@ -437,24 +439,28 @@ func (c *Collector) collectGpuProcessMemoryMetrics(ch chan<- prometheus.Metric) dedicatedUsage, key.Pid, key.Phys, ) + ch <- prometheus.MustNewConstMetric( c.gpuProcessMemoryLocalUsage, prometheus.GaugeValue, processLocalUsageMap[key], key.Pid, key.Phys, ) + ch <- prometheus.MustNewConstMetric( c.gpuProcessMemoryNonLocalUsage, prometheus.GaugeValue, processNonLocalUsageMap[key], key.Pid, key.Phys, ) + ch <- prometheus.MustNewConstMetric( c.gpuProcessMemorySharedUsage, prometheus.GaugeValue, processSharedUsageMap[key], key.Pid, key.Phys, ) + ch <- prometheus.MustNewConstMetric( c.gpuProcessMemoryTotalCommitted, prometheus.GaugeValue, diff --git a/internal/collector/hyperv/hyperv.go b/internal/collector/hyperv/hyperv.go index 56ca36c9..c7527776 100644 --- a/internal/collector/hyperv/hyperv.go +++ b/internal/collector/hyperv/hyperv.go @@ -78,11 +78,6 @@ var ConfigDefaults = Config{ // Collector is a Prometheus Collector for hyper-v. type Collector struct { - config Config - - collectorFns []func(ch chan<- prometheus.Metric) error - closeFns []func() - collectorDataStore collectorDynamicMemoryBalancer collectorDynamicMemoryVM @@ -98,6 +93,11 @@ type Collector struct { collectorVirtualSMB collectorVirtualStorageDevice collectorVirtualSwitch + + config Config + + collectorFns []func(ch chan<- prometheus.Metric) error + closeFns []func() } func New(config *Config) *Collector { diff --git a/internal/collector/hyperv/hyperv_hypervisor_root_partition.go b/internal/collector/hyperv/hyperv_hypervisor_root_partition.go index e77dff03..041e61e0 100644 --- a/internal/collector/hyperv/hyperv_hypervisor_root_partition.go +++ b/internal/collector/hyperv/hyperv_hypervisor_root_partition.go @@ -310,26 +310,31 @@ func (c *Collector) collectHypervisorRootPartition(ch chan<- prometheus.Metric) prometheus.GaugeValue, c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition2MDevicePages, ) + ch <- prometheus.MustNewConstMetric( c.hypervisorRootPartition2MGPAPages, prometheus.GaugeValue, c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition2MGPAPages, ) + ch <- prometheus.MustNewConstMetric( c.hypervisorRootPartition4KDevicePages, prometheus.GaugeValue, c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition4KDevicePages, ) + ch <- prometheus.MustNewConstMetric( c.hypervisorRootPartition4KGPAPages, prometheus.GaugeValue, c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartition4KGPAPages, ) + ch <- prometheus.MustNewConstMetric( c.hypervisorRootPartitionVirtualTLBFlushEntries, prometheus.CounterValue, c.perfDataObjectHypervisorRootPartition[0].HypervisorRootPartitionVirtualTLBFlushEntries, ) + ch <- prometheus.MustNewConstMetric( c.hypervisorRootPartitionVirtualTLBPages, prometheus.GaugeValue, diff --git a/internal/collector/hyperv/hyperv_virtual_network_adapter_drop_reasons.go b/internal/collector/hyperv/hyperv_virtual_network_adapter_drop_reasons.go index fe9806be..fa3a00f3 100644 --- a/internal/collector/hyperv/hyperv_virtual_network_adapter_drop_reasons.go +++ b/internal/collector/hyperv/hyperv_virtual_network_adapter_drop_reasons.go @@ -195,294 +195,343 @@ func (c *Collector) collectVirtualNetworkAdapterDropReasons(ch chan<- prometheus data.VirtualNetworkAdapterDropReasonsOutgoingNativeFwdingReq, data.Name, "NativeFwdingReq", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingNativeFwdingReq, data.Name, "NativeFwdingReq", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingMTUMismatch, data.Name, "MTUMismatch", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingMTUMismatch, data.Name, "MTUMismatch", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingInvalidConfig, data.Name, "InvalidConfig", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingInvalidConfig, data.Name, "InvalidConfig", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingRequiredExtensionMissing, data.Name, "RequiredExtensionMissing", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingRequiredExtensionMissing, data.Name, "RequiredExtensionMissing", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingVirtualSubnetId, data.Name, "VirtualSubnetId", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingVirtualSubnetId, data.Name, "VirtualSubnetId", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingBridgeReserved, data.Name, "BridgeReserved", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingBridgeReserved, data.Name, "BridgeReserved", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingRouterGuard, data.Name, "RouterGuard", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingRouterGuard, data.Name, "RouterGuard", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingDhcpGuard, data.Name, "DhcpGuard", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingDhcpGuard, data.Name, "DhcpGuard", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingMacSpoofing, data.Name, "MacSpoofing", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingMacSpoofing, data.Name, "MacSpoofing", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingIpsec, data.Name, "Ipsec", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingIpsec, data.Name, "Ipsec", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingQos, data.Name, "Qos", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingQos, data.Name, "Qos", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingFailedPvlanSetting, data.Name, "FailedPvlanSetting", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingFailedPvlanSetting, data.Name, "FailedPvlanSetting", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingFailedSecurityPolicy, data.Name, "FailedSecurityPolicy", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingFailedSecurityPolicy, data.Name, "FailedSecurityPolicy", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedMAC, data.Name, "UnauthorizedMAC", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingUnauthorizedMAC, data.Name, "UnauthorizedMAC", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingUnauthorizedVLAN, data.Name, "UnauthorizedVLAN", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingUnauthorizedVLAN, data.Name, "UnauthorizedVLAN", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingFilteredVLAN, data.Name, "FilteredVLAN", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingFilteredVLAN, data.Name, "FilteredVLAN", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingFiltered, data.Name, "Filtered", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingFiltered, data.Name, "Filtered", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingBusy, data.Name, "Busy", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingBusy, data.Name, "Busy", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingNotAccepted, data.Name, "NotAccepted", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingNotAccepted, data.Name, "NotAccepted", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingDisconnected, data.Name, "Disconnected", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingDisconnected, data.Name, "Disconnected", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingNotReady, data.Name, "NotReady", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingNotReady, data.Name, "NotReady", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingResources, data.Name, "Resources", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingResources, data.Name, "Resources", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingInvalidPacket, data.Name, "InvalidPacket", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingInvalidPacket, data.Name, "InvalidPacket", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingInvalidData, data.Name, "InvalidData", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsIncomingInvalidData, data.Name, "InvalidData", "incoming", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, data.VirtualNetworkAdapterDropReasonsOutgoingUnknown, data.Name, "Unknown", "outgoing", ) + ch <- prometheus.MustNewConstMetric( c.virtualNetworkAdapterDropReasons, prometheus.CounterValue, diff --git a/internal/collector/hyperv/hyperv_virtual_switch.go b/internal/collector/hyperv/hyperv_virtual_switch.go index 7a57baf5..2c130a4d 100644 --- a/internal/collector/hyperv/hyperv_virtual_switch.go +++ b/internal/collector/hyperv/hyperv_virtual_switch.go @@ -265,6 +265,7 @@ func (c *Collector) collectVirtualSwitch(ch chan<- prometheus.Metric) error { data.VirtualSwitchDirectedPacketsReceived, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.virtualSwitchDirectedPacketsSent, prometheus.CounterValue, @@ -278,18 +279,21 @@ func (c *Collector) collectVirtualSwitch(ch chan<- prometheus.Metric) error { data.VirtualSwitchDroppedPacketsIncoming, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.virtualSwitchDroppedPacketsOutgoing, prometheus.CounterValue, data.VirtualSwitchDroppedPacketsOutgoing, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.virtualSwitchExtensionsDroppedPacketsIncoming, prometheus.CounterValue, data.VirtualSwitchExtensionsDroppedPacketsIncoming, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.virtualSwitchExtensionsDroppedPacketsOutgoing, prometheus.CounterValue, @@ -303,24 +307,28 @@ func (c *Collector) collectVirtualSwitch(ch chan<- prometheus.Metric) error { data.VirtualSwitchLearnedMacAddresses, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.virtualSwitchMulticastPacketsReceived, prometheus.CounterValue, data.VirtualSwitchMulticastPacketsReceived, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.virtualSwitchMulticastPacketsSent, prometheus.CounterValue, data.VirtualSwitchMulticastPacketsSent, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.virtualSwitchNumberOfSendChannelMoves, prometheus.CounterValue, data.VirtualSwitchNumberOfSendChannelMoves, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.virtualSwitchNumberOfVMQMoves, prometheus.CounterValue, @@ -348,12 +356,14 @@ func (c *Collector) collectVirtualSwitch(ch chan<- prometheus.Metric) error { data.VirtualSwitchPacketsReceived, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.virtualSwitchPacketsSent, prometheus.CounterValue, data.VirtualSwitchPacketsSent, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.virtualSwitchPurgedMacAddresses, prometheus.CounterValue, diff --git a/internal/collector/iis/iis.go b/internal/collector/iis/iis.go index 3d49bba9..d47f60d9 100644 --- a/internal/collector/iis/iis.go +++ b/internal/collector/iis/iis.go @@ -50,17 +50,18 @@ var ConfigDefaults = Config{ } type Collector struct { + collectorWebService + collectorHttpServiceRequestQueues + collectorAppPoolWAS + collectorW3SVCW3WP + collectorWebServiceCache + config Config iisVersion simpleVersion logger *slog.Logger info *prometheus.Desc - collectorWebService - collectorHttpServiceRequestQueues - collectorAppPoolWAS - collectorW3SVCW3WP - collectorWebServiceCache } func New(config *Config) *Collector { diff --git a/internal/collector/iis/iis_app_pool_was.go b/internal/collector/iis/iis_app_pool_was.go index f31b1fa3..4a4b1356 100644 --- a/internal/collector/iis/iis_app_pool_was.go +++ b/internal/collector/iis/iis_app_pool_was.go @@ -201,66 +201,77 @@ func (c *Collector) collectAppPoolWAS(ch chan<- prometheus.Metric) error { data.CurrentApplicationPoolUptime, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.currentWorkerProcesses, prometheus.GaugeValue, data.CurrentWorkerProcesses, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.maximumWorkerProcesses, prometheus.GaugeValue, data.MaximumWorkerProcesses, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.recentWorkerProcessFailures, prometheus.GaugeValue, data.RecentWorkerProcessFailures, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.timeSinceLastWorkerProcessFailure, prometheus.GaugeValue, data.TimeSinceLastWorkerProcessFailure, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.totalApplicationPoolRecycles, prometheus.CounterValue, data.TotalApplicationPoolRecycles, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.totalApplicationPoolUptime, prometheus.CounterValue, data.TotalApplicationPoolUptime, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.totalWorkerProcessesCreated, prometheus.CounterValue, data.TotalWorkerProcessesCreated, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.totalWorkerProcessFailures, prometheus.CounterValue, data.TotalWorkerProcessFailures, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.totalWorkerProcessPingFailures, prometheus.CounterValue, data.TotalWorkerProcessPingFailures, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.totalWorkerProcessShutdownFailures, prometheus.CounterValue, data.TotalWorkerProcessShutdownFailures, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.totalWorkerProcessStartupFailures, prometheus.CounterValue, diff --git a/internal/collector/iis/iis_http_service_request_queues.go b/internal/collector/iis/iis_http_service_request_queues.go index 0e047746..965ff503 100644 --- a/internal/collector/iis/iis_http_service_request_queues.go +++ b/internal/collector/iis/iis_http_service_request_queues.go @@ -110,18 +110,21 @@ func (c *Collector) collectHttpServiceRequestQueues(ch chan<- prometheus.Metric) data.HttpRequestQueuesCurrentQueueSize, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.httpRequestQueuesTotalRejectedRequest, prometheus.GaugeValue, data.HttpRequestQueuesTotalRejectedRequests, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.httpRequestQueuesMaxQueueItemAge, prometheus.GaugeValue, data.HttpRequestQueuesMaxQueueItemAge, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.httpRequestQueuesArrivalRate, prometheus.GaugeValue, diff --git a/internal/collector/iis/iis_w3svc_w3wp.go b/internal/collector/iis/iis_w3svc_w3wp.go index 224ca296..36e0bc64 100644 --- a/internal/collector/iis/iis_w3svc_w3wp.go +++ b/internal/collector/iis/iis_w3svc_w3wp.go @@ -441,6 +441,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error { pid, "401", ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPRequestErrorsTotal, prometheus.CounterValue, @@ -449,6 +450,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error { pid, "403", ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPRequestErrorsTotal, prometheus.CounterValue, @@ -457,6 +459,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error { pid, "404", ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPRequestErrorsTotal, prometheus.CounterValue, @@ -465,6 +468,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error { pid, "500", ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPWebSocketRequestsActive, prometheus.CounterValue, @@ -472,6 +476,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPWebSocketConnectionAttempts, prometheus.CounterValue, @@ -479,6 +484,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPWebSocketConnectionsAccepted, prometheus.CounterValue, @@ -486,6 +492,7 @@ func (c *Collector) collectW3SVCW3WPv8(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPWebSocketConnectionsRejected, prometheus.CounterValue, @@ -529,6 +536,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { pid, "busy", ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPMaximumThreads, prometheus.CounterValue, @@ -536,6 +544,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPRequestsTotal, prometheus.CounterValue, @@ -543,6 +552,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPRequestsActive, prometheus.CounterValue, @@ -550,6 +560,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPActiveFlushedEntries, prometheus.GaugeValue, @@ -557,6 +568,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPCurrentFileCacheMemoryUsage, prometheus.GaugeValue, @@ -564,6 +576,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPMaximumFileCacheMemoryUsage, prometheus.CounterValue, @@ -571,6 +584,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPFileCacheFlushesTotal, prometheus.CounterValue, @@ -578,6 +592,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPFileCacheQueriesTotal, prometheus.CounterValue, @@ -585,6 +600,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPFileCacheHitsTotal, prometheus.CounterValue, @@ -592,6 +608,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPFilesCached, prometheus.GaugeValue, @@ -599,6 +616,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPFilesCachedTotal, prometheus.CounterValue, @@ -606,6 +624,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPFilesFlushedTotal, prometheus.CounterValue, @@ -613,6 +632,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPURICacheFlushesTotal, prometheus.CounterValue, @@ -620,6 +640,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPURICacheQueriesTotal, prometheus.CounterValue, @@ -627,6 +648,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPURICacheHitsTotal, prometheus.CounterValue, @@ -634,6 +656,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPURIsCached, prometheus.GaugeValue, @@ -641,6 +664,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPURIsCachedTotal, prometheus.CounterValue, @@ -648,6 +672,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPURIsFlushedTotal, prometheus.CounterValue, @@ -655,6 +680,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPMetadataCached, prometheus.GaugeValue, @@ -662,6 +688,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPMetadataCacheFlushes, prometheus.CounterValue, @@ -669,6 +696,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPMetadataCacheQueriesTotal, prometheus.CounterValue, @@ -676,6 +704,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPMetadataCacheHitsTotal, prometheus.CounterValue, @@ -683,6 +712,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPMetadataCachedTotal, prometheus.CounterValue, @@ -690,6 +720,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPMetadataFlushedTotal, prometheus.CounterValue, @@ -697,6 +728,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPOutputCacheActiveFlushedItems, prometheus.CounterValue, @@ -704,6 +736,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPOutputCacheItems, prometheus.CounterValue, @@ -711,6 +744,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPOutputCacheMemoryUsage, prometheus.CounterValue, @@ -718,6 +752,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPOutputCacheQueriesTotal, prometheus.CounterValue, @@ -725,6 +760,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPOutputCacheHitsTotal, prometheus.CounterValue, @@ -732,6 +768,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPOutputCacheFlushedItemsTotal, prometheus.CounterValue, @@ -739,6 +776,7 @@ func (c *Collector) collectW3SVCW3WPv7(ch chan<- prometheus.Metric) error { name, pid, ) + ch <- prometheus.MustNewConstMetric( c.w3SVCW3WPOutputCacheFlushesTotal, prometheus.CounterValue, diff --git a/internal/collector/iis/iis_web_service.go b/internal/collector/iis/iis_web_service.go index 84156986..02e3f0f8 100644 --- a/internal/collector/iis/iis_web_service.go +++ b/internal/collector/iis/iis_web_service.go @@ -262,126 +262,147 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.WebServiceCurrentAnonymousUsers, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceCurrentBlockedAsyncIORequests, prometheus.GaugeValue, data.WebServiceCurrentBlockedAsyncIORequests, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceCurrentCGIRequests, prometheus.GaugeValue, data.WebServiceCurrentCGIRequests, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceCurrentConnections, prometheus.GaugeValue, data.WebServiceCurrentConnections, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceCurrentISAPIExtensionRequests, prometheus.GaugeValue, data.WebServiceCurrentISAPIExtensionRequests, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceCurrentNonAnonymousUsers, prometheus.GaugeValue, data.WebServiceCurrentNonAnonymousUsers, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceServiceUptime, prometheus.GaugeValue, data.WebServiceServiceUptime, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalBytesReceived, prometheus.CounterValue, data.WebServiceTotalBytesReceived, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalBytesSent, prometheus.CounterValue, data.WebServiceTotalBytesSent, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalAnonymousUsers, prometheus.CounterValue, data.WebServiceTotalAnonymousUsers, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalBlockedAsyncIORequests, prometheus.CounterValue, data.WebServiceTotalBlockedAsyncIORequests, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalCGIRequests, prometheus.CounterValue, data.WebServiceTotalCGIRequests, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalConnectionAttemptsAllInstances, prometheus.CounterValue, data.WebServiceTotalConnectionAttemptsAllInstances, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalFilesReceived, prometheus.CounterValue, data.WebServiceTotalFilesReceived, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalFilesSent, prometheus.CounterValue, data.WebServiceTotalFilesSent, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalISAPIExtensionRequests, prometheus.CounterValue, data.WebServiceTotalISAPIExtensionRequests, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalLockedErrors, prometheus.CounterValue, data.WebServiceTotalLockedErrors, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalLogonAttempts, prometheus.CounterValue, data.WebServiceTotalLogonAttempts, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalNonAnonymousUsers, prometheus.CounterValue, data.WebServiceTotalNonAnonymousUsers, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalNotFoundErrors, prometheus.CounterValue, data.WebServiceTotalNotFoundErrors, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRejectedAsyncIORequests, prometheus.CounterValue, data.WebServiceTotalRejectedAsyncIORequests, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, @@ -389,6 +410,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.Name, "other", ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, @@ -396,6 +418,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.Name, "COPY", ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, @@ -403,6 +426,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.Name, "DELETE", ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, @@ -410,6 +434,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.Name, "GET", ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, @@ -417,6 +442,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.Name, "HEAD", ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, @@ -424,6 +450,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.Name, "LOCK", ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, @@ -431,6 +458,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.Name, "MKCOL", ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, @@ -438,6 +466,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.Name, "MOVE", ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, @@ -445,6 +474,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.Name, "OPTIONS", ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, @@ -452,6 +482,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.Name, "POST", ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, @@ -459,6 +490,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.Name, "PROPFIND", ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, @@ -466,6 +498,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.Name, "PROPPATCH", ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, @@ -473,6 +506,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.Name, "PUT", ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, @@ -480,6 +514,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.Name, "SEARCH", ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, @@ -487,6 +522,7 @@ func (c *Collector) collectWebService(ch chan<- prometheus.Metric) error { data.Name, "TRACE", ) + ch <- prometheus.MustNewConstMetric( c.webServiceTotalRequests, prometheus.CounterValue, diff --git a/internal/collector/iis/iis_web_service_cache.go b/internal/collector/iis/iis_web_service_cache.go index a52f7938..662a2373 100644 --- a/internal/collector/iis/iis_web_service_cache.go +++ b/internal/collector/iis/iis_web_service_cache.go @@ -293,178 +293,211 @@ func (c *Collector) collectWebServiceCache(ch chan<- prometheus.Metric) error { prometheus.GaugeValue, data.ServiceCacheActiveFlushedEntries, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheCurrentFileCacheMemoryUsage, prometheus.GaugeValue, data.ServiceCacheCurrentFileCacheMemoryUsage, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheMaximumFileCacheMemoryUsage, prometheus.CounterValue, data.ServiceCacheMaximumFileCacheMemoryUsage, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheFileCacheFlushesTotal, prometheus.CounterValue, data.ServiceCacheFileCacheFlushesTotal, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheFileCacheQueriesTotal, prometheus.CounterValue, data.ServiceCacheFileCacheHitsTotal+data.ServiceCacheFileCacheMissesTotal, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheFileCacheHitsTotal, prometheus.CounterValue, data.ServiceCacheFileCacheHitsTotal, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheFilesCached, prometheus.GaugeValue, data.ServiceCacheFilesCached, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheFilesCachedTotal, prometheus.CounterValue, data.ServiceCacheFilesCachedTotal, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheFilesFlushedTotal, prometheus.CounterValue, data.ServiceCacheFilesFlushedTotal, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheURICacheFlushesTotal, prometheus.CounterValue, data.ServiceCacheURICacheFlushesTotal, "user", ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheURICacheFlushesTotal, prometheus.CounterValue, data.ServiceCacheURICacheFlushesTotalKernel, "kernel", ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheURICacheQueriesTotal, prometheus.CounterValue, data.ServiceCacheURICacheHitsTotal+data.ServiceCacheURICacheMissesTotal, "user", ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheURICacheQueriesTotal, prometheus.CounterValue, data.ServiceCacheURICacheHitsTotalKernel+data.ServiceCacheURICacheMissesTotalKernel, "kernel", ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheURICacheHitsTotal, prometheus.CounterValue, data.ServiceCacheURICacheHitsTotal, "user", ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheURICacheHitsTotal, prometheus.CounterValue, data.ServiceCacheURICacheHitsTotalKernel, "kernel", ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheURIsCached, prometheus.GaugeValue, data.ServiceCacheURIsCached, "user", ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheURIsCached, prometheus.GaugeValue, data.ServiceCacheURIsCachedKernel, "kernel", ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheURIsCachedTotal, prometheus.CounterValue, data.ServiceCacheURIsCachedTotal, "user", ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheURIsCachedTotal, prometheus.CounterValue, data.ServiceCacheURIsCachedTotalKernel, "kernel", ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheURIsFlushedTotal, prometheus.CounterValue, data.ServiceCacheURIsFlushedTotal, "user", ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheURIsFlushedTotal, prometheus.CounterValue, data.ServiceCacheURIsFlushedTotalKernel, "kernel", ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheMetadataCached, prometheus.GaugeValue, data.ServiceCacheMetadataCached, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheMetadataCacheFlushes, prometheus.CounterValue, data.ServiceCacheMetadataCacheFlushes, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheMetadataCacheQueriesTotal, prometheus.CounterValue, data.ServiceCacheMetaDataCacheHits+data.ServiceCacheMetaDataCacheMisses, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheMetadataCacheHitsTotal, prometheus.CounterValue, 0, // data.ServiceCacheMetadataCacheHitsTotal, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheMetadataCachedTotal, prometheus.CounterValue, data.ServiceCacheMetadataCachedTotal, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheMetadataFlushedTotal, prometheus.CounterValue, data.ServiceCacheMetadataFlushedTotal, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheOutputCacheActiveFlushedItems, prometheus.CounterValue, data.ServiceCacheOutputCacheActiveFlushedItems, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheOutputCacheItems, prometheus.CounterValue, data.ServiceCacheOutputCacheItems, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheOutputCacheMemoryUsage, prometheus.CounterValue, data.ServiceCacheOutputCacheMemoryUsage, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheOutputCacheQueriesTotal, prometheus.CounterValue, data.ServiceCacheOutputCacheHitsTotal+data.ServiceCacheOutputCacheMissesTotal, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheOutputCacheHitsTotal, prometheus.CounterValue, data.ServiceCacheOutputCacheHitsTotal, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheOutputCacheFlushedItemsTotal, prometheus.CounterValue, data.ServiceCacheOutputCacheFlushedItemsTotal, ) + ch <- prometheus.MustNewConstMetric( c.serviceCacheOutputCacheFlushesTotal, prometheus.CounterValue, diff --git a/internal/collector/logical_disk/logical_disk.go b/internal/collector/logical_disk/logical_disk.go index 3d6a59a7..7aeef77e 100644 --- a/internal/collector/logical_disk/logical_disk.go +++ b/internal/collector/logical_disk/logical_disk.go @@ -514,6 +514,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { if slices.Contains(c.config.CollectorsEnabled, subCollectorBitlocker) { c.bitlockerReqCh <- data.Name + bitlockerStatus := <-c.bitlockerResCh if bitlockerStatus.err != nil { diff --git a/internal/collector/mscluster/mscluster.go b/internal/collector/mscluster/mscluster.go index 21d2dfad..32b2802b 100644 --- a/internal/collector/mscluster/mscluster.go +++ b/internal/collector/mscluster/mscluster.go @@ -57,14 +57,14 @@ var ConfigDefaults = Config{ // A Collector is a Prometheus Collector for WMI MSCluster_Cluster metrics. type Collector struct { - config Config - miSession *mi.Session - collectorCluster collectorNetwork collectorNode collectorResource collectorResourceGroup + + config Config + miSession *mi.Session } func New(config *Config) *Collector { diff --git a/internal/collector/mscluster/mscluster_resource.go b/internal/collector/mscluster/mscluster_resource.go index 36d49092..8b2bc745 100644 --- a/internal/collector/mscluster/mscluster_resource.go +++ b/internal/collector/mscluster/mscluster_resource.go @@ -265,6 +265,7 @@ func (c *Collector) collectResource(ch chan<- prometheus.Metric, nodeNames []str if v.OwnerNode == nodeName { isCurrentState = 1.0 } + ch <- prometheus.MustNewConstMetric( c.resourceOwnerNode, prometheus.GaugeValue, diff --git a/internal/collector/mscluster/mscluster_resourcegroup.go b/internal/collector/mscluster/mscluster_resourcegroup.go index dc471205..6c528c0b 100644 --- a/internal/collector/mscluster/mscluster_resourcegroup.go +++ b/internal/collector/mscluster/mscluster_resourcegroup.go @@ -260,6 +260,7 @@ func (c *Collector) collectResourceGroup(ch chan<- prometheus.Metric, nodeNames if v.OwnerNode == nodeName { isCurrentState = 1.0 } + ch <- prometheus.MustNewConstMetric( c.resourceGroupOwnerNode, prometheus.GaugeValue, diff --git a/internal/collector/mssql/mssql.go b/internal/collector/mssql/mssql.go index 6deab7a0..1a4a8fe3 100644 --- a/internal/collector/mssql/mssql.go +++ b/internal/collector/mssql/mssql.go @@ -78,18 +78,6 @@ var ConfigDefaults = Config{ // A Collector is a Prometheus Collector for various WMI Win32_PerfRawData_MSSQLSERVER_* metrics. type Collector struct { - config Config - - logger *slog.Logger - - mssqlInstances []mssqlInstance - collectorFns []func(ch chan<- prometheus.Metric) error - closeFns []func() - - // meta - mssqlScrapeDurationDesc *prometheus.Desc - mssqlScrapeSuccessDesc *prometheus.Desc - collectorAccessMethods collectorAvailabilityReplica collectorBufferManager @@ -103,6 +91,18 @@ type Collector struct { collectorSQLStats collectorTransactions collectorWaitStats + + config Config + + logger *slog.Logger + + mssqlInstances []mssqlInstance + collectorFns []func(ch chan<- prometheus.Metric) error + closeFns []func() + + // meta + mssqlScrapeDurationDesc *prometheus.Desc + mssqlScrapeSuccessDesc *prometheus.Desc } func New(config *Config) *Collector { @@ -405,6 +405,7 @@ func (c *Collector) collect( duration.Seconds(), collector, sqlInstance.name, ) + ch <- prometheus.MustNewConstMetric( c.mssqlScrapeSuccessDesc, prometheus.GaugeValue, diff --git a/internal/collector/net/net.go b/internal/collector/net/net.go index 1b7f0fde..5abc03b3 100644 --- a/internal/collector/net/net.go +++ b/internal/collector/net/net.go @@ -331,72 +331,84 @@ func (c *Collector) collect(ch chan<- prometheus.Metric) error { data.BytesReceivedPerSec, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.bytesSentTotal, prometheus.CounterValue, data.BytesSentPerSec, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.bytesTotal, prometheus.CounterValue, data.BytesTotalPerSec, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.outputQueueLength, prometheus.GaugeValue, data.OutputQueueLength, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.packetsOutboundDiscarded, prometheus.CounterValue, data.PacketsOutboundDiscarded, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.packetsOutboundErrors, prometheus.CounterValue, data.PacketsOutboundErrors, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.packetsTotal, prometheus.CounterValue, data.PacketsPerSec, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.packetsReceivedDiscarded, prometheus.CounterValue, data.PacketsReceivedDiscarded, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.packetsReceivedErrors, prometheus.CounterValue, data.PacketsReceivedErrors, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.packetsReceivedTotal, prometheus.CounterValue, data.PacketsReceivedPerSec, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.packetsReceivedUnknown, prometheus.CounterValue, data.PacketsReceivedUnknown, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.packetsSentTotal, prometheus.CounterValue, data.PacketsSentPerSec, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.currentBandwidth, prometheus.GaugeValue, diff --git a/internal/collector/remote_fx/remote_fx.go b/internal/collector/remote_fx/remote_fx.go index dcf6655e..543fc771 100644 --- a/internal/collector/remote_fx/remote_fx.go +++ b/internal/collector/remote_fx/remote_fx.go @@ -280,60 +280,70 @@ func (c *Collector) collectRemoteFXNetworkCount(ch chan<- prometheus.Metric) err utils.MilliSecToSec(data.BaseTCPRTT), sessionName, ) + ch <- prometheus.MustNewConstMetric( c.baseUDPRTT, prometheus.GaugeValue, utils.MilliSecToSec(data.BaseUDPRTT), sessionName, ) + ch <- prometheus.MustNewConstMetric( c.currentTCPBandwidth, prometheus.GaugeValue, (data.CurrentTCPBandwidth*1000)/8, sessionName, ) + ch <- prometheus.MustNewConstMetric( c.currentTCPRTT, prometheus.GaugeValue, utils.MilliSecToSec(data.CurrentTCPRTT), sessionName, ) + ch <- prometheus.MustNewConstMetric( c.currentUDPBandwidth, prometheus.GaugeValue, (data.CurrentUDPBandwidth*1000)/8, sessionName, ) + ch <- prometheus.MustNewConstMetric( c.currentUDPRTT, prometheus.GaugeValue, utils.MilliSecToSec(data.CurrentUDPRTT), sessionName, ) + ch <- prometheus.MustNewConstMetric( c.totalReceivedBytes, prometheus.CounterValue, data.TotalReceivedBytes, sessionName, ) + ch <- prometheus.MustNewConstMetric( c.totalSentBytes, prometheus.CounterValue, data.TotalSentBytes, sessionName, ) + ch <- prometheus.MustNewConstMetric( c.udpPacketsReceivedPerSec, prometheus.CounterValue, data.UDPPacketsReceivedPersec, sessionName, ) + ch <- prometheus.MustNewConstMetric( c.udpPacketsSentPerSec, prometheus.CounterValue, data.UDPPacketsSentPersec, sessionName, ) + ch <- prometheus.MustNewConstMetric( c.fecRate, prometheus.GaugeValue, @@ -378,12 +388,14 @@ func (c *Collector) collectRemoteFXGraphicsCounters(ch chan<- prometheus.Metric) utils.MilliSecToSec(data.AverageEncodingTime), sessionName, ) + ch <- prometheus.MustNewConstMetric( c.frameQuality, prometheus.GaugeValue, data.FrameQuality, sessionName, ) + ch <- prometheus.MustNewConstMetric( c.framesSkippedPerSecondInsufficientResources, prometheus.CounterValue, @@ -391,6 +403,7 @@ func (c *Collector) collectRemoteFXGraphicsCounters(ch chan<- prometheus.Metric) sessionName, "client", ) + ch <- prometheus.MustNewConstMetric( c.framesSkippedPerSecondInsufficientResources, prometheus.CounterValue, @@ -398,6 +411,7 @@ func (c *Collector) collectRemoteFXGraphicsCounters(ch chan<- prometheus.Metric) sessionName, "network", ) + ch <- prometheus.MustNewConstMetric( c.framesSkippedPerSecondInsufficientResources, prometheus.CounterValue, @@ -405,24 +419,28 @@ func (c *Collector) collectRemoteFXGraphicsCounters(ch chan<- prometheus.Metric) sessionName, "server", ) + ch <- prometheus.MustNewConstMetric( c.graphicsCompressionRatio, prometheus.GaugeValue, data.GraphicsCompressionratio, sessionName, ) + ch <- prometheus.MustNewConstMetric( c.inputFramesPerSecond, prometheus.CounterValue, data.InputFramesPerSecond, sessionName, ) + ch <- prometheus.MustNewConstMetric( c.outputFramesPerSecond, prometheus.CounterValue, data.OutputFramesPerSecond, sessionName, ) + ch <- prometheus.MustNewConstMetric( c.sourceFramesPerSecond, prometheus.CounterValue, diff --git a/internal/collector/service/service.go b/internal/collector/service/service.go index 0ef0ef90..e813efbc 100644 --- a/internal/collector/service/service.go +++ b/internal/collector/service/service.go @@ -316,6 +316,7 @@ func (c *Collector) collectService(ch chan<- prometheus.Metric, serviceName stri if startMode == c.apiStartModeValues[serviceConfig.StartType] { isCurrentStartMode = 1.0 } + ch <- prometheus.MustNewConstMetric( c.startMode, prometheus.GaugeValue, @@ -401,7 +402,6 @@ func (c *Collector) queryAllServices() ([]windows.ENUM_SERVICE_STATUS_PROCESS, e nil, nil, ) - if err == nil { break } @@ -443,7 +443,6 @@ func (c *Collector) getProcessStartTime(pid uint32) (uint64, error) { ) err = windows.GetProcessTimes(handle, &creation, &exit, &krn, &user) - if err := windows.CloseHandle(handle); err != nil { c.logger.LogAttrs(context.Background(), slog.LevelWarn, "failed to close process handle", slog.Any("err", err), diff --git a/internal/collector/system/system.go b/internal/collector/system/system.go index 3aef4903..2494c294 100644 --- a/internal/collector/system/system.go +++ b/internal/collector/system/system.go @@ -168,26 +168,31 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { prometheus.CounterValue, c.perfDataObject[0].ContextSwitchesPerSec, ) + ch <- prometheus.MustNewConstMetric( c.exceptionDispatchesTotal, prometheus.CounterValue, c.perfDataObject[0].ExceptionDispatchesPerSec, ) + ch <- prometheus.MustNewConstMetric( c.processorQueueLength, prometheus.GaugeValue, c.perfDataObject[0].ProcessorQueueLength, ) + ch <- prometheus.MustNewConstMetric( c.processes, prometheus.GaugeValue, c.perfDataObject[0].Processes, ) + ch <- prometheus.MustNewConstMetric( c.systemCallsTotal, prometheus.CounterValue, c.perfDataObject[0].SystemCallsPerSec, ) + ch <- prometheus.MustNewConstMetric( c.threads, prometheus.GaugeValue, diff --git a/internal/collector/tcp/tcp.go b/internal/collector/tcp/tcp.go index 8f26d2ed..5dcb9f35 100644 --- a/internal/collector/tcp/tcp.go +++ b/internal/collector/tcp/tcp.go @@ -259,48 +259,56 @@ func (c *Collector) writeTCPCounters(ch chan<- prometheus.Metric, metrics []perf metrics[0].ConnectionFailures, af, ) + ch <- prometheus.MustNewConstMetric( c.connectionsActive, prometheus.CounterValue, metrics[0].ConnectionsActive, af, ) + ch <- prometheus.MustNewConstMetric( c.connectionsEstablished, prometheus.GaugeValue, metrics[0].ConnectionsEstablished, af, ) + ch <- prometheus.MustNewConstMetric( c.connectionsPassive, prometheus.CounterValue, metrics[0].ConnectionsPassive, af, ) + ch <- prometheus.MustNewConstMetric( c.connectionsReset, prometheus.CounterValue, metrics[0].ConnectionsReset, af, ) + ch <- prometheus.MustNewConstMetric( c.segmentsTotal, prometheus.CounterValue, metrics[0].SegmentsPerSec, af, ) + ch <- prometheus.MustNewConstMetric( c.segmentsReceivedTotal, prometheus.CounterValue, metrics[0].SegmentsReceivedPerSec, af, ) + ch <- prometheus.MustNewConstMetric( c.segmentsRetransmittedTotal, prometheus.CounterValue, metrics[0].SegmentsRetransmittedPerSec, af, ) + ch <- prometheus.MustNewConstMetric( c.segmentsSentTotal, prometheus.CounterValue, diff --git a/internal/collector/terminal_services/terminal_services.go b/internal/collector/terminal_services/terminal_services.go index a6648c0d..4537f770 100644 --- a/internal/collector/terminal_services/terminal_services.go +++ b/internal/collector/terminal_services/terminal_services.go @@ -308,24 +308,28 @@ func (c *Collector) collectTSSessionCounters(ch chan<- prometheus.Metric) error data.HandleCount, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.pageFaultsPerSec, prometheus.CounterValue, data.PageFaultsPersec, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.pageFileBytes, prometheus.GaugeValue, data.PageFileBytes, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.pageFileBytesPeak, prometheus.GaugeValue, data.PageFileBytesPeak, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.percentCPUTime, prometheus.CounterValue, @@ -333,6 +337,7 @@ func (c *Collector) collectTSSessionCounters(ch chan<- prometheus.Metric) error data.Name, "privileged", ) + ch <- prometheus.MustNewConstMetric( c.percentCPUTime, prometheus.CounterValue, @@ -340,6 +345,7 @@ func (c *Collector) collectTSSessionCounters(ch chan<- prometheus.Metric) error data.Name, "processor", ) + ch <- prometheus.MustNewConstMetric( c.percentCPUTime, prometheus.CounterValue, @@ -347,48 +353,56 @@ func (c *Collector) collectTSSessionCounters(ch chan<- prometheus.Metric) error data.Name, "user", ) + ch <- prometheus.MustNewConstMetric( c.poolNonPagedBytes, prometheus.GaugeValue, data.PoolNonpagedBytes, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.poolPagedBytes, prometheus.GaugeValue, data.PoolPagedBytes, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.privateBytes, prometheus.GaugeValue, data.PrivateBytes, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.threadCount, prometheus.GaugeValue, data.ThreadCount, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.virtualBytes, prometheus.GaugeValue, data.VirtualBytes, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.virtualBytesPeak, prometheus.GaugeValue, data.VirtualBytesPeak, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.workingSet, prometheus.GaugeValue, data.WorkingSet, data.Name, ) + ch <- prometheus.MustNewConstMetric( c.workingSetPeak, prometheus.GaugeValue, @@ -453,6 +467,7 @@ func (c *Collector) collectWTSSessions(ch chan<- prometheus.Metric) error { if session.State == stateID { isState = 1.0 } + ch <- prometheus.MustNewConstMetric( c.sessionInfo, prometheus.GaugeValue, diff --git a/internal/collector/textfile/textfile.go b/internal/collector/textfile/textfile.go index 0aa227a6..b66d3ea8 100644 --- a/internal/collector/textfile/textfile.go +++ b/internal/collector/textfile/textfile.go @@ -217,6 +217,7 @@ func (c *Collector) convertMetricFamily(logger *slog.Logger, metricFamily *dto.M for _, q := range metric.GetSummary().GetQuantile() { quantiles[q.GetQuantile()] = q.GetValue() } + ch <- prometheus.MustNewConstSummary( prometheus.NewDesc( metricFamily.GetName(), @@ -232,6 +233,7 @@ func (c *Collector) convertMetricFamily(logger *slog.Logger, metricFamily *dto.M for _, b := range metric.GetHistogram().GetBucket() { buckets[b.GetUpperBound()] = b.GetCumulativeCount() } + ch <- prometheus.MustNewConstHistogram( prometheus.NewDesc( metricFamily.GetName(), @@ -290,8 +292,8 @@ type carriageReturnFilteringReader struct { // Read returns data from the underlying io.Reader, but with \r filtered out. func (cr carriageReturnFilteringReader) Read(p []byte) (int, error) { buf := make([]byte, len(p)) - n, err := cr.r.Read(buf) + n, err := cr.r.Read(buf) if err != nil && err != io.EOF { return n, err } @@ -356,7 +358,6 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error { return nil }) - if err != nil && directory != "" { errs = append(errs, fmt.Errorf("error reading textfile directory %q: %w", directory, err)) } diff --git a/internal/collector/textfile/textfile_test.go b/internal/collector/textfile/textfile_test.go index d9a3bf7a..00ebe98e 100644 --- a/internal/collector/textfile/textfile_test.go +++ b/internal/collector/textfile/textfile_test.go @@ -119,6 +119,7 @@ func TestDuplicateMetricEntry(t *testing.T) { } var duplicateFamily []*dto.MetricFamily + duplicateFamily = append(duplicateFamily, &duplicate) // Ensure detection for duplicate metrics diff --git a/internal/collector/textfile/textfile_test_test.go b/internal/collector/textfile/textfile_test_test.go index cb462139..e522ba1a 100644 --- a/internal/collector/textfile/textfile_test_test.go +++ b/internal/collector/textfile/textfile_test_test.go @@ -51,6 +51,7 @@ func TestMultipleDirectories(t *testing.T) { got := "" errCh := make(chan error, 1) + go func() { errCh <- textFileCollector.Collect(metrics) @@ -88,6 +89,7 @@ func TestDuplicateFileName(t *testing.T) { got := "" errCh := make(chan error, 1) + go func() { errCh <- textFileCollector.Collect(metrics) diff --git a/internal/collector/time/time.go b/internal/collector/time/time.go index 8cc3b49a..a29b8762 100644 --- a/internal/collector/time/time.go +++ b/internal/collector/time/time.go @@ -329,21 +329,25 @@ func (c *Collector) collectNTP(ch chan<- prometheus.Metric) error { prometheus.GaugeValue, c.perfDataObject[0].ComputedTimeOffset/1000000, // microseconds -> seconds ) + ch <- prometheus.MustNewConstMetric( c.ntpClientTimeSourceCount, prometheus.GaugeValue, c.perfDataObject[0].NTPClientTimeSourceCount, ) + ch <- prometheus.MustNewConstMetric( c.ntpRoundTripDelay, prometheus.GaugeValue, c.perfDataObject[0].NTPRoundTripDelay/1000000, // microseconds -> seconds ) + ch <- prometheus.MustNewConstMetric( c.ntpServerIncomingRequestsTotal, prometheus.CounterValue, c.perfDataObject[0].NTPServerIncomingRequestsTotal, ) + ch <- prometheus.MustNewConstMetric( c.ntpServerOutgoingResponsesTotal, prometheus.CounterValue, diff --git a/internal/collector/udp/udp.go b/internal/collector/udp/udp.go index afa53107..977f4b2c 100644 --- a/internal/collector/udp/udp.go +++ b/internal/collector/udp/udp.go @@ -160,18 +160,21 @@ func (c *Collector) writeUDPCounters(ch chan<- prometheus.Metric, metrics []perf metrics[0].DatagramsNoPortPerSec, af, ) + ch <- prometheus.MustNewConstMetric( c.datagramsReceivedErrorsTotal, prometheus.CounterValue, metrics[0].DatagramsReceivedErrors, af, ) + ch <- prometheus.MustNewConstMetric( c.datagramsReceivedTotal, prometheus.GaugeValue, metrics[0].DatagramsReceivedPerSec, af, ) + ch <- prometheus.MustNewConstMetric( c.datagramsSentTotal, prometheus.CounterValue, diff --git a/internal/headers/iphlpapi/iphlpapi.go b/internal/headers/iphlpapi/iphlpapi.go index de127e03..24734be0 100644 --- a/internal/headers/iphlpapi/iphlpapi.go +++ b/internal/headers/iphlpapi/iphlpapi.go @@ -154,6 +154,7 @@ func GetIfEntry2Ex(row *MIB_IF_ROW2) error { // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/nf-netioapi-convertinterfaceguidtoluid func ConvertInterfaceGUIDToLUID(guid ole.GUID) (uint64, error) { var luid uint64 + ret, _, _ := procConvertInterfaceGuidToLuid.Call( uintptr(unsafe.Pointer(&guid)), uintptr(unsafe.Pointer(&luid)), diff --git a/internal/headers/psapi/psapi.go b/internal/headers/psapi/psapi.go index e9e4e023..6683062c 100644 --- a/internal/headers/psapi/psapi.go +++ b/internal/headers/psapi/psapi.go @@ -51,6 +51,7 @@ var ( // GetPerformanceInfo returns the dereferenced version of GetLPPerformanceInfo. func GetPerformanceInfo() (PerformanceInformation, error) { var lppi PerformanceInformation + size := (uint32)(unsafe.Sizeof(lppi)) lppi.cb = size r1, _, err := procGetPerformanceInfo.Call(uintptr(unsafe.Pointer(&lppi)), uintptr(size)) diff --git a/internal/headers/slc/slc.go b/internal/headers/slc/slc.go index de2aa6f2..afdd70c7 100644 --- a/internal/headers/slc/slc.go +++ b/internal/headers/slc/slc.go @@ -50,7 +50,6 @@ func SLIsWindowsGenuineLocal() (SL_GENUINE_STATE, error) { _, _, err := procSLIsWindowsGenuineLocal.Call( uintptr(unsafe.Pointer(&genuineState)), ) - if !errors.Is(err, windows.NTE_OP_OK) { return 0, err } diff --git a/internal/headers/sysinfoapi/sysinfoapi.go b/internal/headers/sysinfoapi/sysinfoapi.go index c4533ea8..10c1ed08 100644 --- a/internal/headers/sysinfoapi/sysinfoapi.go +++ b/internal/headers/sysinfoapi/sysinfoapi.go @@ -127,6 +127,7 @@ var ( // https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-globalmemorystatusex func GlobalMemoryStatusEx() (MemoryStatus, error) { var mse memoryStatusEx + mse.dwLength = (uint32)(unsafe.Sizeof(mse)) r1, _, err := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&mse))) diff --git a/internal/headers/wtsapi32/wtsapi32.go b/internal/headers/wtsapi32/wtsapi32.go index 5eb6f79e..8300b434 100644 --- a/internal/headers/wtsapi32/wtsapi32.go +++ b/internal/headers/wtsapi32/wtsapi32.go @@ -147,7 +147,6 @@ func WTSOpenServer(server string) (windows.Handle, error) { func WTSCloseServer(server windows.Handle) error { r1, _, err := procWTSCloseServer.Call(uintptr(server)) - if r1 != 1 && !errors.Is(err, windows.ERROR_SUCCESS) { return fmt.Errorf("failed to close server: %w", err) } @@ -196,6 +195,7 @@ func WTSEnumerateSessionsEx(server windows.Handle, logger *slog.Logger) ([]WTSSe } var sizeTest wtsSessionInfo1 + sessionSize := unsafe.Sizeof(sizeTest) sessions := make([]WTSSession, 0, count) diff --git a/internal/mi/application.go b/internal/mi/application.go index c4c4e42a..8e962f6f 100644 --- a/internal/mi/application.go +++ b/internal/mi/application.go @@ -113,7 +113,6 @@ func ApplicationInitialize() (*Application, error) { 0, uintptr(unsafe.Pointer(application)), ) - if !errors.Is(err, windows.NOERROR) { return nil, fmt.Errorf("syscall returned: %w", err) } diff --git a/internal/mi/operation.go b/internal/mi/operation.go index 4a4443dd..f90e9946 100644 --- a/internal/mi/operation.go +++ b/internal/mi/operation.go @@ -154,7 +154,6 @@ func (o *Operation) GetInstance() (*Instance, bool, error) { uintptr(unsafe.Pointer(&errorMessageUTF16)), uintptr(unsafe.Pointer(&errorDetails)), ) - if !errors.Is(instanceResult, MI_RESULT_OK) { return nil, false, fmt.Errorf("instance result: %w (%s)", instanceResult, windows.UTF16PtrToString(errorMessageUTF16)) } diff --git a/internal/mi/session.go b/internal/mi/session.go index 67be7515..33fb7eb7 100644 --- a/internal/mi/session.go +++ b/internal/mi/session.go @@ -109,13 +109,11 @@ func (s *Session) TestConnection() error { return result } - var err error - - if _, _, err = operation.GetInstance(); err != nil { + if _, _, err := operation.GetInstance(); err != nil { return fmt.Errorf("failed to get instance: %w", err) } - if err = operation.Close(); err != nil { + if err := operation.Close(); err != nil { return fmt.Errorf("failed to close operation: %w", err) } diff --git a/internal/pdh/pdh.go b/internal/pdh/pdh.go index ffc17a04..08f55295 100644 --- a/internal/pdh/pdh.go +++ b/internal/pdh/pdh.go @@ -549,8 +549,8 @@ func FormatError(msgID uint32) string { var flags uint32 = windows.FORMAT_MESSAGE_FROM_HMODULE | windows.FORMAT_MESSAGE_ARGUMENT_ARRAY | windows.FORMAT_MESSAGE_IGNORE_INSERTS buf := make([]uint16, 300) - _, err := windows.FormatMessage(flags, libPdhDll.Handle(), msgID, 0, buf, nil) + _, err := windows.FormatMessage(flags, libPdhDll.Handle(), msgID, 0, buf, nil) if err == nil { return windows.UTF16PtrToString(&buf[0]) } diff --git a/internal/pdh/registry/collector.go b/internal/pdh/registry/collector.go index e232a8fd..dcbb7f4f 100644 --- a/internal/pdh/registry/collector.go +++ b/internal/pdh/registry/collector.go @@ -54,6 +54,7 @@ func NewCollector[T any](object string, _ []string) (*Collector, error) { } var values [0]T + valueType := reflect.TypeOf(values).Elem() if f, ok := valueType.FieldByName("Name"); ok { diff --git a/pkg/collector/collect.go b/pkg/collector/collect.go index c695cf91..0784611f 100644 --- a/pkg/collector/collect.go +++ b/pkg/collector/collect.go @@ -200,7 +200,6 @@ func (c *Collection) collectCollector(ch chan<- prometheus.Metric, logger *slog. go func() { // Drain channel in case of premature return to not leak a goroutine. - //nolint:revive for range bufCh { } }()