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

Performancecounter: panic: reflect.StructOf: field 0 has invalid name #1821

Closed
Nachtfalkeaw opened this issue Dec 27, 2024 · 3 comments · Fixed by #1822
Closed

Performancecounter: panic: reflect.StructOf: field 0 has invalid name #1821

Nachtfalkeaw opened this issue Dec 27, 2024 · 3 comments · Fixed by #1822
Labels

Comments

@Nachtfalkeaw
Copy link

Current Behavior

Command:
C:\Users\Alexander\Desktop\windows_exporter-0.30.0-rc.4-amd64.exe --config.file=C:\Users\Alexander\Desktop\windows_exporter.yml --log.file=C:\Users\Alexander\Desktop\windows_exporter.log

config:

I tried with

Panic
objects: |-

Panic
objects: |

Running but not perfcounter results.
objects:

Discrepancy in readme:
https://github.com/prometheus-community/windows_exporter/blob/master/docs/collector.performancecounter.md

top of readme ( |- vs | )

Caution

If you are using a configuration file, the value must be kept as a string.

Use a |- to keep the value as a string.

bottom of readme

Note

If you are using a configuration file, the value must be keep as string.

Example:

collector:
  performancecounter:
    objects: |
## C:\Users\Alexander\Desktop\windows_exporter-0.30.0-rc.4-amd64.exe --config.file=C:\Users\Alexander\Desktop\windows_exporter.yml --log.file=C:\Users\Alexander\Desktop\windows_exporter.log


collectors:
  enabled: performancecounter

## https://kb.paessler.com/en/topic/50673-how-can-i-find-out-the-names-of-available-performance-counters
## https://gist.github.com/shadowbq/7babb99078721c153346fed4173059ad
## per Windows cmd PerformanceCounter auslesen. Beispiel case-insensitive mit regex für BitLocker                 typeperf -qx | findstr /I /R BitLocker
## https://leanpub.com/windowspowershellnetworkingguide/read#leanpub-auto-performance-counters
## Powershell alle Performance Counter:
##                           Get-Counter -ListSet * | Sort-Object CounterSetName | Select-Object CounterSetName
## Powershell zu einem Performancecounter (hier: Prozess) die Pfade in Variable "paths":
##                           $paths = (Get-Counter -ListSet Prozess).paths
## Powershell alle Pfade aus de Variablen nun auslesen. Das ist das, was wir bei performancecounter brauchen
##                           Get-Counter -Counter $paths
collector:
  performancecounter:
### not working YAML
#    objects: |
#      - object: "Memory"
#        counters:
#          - name: "Cache Faults/sec"
#            type: "counter"
#      
#      - object: "BitLocker"
#        instances:
#          - "C:"
#          - "E:"
#          - "F:"
#        instance_label: "Laufwerk"
#        counters:
#          - name: "Write Requests/sec"
#            type: "counter"
#      
#      - object: "BitLocker"
#        instances:
#          - "D:"
#          - "G:"
#          - "H:"
#        instance_label: "DLaufwerk"
#        counters:
#          - name: "Read Requests/sec"
#            type: "counter"
#
### working JSON
    objects: |-
      [
        {
          "name": "pf1",
          "object": "Memory",
          "counters": [
            {
              "name": "Cache Faults/sec",
              "type": "counter"
            }
          ]
        },
        {
          "name": "pf2",
          "object": "BitLocker",
          "instances": [
            "*"
          ],
          "instance_label": "Laufwerk",
          "counters": [
            {
              "name": "Write Requests/sec",
              "type": "counter"
            },
            {
              "name": "Write Subrequests/sec",
              "type": "counter"
            },
            {
              "name": "Read Requests/sec",
              "type": "counter"
            },
            {
              "name": "Read Subrequests/sec",
              "type": "counter"
            }
          ]
        },
        {
          "name": "pf3",
          "object": "Event Tracing for Windows",
          "counters": [
            {
              "name": "Total Memory Usage --- Non-Paged Pool",
              "type": "counter"
            },
            {
              "name": "Total Memory Usage --- Paged Pool",
              "type": "counter"
            },
            {
              "name": "Total Number of Active Sessions",
              "type": "counter"
            },
            {
              "name": "Total Number of Distinct Disabled Providers",
              "type": "counter"
            }
          ]
        },
        {
          "name": "pf4",
          "object": "User Input Delay per Session",
          "counters": [
            {
              "name": "Max Session Input Delay (ms)",
              "type": "counter"
            }
          ]
        }
      ]

