Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

process: Use registry collector for V1 data #1805

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/collector/ad/ad.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
Expand All @@ -36,7 +36,7 @@ var ConfigDefaults = Config{}
type Collector struct {
config Config

perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector

addressBookClientSessions *prometheus.Desc
addressBookOperationsTotal *prometheus.Desc
Expand Down Expand Up @@ -278,7 +278,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {

var err error

c.perfDataCollector, err = perfdata.NewCollector("DirectoryServices", perfdata.InstancesAll, counters)
c.perfDataCollector, err = pdh.NewCollector("DirectoryServices", pdh.InstancesAll, counters, false)
if err != nil {
return fmt.Errorf("failed to create DirectoryServices collector: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions internal/collector/adcs/adcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus-community/windows_exporter/internal/utils"
"github.com/prometheus/client_golang/prometheus"
Expand All @@ -37,7 +37,7 @@ var ConfigDefaults = Config{}
type Collector struct {
config Config

perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector

challengeResponseProcessingTime *prometheus.Desc
challengeResponsesPerSecond *prometheus.Desc
Expand Down Expand Up @@ -83,7 +83,7 @@ func (c *Collector) Close() error {
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
var err error

c.perfDataCollector, err = perfdata.NewCollector("Certification Authority", perfdata.InstancesAll, []string{
c.perfDataCollector, err = pdh.NewCollector("Certification Authority", pdh.InstancesAll, []string{
requestsPerSecond,
requestProcessingTime,
retrievalsPerSecond,
Expand All @@ -97,7 +97,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
challengeResponseProcessingTime,
signedCertificateTimestampListsPerSecond,
signedCertificateTimestampListProcessingTime,
})
}, false)
if err != nil {
return fmt.Errorf("failed to create Certification Authority collector: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions internal/collector/adfs/adfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
Expand All @@ -39,7 +39,7 @@ var ConfigDefaults = Config{}
type Collector struct {
config Config

perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector

adLoginConnectionFailures *prometheus.Desc
artifactDBFailures *prometheus.Desc
Expand Down Expand Up @@ -115,7 +115,7 @@ func (c *Collector) Close() error {
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
var err error

c.perfDataCollector, err = perfdata.NewCollector("AD FS", nil, []string{
c.perfDataCollector, err = pdh.NewCollector("AD FS", nil, []string{
adLoginConnectionFailures,
certificateAuthentications,
deviceAuthentications,
Expand Down Expand Up @@ -159,7 +159,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
configDBFailures,
avgConfigDBQueryTime,
federationMetadataRequests,
})
}, false)
if err != nil {
return fmt.Errorf("failed to create AD FS collector: %w", err)
}
Expand Down
10 changes: 5 additions & 5 deletions internal/collector/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
Expand All @@ -37,7 +37,7 @@ var ConfigDefaults = Config{}
type Collector struct {
config Config

perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector

asyncCopyReadsTotal *prometheus.Desc
asyncDataMapsTotal *prometheus.Desc
Expand Down Expand Up @@ -99,7 +99,7 @@ func (c *Collector) Close() error {
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
var err error

c.perfDataCollector, err = perfdata.NewCollector("Cache", perfdata.InstancesAll, []string{
c.perfDataCollector, err = pdh.NewCollector("Cache", pdh.InstancesAll, []string{
asyncCopyReadsTotal,
asyncDataMapsTotal,
asyncFastReadsTotal,
Expand Down Expand Up @@ -129,7 +129,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
syncFastReadsTotal,
syncMDLReadsTotal,
syncPinReadsTotal,
})
}, false)
if err != nil {
return fmt.Errorf("failed to create Cache collector: %w", err)
}
Expand Down Expand Up @@ -319,7 +319,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
return fmt.Errorf("failed to collect Cache metrics: %w", err)
}

cacheData, ok := data[perfdata.InstanceEmpty]
cacheData, ok := data[pdh.InstanceEmpty]

if !ok {
return fmt.Errorf("failed to collect Cache metrics: %w", types.ErrNoData)
Expand Down
8 changes: 4 additions & 4 deletions internal/collector/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/Microsoft/hcsshim"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
Expand Down Expand Up @@ -322,19 +322,19 @@ func (c *Collector) collectContainer(ch chan<- prometheus.Metric, containerDetai
ch <- prometheus.MustNewConstMetric(
c.runtimeTotal,
prometheus.CounterValue,
float64(containerStats.Processor.TotalRuntime100ns)*perfdata.TicksToSecondScaleFactor,
float64(containerStats.Processor.TotalRuntime100ns)*pdh.TicksToSecondScaleFactor,
containerIdWithPrefix,
)
ch <- prometheus.MustNewConstMetric(
c.runtimeUser,
prometheus.CounterValue,
float64(containerStats.Processor.RuntimeUser100ns)*perfdata.TicksToSecondScaleFactor,
float64(containerStats.Processor.RuntimeUser100ns)*pdh.TicksToSecondScaleFactor,
containerIdWithPrefix,
)
ch <- prometheus.MustNewConstMetric(
c.runtimeKernel,
prometheus.CounterValue,
float64(containerStats.Processor.RuntimeKernel100ns)*perfdata.TicksToSecondScaleFactor,
float64(containerStats.Processor.RuntimeKernel100ns)*pdh.TicksToSecondScaleFactor,
containerIdWithPrefix,
)
ch <- prometheus.MustNewConstMetric(
Expand Down
8 changes: 4 additions & 4 deletions internal/collector/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus-community/windows_exporter/internal/utils"
"github.com/prometheus/client_golang/prometheus"
Expand All @@ -38,7 +38,7 @@ var ConfigDefaults = Config{}
type Collector struct {
config Config

perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector

mu sync.Mutex

Expand Down Expand Up @@ -92,7 +92,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {

c.mu = sync.Mutex{}

c.perfDataCollector, err = perfdata.NewCollector("Processor Information", perfdata.InstancesAll, []string{
c.perfDataCollector, err = pdh.NewCollector("Processor Information", pdh.InstancesAll, []string{
c1TimeSeconds,
c2TimeSeconds,
c3TimeSeconds,
Expand All @@ -116,7 +116,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
processorTimeSeconds,
processorUtilityRate,
userTimeSeconds,
})
}, false)
if err != nil {
return fmt.Errorf("failed to create Processor Information collector: %w", err)
}
Expand Down
20 changes: 10 additions & 10 deletions internal/collector/dfsr/dfsr.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
Expand All @@ -44,9 +44,9 @@ var ConfigDefaults = Config{
type Collector struct {
config Config

perfDataCollectorConnection *perfdata.Collector
perfDataCollectorFolder *perfdata.Collector
perfDataCollectorVolume *perfdata.Collector
perfDataCollectorConnection *pdh.Collector
perfDataCollectorFolder *pdh.Collector
perfDataCollectorVolume *pdh.Collector

// connection source
connectionBandwidthSavingsUsingDFSReplicationTotal *prometheus.Desc
Expand Down Expand Up @@ -160,7 +160,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
var err error

if slices.Contains(c.config.CollectorsEnabled, "connection") {
c.perfDataCollectorConnection, err = perfdata.NewCollector("DFS Replication Connections", perfdata.InstancesAll, []string{
c.perfDataCollectorConnection, err = pdh.NewCollector("DFS Replication Connections", pdh.InstancesAll, []string{
bandwidthSavingsUsingDFSReplicationTotal,
bytesReceivedTotal,
compressedSizeOfFilesReceivedTotal,
Expand All @@ -170,14 +170,14 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
rdcNumberOfFilesReceivedTotal,
rdcSizeOfFilesReceivedTotal,
sizeOfFilesReceivedTotal,
})
}, false)
if err != nil {
return fmt.Errorf("failed to create DFS Replication Connections collector: %w", err)
}
}

if slices.Contains(c.config.CollectorsEnabled, "folder") {
c.perfDataCollectorFolder, err = perfdata.NewCollector("DFS Replicated Folders", perfdata.InstancesAll, []string{
c.perfDataCollectorFolder, err = pdh.NewCollector("DFS Replicated Folders", pdh.InstancesAll, []string{
bandwidthSavingsUsingDFSReplicationTotal,
compressedSizeOfFilesReceivedTotal,
conflictBytesCleanedUpTotal,
Expand Down Expand Up @@ -205,20 +205,20 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
stagingFilesCleanedUpTotal,
stagingFilesGeneratedTotal,
updatesDroppedTotal,
})
}, false)
if err != nil {
return fmt.Errorf("failed to create DFS Replicated Folders collector: %w", err)
}
}

if slices.Contains(c.config.CollectorsEnabled, "volume") {
c.perfDataCollectorVolume, err = perfdata.NewCollector("DFS Replication Service Volumes", perfdata.InstancesAll, []string{
c.perfDataCollectorVolume, err = pdh.NewCollector("DFS Replication Service Volumes", pdh.InstancesAll, []string{
databaseCommitsTotal,
databaseLookupsTotal,
usnJournalRecordsReadTotal,
usnJournalRecordsAcceptedTotal,
usnJournalUnreadPercentage,
})
}, false)
if err != nil {
return fmt.Errorf("failed to create DFS Replication Service Volumes collector: %w", err)
}
Expand Down
10 changes: 5 additions & 5 deletions internal/collector/dhcp/dhcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
Expand All @@ -37,7 +37,7 @@ var ConfigDefaults = Config{}
type Collector struct {
config Config

perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector

acksTotal *prometheus.Desc
activeQueueLength *prometheus.Desc
Expand Down Expand Up @@ -95,7 +95,7 @@ func (c *Collector) Close() error {
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
var err error

c.perfDataCollector, err = perfdata.NewCollector("DHCP Server", nil, []string{
c.perfDataCollector, err = pdh.NewCollector("DHCP Server", nil, []string{
acksTotal,
activeQueueLength,
conflictCheckQueueLength,
Expand All @@ -121,7 +121,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
packetsReceivedTotal,
releasesTotal,
requestsTotal,
})
}, false)
if err != nil {
return fmt.Errorf("failed to create DHCP Server collector: %w", err)
}
Expand Down Expand Up @@ -286,7 +286,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
return fmt.Errorf("failed to collect DHCP Server metrics: %w", err)
}

data, ok := perfData[perfdata.InstanceEmpty]
data, ok := perfData[pdh.InstanceEmpty]
if !ok {
return fmt.Errorf("failed to collect DHCP Server metrics: %w", types.ErrNoData)
}
Expand Down
10 changes: 5 additions & 5 deletions internal/collector/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/perfdata"
"github.com/prometheus-community/windows_exporter/internal/pdh"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
Expand All @@ -37,7 +37,7 @@ var ConfigDefaults = Config{}
type Collector struct {
config Config

perfDataCollector *perfdata.Collector
perfDataCollector *pdh.Collector

dynamicUpdatesFailures *prometheus.Desc
dynamicUpdatesQueued *prometheus.Desc
Expand Down Expand Up @@ -92,7 +92,7 @@ func (c *Collector) Close() error {
func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
var err error

c.perfDataCollector, err = perfdata.NewCollector("DNS", perfdata.InstancesAll, []string{
c.perfDataCollector, err = pdh.NewCollector("DNS", pdh.InstancesAll, []string{
axfrRequestReceived,
axfrRequestSent,
axfrResponseReceived,
Expand Down Expand Up @@ -133,7 +133,7 @@ func (c *Collector) Build(_ *slog.Logger, _ *mi.Session) error {
winsReverseResponseSent,
zoneTransferFailure,
zoneTransferSOARequestSent,
})
}, false)
if err != nil {
return fmt.Errorf("failed to create DNS collector: %w", err)
}
Expand Down Expand Up @@ -282,7 +282,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
return fmt.Errorf("failed to collect DNS metrics: %w", err)
}

data, ok := perfData[perfdata.InstanceEmpty]
data, ok := perfData[pdh.InstanceEmpty]
if !ok {
return fmt.Errorf("failed to collect DNS metrics: %w", types.ErrNoData)
}
Expand Down
Loading
Loading