Skip to content

Commit

Permalink
collector: remove windows_exporter_perflib_snapshot_duration_seconds …
Browse files Browse the repository at this point in the history
…metric

Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Nov 24, 2024
1 parent 4b93978 commit 54e49f5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions internal/collector/iis/iis_w3svc_w3wp.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,7 @@ func (c *Collector) collectW3SVCW3WP(ch chan<- prometheus.Metric) error {
pid := workerProcessNameExtractor.ReplaceAllString(name, "$1")

name := workerProcessNameExtractor.ReplaceAllString(name, "$2")
if name == "" || name == "_Total" ||
c.config.AppExclude.MatchString(name) ||
if name == "" || c.config.AppExclude.MatchString(name) ||
!c.config.AppInclude.MatchString(name) {
continue
}
Expand Down
4 changes: 2 additions & 2 deletions internal/collector/nps/nps.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (c *Collector) collectAccept(ch chan<- prometheus.Metric) error {
return fmt.Errorf("failed to collect NPS Authentication Server metrics: %w", err)
}

data, ok := perfData[perfdata.EmptyInstance]
data, ok := perfData[perfdata.InstanceEmpty]
if !ok {
return errors.New("perflib query for NPS Authentication Server returned empty result set")
}
Expand Down Expand Up @@ -390,7 +390,7 @@ func (c *Collector) collectAccounting(ch chan<- prometheus.Metric) error {
return fmt.Errorf("failed to collect NPS Accounting Server metrics: %w", err)
}

data, ok := perfData[perfdata.EmptyInstance]
data, ok := perfData[perfdata.InstanceEmpty]
if !ok {
return errors.New("perflib query for NPS Accounting Server returned empty result set")
}
Expand Down
4 changes: 1 addition & 3 deletions internal/collector/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
// Duplicate processes are suffixed #, and an index number. Remove those.
name, _, _ = strings.Cut(name, "#")

if name == "_Total" ||
c.config.ProcessExclude.MatchString(name) ||
!c.config.ProcessInclude.MatchString(name) {
if c.config.ProcessExclude.MatchString(name) || !c.config.ProcessInclude.MatchString(name) {
continue
}

Expand Down
2 changes: 1 addition & 1 deletion internal/collector/vmware/vmware.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func (c *Collector) collectCpu(ch chan<- prometheus.Metric) error {
return fmt.Errorf("failed to collect VM Memory metrics: %w", err)
}

data, ok := perfData["_Total"]
data, ok := perfData[perfdata.InstanceTotal]
if !ok {
return errors.New("query for VM CPU returned empty result set")
}
Expand Down
4 changes: 2 additions & 2 deletions internal/perfdata/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewCollector(object string, instances []string, counters []string) (*Collec
object: object,
counters: make(map[string]Counter, len(counters)),
handle: handle,
totalCounterRequested: slices.Contains(instances, "_Total"),
totalCounterRequested: slices.Contains(instances, InstanceTotal),
mu: sync.RWMutex{},
}

Expand Down Expand Up @@ -186,7 +186,7 @@ func (c *Collector) Collect() (map[string]map[string]CounterValues, error) {
for _, item := range items {
if item.RawValue.CStatus == PdhCstatusValidData || item.RawValue.CStatus == PdhCstatusNewData {
instanceName := windows.UTF16PtrToString(item.SzName)
if strings.HasSuffix(instanceName, "_Total") && !c.totalCounterRequested {
if strings.HasSuffix(instanceName, InstanceTotal) && !c.totalCounterRequested {
continue
}

Expand Down
6 changes: 4 additions & 2 deletions internal/perfdata/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ package perfdata

import "github.com/prometheus/client_golang/prometheus"

const InstanceEmpty = "------"
const InstanceTotal = "_Total"
const (
InstanceEmpty = "------"
InstanceTotal = "_Total"
)

type CounterValues struct {
Type prometheus.ValueType
Expand Down

0 comments on commit 54e49f5

Please sign in to comment.