##
##
##      - object: "Processor Information"
##        instances: ["*"]
##        instance_label: "core"
##        counters:
##          - name: "% Processor Time"
##            type: "gauge"
##            metric: windows_performancecounter_processor_information_processor_time # optional
##            labels:
##              state: active
##          - name: "% Idle Time"
##            type: "counter"
##            metric: windows_performancecounter_processor_information_processor_time # optional
##            labels:
##              state: idle
##
##      - object: "BitLocker"
##        instances: ["C:"]
##        instance_label: "Laufwerk"
##        counters:
##          - name: "Schreibunteranforderungen/Sek."
##            metric: windows_performancecounter_bitlocker_leseanforderungen_seconds # optional
##            labels:
##              state: active
##
##      - object: "BitLocker"
##        instances: ["*"]
##        instance_label: "Laufwerk"
##        counters:
##          - name: "*"
##            #metric: windows_performancecounter_bitlocker_leseanforderungen_seconds # optional
##            labels:
##              state: active
##



## collectors:
##   enabled: ad,adcs,adfs,cache,cpu,cpu_info,cs,diskdrive,dfsr,dhcp,dns,exchange,filetime,fsrmquota,hyperv,iis,license,logical_disk,logon,memory,mscluster,msmq,mssql,netframework,net,os,pagefile,perfdata,physical_disk,printer,process,remote_fx,scheduled_task,service,smb,smbclient,smtp,system,tcp,terminal_services,thermalzone,time,udp,update,vmware
## collector:
##   process:
##     include: .*alloy.*
##   service:
##     exclude: ".*"
##   scheduled_task:
##     exclude: ".*"
##   mssql:
##     enabled_classes: ["accessmethods", "availreplica", "bufman", "databases", "dbreplica", "genstats", "locks", "memmgr", "sqlstats", "sqlerrors", "transactions", "waitstats"]
##   smb:
##     enabled_list: "ServerShares"
##   smb_client:
##     enabled_list: "ClientShares"
##   hyperv:
##     enabled: datastore,dynamic_memory_balancer,dynamic_memory_vm,hypervisor_logical_processor,hypervisor_root_partition,hypervisor_root_virtual_processor,hypervisor_virtual_processor,legacy_network_adapter,virtual_machine_health_summary,virtual_machine_vid_partition,virtual_network_adapter,virtual_network_adapter_drop_reasons,virtual_smb,virtual_storage_device,virtual_switch
##   filetime:
##     file-patterns: C:\Users\Alexander\Desktop\windows_exporter.log


log:
  level: debug
scrape:
  timeout-margin: 0.5
telemetry:
  path: /metrics
  max-requests: 0
web:
  listen-address: ":9182"
  disable-exporter-metrics: true     ## disabled go, prom metrics

Error:

C:\WINDOWS\system32>C:\Users\Alexander\Desktop\windows_exporter-0.30.0-rc.4-amd64.exe --config.file=C:\Users\Alexander\Desktop\windows_exporter.yml --log.file=C:\Users\Alexander\Desktop\windows_exporter.log
panic: reflect.StructOf: field 0 has invalid name

goroutine 9 [running]:
reflect.StructOf({0xc0000f8000, 0x2, 0xc000047f18?})
        C:/hostedtoolcache/windows/go/1.23.4/x64/src/reflect/type.go:2371 +0x2694
