Skip to content

Commit

Permalink
performancecounter: rename collector
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Nov 29, 2024
1 parent 2187c9a commit a84c6ca
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions internal/collector/performancecounter/performancecounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
counters := make([]string, 0, len(object.Counters))
for j, counter := range object.Counters {
counters = append(counters, counter.Name)

if counter.Metric == "" {
c.config.Objects[i].Counters[j].Metric = sanitizeMetricName(fmt.Sprintf("%s_perfdata_%s_%s", types.Namespace, object.Object, counter.Name))
}
Expand Down Expand Up @@ -142,6 +143,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric) error {
collectedCounterValue, ok := collectedInstanceCounters[counter.Name]
if !ok {
c.logger.Warn(fmt.Sprintf("counter %s not found in collected data", counter.Name))

continue
}

Expand Down
4 changes: 2 additions & 2 deletions internal/collector/performancecounter/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ type Object struct {
}

type Counter struct {
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"`
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"`
Metric string `json:"metric" yaml:"metric"`
Labels map[string]string `json:"labels" yaml:"labels"`
}
Expand Down
2 changes: 1 addition & 1 deletion tools/end-to-end-test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $exporter_proc = Start-Process `
-PassThru `
-FilePath ..\windows_exporter.exe `
-ArgumentList "--log.level=debug","--web.disable-exporter-metrics","--collectors.enabled=[defaults],cpu_info,textfile,process,pagefile,perfdata,scheduled_task,tcp,udp,time,system,service,logical_disk,printer,os,net,memory,logon,cache","--collector.process.include=explorer.exe","--collector.scheduled_task.include=.*GAEvents","--collector.service.include=Themes","--collector.textfile.directories=$($textfile_dir)",@"
--collector.perfdata.objects="[{\"object\":\"Processor Information\",\"instance_label\":\"core\",\"instances\":[\"*\"],\"counters\":{\"% Processor Time\":{},\"% Privileged Time\":{}}},{\"object\":\"Memory\",\"counters\":{\"Cache Faults/sec\":{\"type\":\"counter\"}}}]"
--collector.performancecounter.objects="[{\"object\":\"Processor Information\",\"instances\":[\"*\"],\"instance_label\":\"core\",\"counters\":[{\"name\":\"% Processor Time\",\"metric\":\"windows_perfdata_processor_information_processor_time\",\"labels\":{\"state\":\"active\"}},{\"name\":\"% Idle Time\",\"metric\":\"windows_perfdata_processor_information_processor_time\",\"labels\":{\"state\":\"idle\"}}]},{\"object\":\"Memory\",\"counters\":[{\"name\":\"Cache Faults/sec\",\"type\":\"counter\"}]}]"
"@ `
-WindowStyle Hidden `
-RedirectStandardOutput "$($temp_dir)/windows_exporter.log" `
Expand Down

0 comments on commit a84c6ca

Please sign in to comment.