github.com/prometheus-community/windows_exporter/internal/collector/performancecounter.(*Collector).Build(0xc000144e60, 0xc000243e00, 0xdd9440?)
        D:/a/windows_exporter/windows_exporter/internal/collector/performancecounter/performancecounter.go:193 +0x1525
github.com/prometheus-community/windows_exporter/pkg/collector.(*Collection).Build.func1()
        D:/a/windows_exporter/windows_exporter/pkg/collector/collection.go:220 +0x8a
created by github.com/prometheus-community/windows_exporter/pkg/collector.(*Collection).Build in goroutine 1
        D:/a/windows_exporter/windows_exporter/pkg/collector/collection.go:217 +0x1e5

C:\WINDOWS\system32>
C:\WINDOWS\system32>
C:\WINDOWS\system32>C:\Users\Alexander\Desktop\windows_exporter-0.30.0-rc.4-amd64.exe --config.file=C:\Users\Alexander\Desktop\windows_exporter.yml --log.file=C:\Users\Alexander\Desktop\windows_exporter.log
panic: reflect.StructOf: field 0 has invalid name

goroutine 23 [running]:
reflect.StructOf({0xc000328000, 0x2, 0xc000047f18?})
        C:/hostedtoolcache/windows/go/1.23.4/x64/src/reflect/type.go:2371 +0x2694
github.com/prometheus-community/windows_exporter/internal/collector/performancecounter.(*Collector).Build(0xc0000f4f00, 0xc0001f7ea0, 0xdd9440?)
        D:/a/windows_exporter/windows_exporter/internal/collector/performancecounter/performancecounter.go:193 +0x1525
github.com/prometheus-community/windows_exporter/pkg/collector.(*Collection).Build.func1()
        D:/a/windows_exporter/windows_exporter/pkg/collector/collection.go:220 +0x8a
created by github.com/prometheus-community/windows_exporter/pkg/collector.(*Collection).Build in goroutine 1
        D:/a/windows_exporter/windows_exporter/pkg/collector/collection.go:217 +0x1e5

C:\WINDOWS\system32>
C:\WINDOWS\system32>
C:\WINDOWS\system32>C:\Users\Alexander\Desktop\windows_exporter-0.30.0-rc.4-amd64.exe --config.file=C:\Users\Alexander\Desktop\windows_exporter.yml --log.file=C:\Users\Alexander\Desktop\windows_exporter.log
panic: reflect.StructOf: field 0 has invalid name

goroutine 7 [running]:
reflect.StructOf({0xc000270000, 0x2, 0xc0003c7f18?})
        C:/hostedtoolcache/windows/go/1.23.4/x64/src/reflect/type.go:2371 +0x2694
github.com/prometheus-community/windows_exporter/internal/collector/performancecounter.(*Collector).Build(0xc000338640, 0xc0003ac3f0, 0xdd9440?)
        D:/a/windows_exporter/windows_exporter/internal/collector/performancecounter/performancecounter.go:193 +0x1525
github.com/prometheus-community/windows_exporter/pkg/collector.(*Collection).Build.func1()
        D:/a/windows_exporter/windows_exporter/pkg/collector/collection.go:220 +0x8a
created by github.com/prometheus-community/windows_exporter/pkg/collector.(*Collection).Build in goroutine 1
        D:/a/windows_exporter/windows_exporter/pkg/collector/collection.go:217 +0x1e5

Expected Behavior

metrics, no panic,

Steps To Reproduce

see above

Environment

  • windows_exporter Version: windows_exporter-0.30.0-rc.4-amd64.exe
  • Windows Version: 10

windows_exporter logs

time=2024-12-27T19:53:15.522Z level=INFO source=config.go:79 msg="loading configuration file: C:\\Users\\Alexander\\Desktop\\windows_exporter.yml"
time=2024-12-27T19:53:15.523Z level=DEBUG source=main.go:196 msg="logging has Started"
time=2024-12-27T19:53:15.523Z level=DEBUG source=main.go:337 msg="setting process priority to normal"
time=2024-12-27T19:53:15.527Z level=ERROR source=main.go:218 msg="couldn't initialize collector" err="error build collector performancecounter: object name is required"
time=2024-12-27T19:53:23.115Z level=INFO source=config.go:79 msg="loading configuration file: C:\\Users\\Alexander\\Desktop\\windows_exporter.yml"
time=2024-12-27T19:53:23.116Z level=DEBUG source=main.go:196 msg="logging has Started"
time=2024-12-27T19:53:23.116Z level=DEBUG source=main.go:337 msg="setting process priority to normal"
time=2024-12-27T19:53:23.120Z level=ERROR source=main.go:218 msg="couldn't initialize collector" err="error build collector performancecounter: object name is required"
time=2024-12-27T19:54:28.866Z level=INFO source=config.go:79 msg="loading configuration file: C:\\Users\\Alexander\\Desktop\\windows_exporter.yml"
time=2024-12-27T19:54:28.867Z level=DEBUG source=main.go:196 msg="logging has Started"
time=2024-12-27T19:54:28.867Z level=DEBUG source=main.go:337 msg="setting process priority to normal"
time=2024-12-27T19:54:29.142Z level=ERROR source=main.go:218 msg="couldn't initialize collector" err="error build collector performancecounter: object name is required"
time=2024-12-27T19:55:07.954Z level=INFO source=config.go:79 msg="loading configuration file: C:\\Users\\Alexander\\Desktop\\windows_exporter.yml"
time=2024-12-27T19:55:07.955Z level=DEBUG source=main.go:196 msg="logging has Started"
time=2024-12-27T19:55:07.955Z level=DEBUG source=main.go:337 msg="setting process priority to normal"
time=2024-12-27T19:55:08.230Z level=ERROR source=main.go:218 msg="couldn't initialize collector" err="error build collector performancecounter: object name is required"
time=2024-12-27T19:57:10.635Z level=INFO source=config.go:79 msg="loading configuration file: C:\\Users\\Alexander\\Desktop\\windows_exporter.yml"
time=2024-12-27T19:57:10.636Z level=DEBUG source=main.go:196 msg="logging has Started"
time=2024-12-27T19:57:10.636Z level=DEBUG source=main.go:337 msg="setting process priority to normal"
time=2024-12-27T19:57:10.904Z level=ERROR source=main.go:218 msg="couldn't initialize collector" err="error build collector performancecounter: object name is required"
time=2024-12-27T19:57:43.346Z level=INFO source=config.go:79 msg="loading configuration file: C:\\Users\\Alexander\\Desktop\\windows_exporter.yml"
time=2024-12-27T19:57:43.347Z level=DEBUG source=main.go:196 msg="logging has Started"
time=2024-12-27T19:57:43.347Z level=DEBUG source=main.go:337 msg="setting process priority to normal"
time=2024-12-27T19:57:43.355Z level=INFO source=main.go:311 msg="Running as NACHTFALKE\\Alexander"
time=2024-12-27T19:57:43.355Z level=INFO source=main.go:228 msg="Enabled collectors: performancecounter"
time=2024-12-27T19:57:43.355Z level=INFO source=main.go:246 msg="starting windows_exporter in 9.7822ms" version=0.30.0-rc.4 branch=HEAD revision=78386557d4dcb168b82e87084db8faf04dacdd72 goversion=go1.23.4 builddate=20241222-13:19:26 maxprocs=12
time=2024-12-27T19:57:43.357Z level=INFO source=tls_config.go:347 msg="Listening on" address=[::]:9182
time=2024-12-27T19:57:43.357Z level=INFO source=tls_config.go:350 msg="TLS is disabled." http2=false address=[::]:9182
time=2024-12-27T19:57:56.653Z level=DEBUG source=collect.go:220 msg="collector performancecounter succeeded after 0s, resulting in 0 metrics"
time=2024-12-27T19:58:30.486Z level=DEBUG source=collect.go:220 msg="collector performancecounter succeeded after 0s, resulting in 0 metrics"
time=2024-12-27T20:00:00.159Z level=INFO source=main.go:278 msg="Shutting down windows_exporter via kill signal"
time=2024-12-27T20:00:00.159Z level=INFO source=main.go:296 msg="windows_exporter has shut down"
time=2024-12-27T20:00:55.715Z level=INFO source=config.go:79 msg="loading configuration file: C:\\Users\\Alexander\\Desktop\\windows_exporter.yml"
time=2024-12-27T20:00:55.717Z level=DEBUG source=main.go:196 msg="logging has Started"
time=2024-12-27T20:00:55.717Z level=DEBUG source=main.go:337 msg="setting process priority to normal"
time=2024-12-27T20:01:40.411Z level=INFO source=config.go:79 msg="loading configuration file: C:\\Users\\Alexander\\Desktop\\windows_exporter.yml"
time=2024-12-27T20:01:40.412Z level=DEBUG source=main.go:196 msg="logging has Started"
time=2024-12-27T20:01:40.412Z level=DEBUG source=main.go:337 msg="setting process priority to normal"
time=2024-12-27T20:01:59.123Z level=INFO source=config.go:79 msg="loading configuration file: C:\\Users\\Alexander\\Desktop\\windows_exporter.yml"
time=2024-12-27T20:01:59.124Z level=DEBUG source=main.go:196 msg="logging has Started"
time=2024-12-27T20:01:59.124Z level=DEBUG source=main.go:337 msg="setting process priority to normal"
time=2024-12-27T20:02:33.716Z level=INFO source=config.go:79 msg="loading configuration file: C:\\Users\\Alexander\\Desktop\\windows_exporter.yml"
time=2024-12-27T20:02:33.717Z level=DEBUG source=main.go:196 msg="logging has Started"
time=2024-12-27T20:02:33.717Z level=DEBUG source=main.go:337 msg="setting process priority to normal"
time=2024-12-27T20:05:54.677Z level=INFO source=config.go:79 msg="loading configuration file: C:\\Users\\Alexander\\Desktop\\windows_exporter.yml"
time=2024-12-27T20:05:54.678Z level=DEBUG source=main.go:196 msg="logging has Started"
time=2024-12-27T20:05:54.678Z level=DEBUG source=main.go:337 msg="setting process priority to normal"
time=2024-12-27T20:05:54.689Z level=INFO source=main.go:311 msg="Running as NACHTFALKE\\Alexander"
time=2024-12-27T20:05:54.689Z level=INFO source=main.go:228 msg="Enabled collectors: performancecounter"
time=2024-12-27T20:05:54.689Z level=INFO source=main.go:246 msg="starting windows_exporter in 12.912ms" version=0.30.0-rc.4 branch=HEAD revision=78386557d4dcb168b82e87084db8faf04dacdd72 goversion=go1.23.4 builddate=20241222-13:19:26 maxprocs=12
time=2024-12-27T20:05:54.690Z level=INFO source=tls_config.go:347 msg="Listening on" address=[::]:9182
time=2024-12-27T20:05:54.690Z level=INFO source=tls_config.go:350 msg="TLS is disabled." http2=false address=[::]:9182
time=2024-12-27T20:06:00.272Z level=DEBUG source=collect.go:220 msg="collector performancecounter succeeded after 0s, resulting in 0 metrics"
time=2024-12-27T20:06:02.079Z level=DEBUG source=collect.go:220 msg="collector performancecounter succeeded after 0s, resulting in 0 metrics"
time=2024-12-27T20:06:04.043Z level=DEBUG source=collect.go:220 msg="collector performancecounter succeeded after 0s, resulting in 0 metrics"
time=2024-12-27T20:06:04.283Z level=DEBUG source=collect.go:220 msg="collector performancecounter succeeded after 0s, resulting in 0 metrics"
time=2024-12-27T20:06:04.442Z level=DEBUG source=collect.go:220 msg="collector performancecounter succeeded after 0s, resulting in 0 metrics"
time=2024-12-27T20:06:04.594Z level=DEBUG source=collect.go:220 msg="collector performancecounter succeeded after 0s, resulting in 0 metrics"

Anything else?

No response

@jkroepke
Copy link
Member

thanks, Seems like I did not sanitize brackets.

The fix in available here: https://github.com/prometheus-community/windows_exporter/actions/runs/12454122957/artifacts/2353309323 and in the next release.

@Nachtfalkeaw
Copy link
Author

@jkroepke
tried the binary from the provided link.

still panics - same config as before:

C:\WINDOWS\system32>C:\Users\Alexander\Desktop\windows_exporter-0.30.0-rc.3-1-g7838655-amd64.exe  --config.file=C:\Users\Alexander\Desktop\windows_exporter.yml --log.file=C:\Users\Alexander\Desktop\windows_exporter.log
panic: reflect.StructOf: field 0 has invalid name

goroutine 10 [running]:
reflect.StructOf({0xc00035a000, 0x2, 0xc000047f18?})
        C:/hostedtoolcache/windows/go/1.23.4/x64/src/reflect/type.go:2371 +0x2694
github.com/prometheus-community/windows_exporter/internal/collector/performancecounter.(*Collector).Build(0xc000142eb0, 0xc00023fed0, 0x179440?)
        D:/a/windows_exporter/windows_exporter/internal/collector/performancecounter/performancecounter.go:193 +0x1525
github.com/prometheus-community/windows_exporter/pkg/collector.(*Collection).Build.func1()
        D:/a/windows_exporter/windows_exporter/pkg/collector/collection.go:220 +0x8a
created by github.com/prometheus-community/windows_exporter/pkg/collector.(*Collection).Build in goroutine 1
        D:/a/windows_exporter/windows_exporter/pkg/collector/collection.go:217 +0x1e5

C:\WINDOWS\system32>C:\Users\Alexander\Desktop\windows_exporter-0.30.0-rc.3-1-g7838655-amd64.exe  --config.file=C:\Users\Alexander\Desktop\windows_exporter.yml --log.file=C:\Users\Alexander\Desktop\windows_exporter.log
panic: reflect.StructOf: field 0 has invalid name

goroutine 7 [running]:
reflect.StructOf({0xc0002d8000, 0x2, 0xc0003a9f18?})
        C:/hostedtoolcache/windows/go/1.23.4/x64/src/reflect/type.go:2371 +0x2694
github.com/prometheus-community/windows_exporter/internal/collector/performancecounter.(*Collector).Build(0xc000316640, 0xc00038c3f0, 0x179440?)
        D:/a/windows_exporter/windows_exporter/internal/collector/performancecounter/performancecounter.go:193 +0x1525
github.com/prometheus-community/windows_exporter/pkg/collector.(*Collection).Build.func1()
        D:/a/windows_exporter/windows_exporter/pkg/collector/collection.go:220 +0x8a
created by github.com/prometheus-community/windows_exporter/pkg/collector.(*Collection).Build in goroutine 1
        D:/a/windows_exporter/windows_exporter/pkg/collector/collection.go:217 +0x1e5

I get the panic with
objects: |-

and this:
objects: |

what is the correct syntax?

@jkroepke
Copy link
Member

jkroepke commented Dec 29, 2024

It seems like I deliver the wrong link to you. I guess I had a old tab open. Sorry for that.

Here is the correct one: https://github.com/prometheus-community/windows_exporter/actions/runs/12520747861/artifacts/2366802477 the file name is windows_exporter-0.30.0-rc.4-1-g81ea4c6

I also provide a documentation how to access the builds by your own.

https://github.com/prometheus-community/windows_exporter/wiki/Snapshot-Builds

I get the panic with
objects: |-

and this:
objects: |

what is the correct syntax?

Both variants are fine. The pipe is mandatory. The hypen declare that a pending newline is trimmed. https://yaml-multiline.info/ describe it well.

YAML hass approx 63 different variation how multi line values can be declared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants