webdevops / gq-gmc-exporter

Prometheus exporter for GQ GMC (Geiger–Muller counter) devices
MIT License
4 stars 0 forks source link

Consuming with Telegraf #1

Closed realies closed 2 years ago

realies commented 2 years ago

Is querying /metrics expected to list the gqgmc_info, gqgmc_cpm, gqgmc_voltage and gqgmc_temperature metrics?

mblaschke commented 2 years ago

Hm.. not used Telegraf yet. This exporter is currently only providing prometheus metric format.

Does Telegraf uses the same format? If not, feel free to provide a PR :)

realies commented 2 years ago

I'm not sure I'm getting the expected readout from the metrics endpoint. Can you please post an expected readout sample?

mblaschke commented 2 years ago

I'm monitoring my GQ GMC 300E plus device and get following metrics on :8080/metrics:

# HELP gqgmc_cpm GQ GMC counts per minute
# TYPE gqgmc_cpm gauge
gqgmc_cpm{port="/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0"} 18
# HELP gqgmc_info GQ GMC counts per minute
# TYPE gqgmc_info gauge
gqgmc_info{model="GMC-300",port="/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0",version="Re 4.60"} 1
# HELP gqgmc_temperature GQ GMC device temperature
# TYPE gqgmc_temperature gauge
gqgmc_temperature{port="/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0"} 0
# HELP gqgmc_voltage GQ GMC battery voltage
# TYPE gqgmc_voltage gauge
gqgmc_voltage{port="/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0"} 42

metrics go_, process_ and promhttp_ are published by default from the prometheus client.

realies commented 2 years ago

I don't appear to be having any gqgmc_* metrics when I open :8081/metrics, any ideas what could it be?


# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 3.8506e-05
go_gc_duration_seconds{quantile="0.25"} 3.9827e-05
go_gc_duration_seconds{quantile="0.5"} 5.6437e-05
go_gc_duration_seconds{quantile="0.75"} 8.6333e-05
go_gc_duration_seconds{quantile="1"} 0.000119451
go_gc_duration_seconds_sum 0.000709205
go_gc_duration_seconds_count 11
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 8
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.17"} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 589472
# HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed.
# TYPE go_memstats_alloc_bytes_total counter
go_memstats_alloc_bytes_total 2.6664352e+07
# HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table.
# TYPE go_memstats_buck_hash_sys_bytes gauge
go_memstats_buck_hash_sys_bytes 4226
# HELP go_memstats_frees_total Total number of frees.
# TYPE go_memstats_frees_total counter
go_memstats_frees_total 96402
# HELP go_memstats_gc_cpu_fraction The fraction of this program's available CPU time used by the GC since the program started.
# TYPE go_memstats_gc_cpu_fraction gauge
go_memstats_gc_cpu_fraction 2.6083043889169842e-06
# HELP go_memstats_gc_sys_bytes Number of bytes used for garbage collection system metadata.
# TYPE go_memstats_gc_sys_bytes gauge
go_memstats_gc_sys_bytes 5.014152e+06
# HELP go_memstats_heap_alloc_bytes Number of heap bytes allocated and still in use.
# TYPE go_memstats_heap_alloc_bytes gauge
go_memstats_heap_alloc_bytes 589472
# HELP go_memstats_heap_idle_bytes Number of heap bytes waiting to be used.
# TYPE go_memstats_heap_idle_bytes gauge
go_memstats_heap_idle_bytes 1.429504e+07
# HELP go_memstats_heap_inuse_bytes Number of heap bytes that are in use.
# TYPE go_memstats_heap_inuse_bytes gauge
go_memstats_heap_inuse_bytes 1.59744e+06
# HELP go_memstats_heap_objects Number of allocated objects.
# TYPE go_memstats_heap_objects gauge
go_memstats_heap_objects 1765
# HELP go_memstats_heap_released_bytes Number of heap bytes released to OS.
# TYPE go_memstats_heap_released_bytes gauge
go_memstats_heap_released_bytes 1.3574144e+07
# HELP go_memstats_heap_sys_bytes Number of heap bytes obtained from system.
# TYPE go_memstats_heap_sys_bytes gauge
go_memstats_heap_sys_bytes 1.589248e+07
# HELP go_memstats_last_gc_time_seconds Number of seconds since 1970 of last garbage collection.
# TYPE go_memstats_last_gc_time_seconds gauge
go_memstats_last_gc_time_seconds 1.6347799424444292e+09
# HELP go_memstats_lookups_total Total number of pointer lookups.
# TYPE go_memstats_lookups_total counter
go_memstats_lookups_total 0
# HELP go_memstats_mallocs_total Total number of mallocs.
# TYPE go_memstats_mallocs_total counter
go_memstats_mallocs_total 98167
# HELP go_memstats_mcache_inuse_bytes Number of bytes in use by mcache structures.
# TYPE go_memstats_mcache_inuse_bytes gauge
go_memstats_mcache_inuse_bytes 19200
# HELP go_memstats_mcache_sys_bytes Number of bytes used for mcache structures obtained from system.
# TYPE go_memstats_mcache_sys_bytes gauge
go_memstats_mcache_sys_bytes 32768
# HELP go_memstats_mspan_inuse_bytes Number of bytes in use by mspan structures.
# TYPE go_memstats_mspan_inuse_bytes gauge
go_memstats_mspan_inuse_bytes 123624
# HELP go_memstats_mspan_sys_bytes Number of bytes used for mspan structures obtained from system.
# TYPE go_memstats_mspan_sys_bytes gauge
go_memstats_mspan_sys_bytes 163840
# HELP go_memstats_next_gc_bytes Number of heap bytes when next garbage collection will take place.
# TYPE go_memstats_next_gc_bytes gauge
go_memstats_next_gc_bytes 4.194304e+06
# HELP go_memstats_other_sys_bytes Number of bytes used for other system allocations.
# TYPE go_memstats_other_sys_bytes gauge
go_memstats_other_sys_bytes 1.816582e+06
# HELP go_memstats_stack_inuse_bytes Number of bytes in use by the stack allocator.
# TYPE go_memstats_stack_inuse_bytes gauge
go_memstats_stack_inuse_bytes 884736
# HELP go_memstats_stack_sys_bytes Number of bytes obtained from system for stack allocator.
# TYPE go_memstats_stack_sys_bytes gauge
go_memstats_stack_sys_bytes 884736
# HELP go_memstats_sys_bytes Number of bytes obtained from system.
# TYPE go_memstats_sys_bytes gauge
go_memstats_sys_bytes 2.3808784e+07
# HELP go_threads Number of OS threads created.
# TYPE go_threads gauge
go_threads 14
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0.42
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 40960
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 10
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 1.370112e+07
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.63477920592e+09
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 7.29796608e+08
# HELP process_virtual_memory_max_bytes Maximum amount of virtual memory available in bytes.
# TYPE process_virtual_memory_max_bytes gauge
process_virtual_memory_max_bytes 1.8446744073709552e+19
# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served.
# TYPE promhttp_metric_handler_requests_in_flight gauge
promhttp_metric_handler_requests_in_flight 1
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 101
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0
mblaschke commented 2 years ago

any information available in log?

realies commented 2 years ago

Nothing other than this:


{"file":"main.go:32","func":"main","level":"info","msg":"starting gq-gmc-exporter v21.8.2 (24a9250; go1.17; by webdevops.io)"}
{"file":"main.go:33","func":"main","level":"info","msg":"{\"Logger\":{\"Debug\":false,\"Verbose\":false,\"LogJson\":true},\"Serial\":{\"Port\":\"/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0\",\"BaudRate\":57600,\"DataBits\":8,\"StopBits\":1},\"ServerBind\":\":8080\"}"}
{"file":"main.go:37","func":"main","level":"info","msg":"starting http server on :8080"}
mblaschke commented 2 years ago

which device are you using? i guess the serial settings are wrong so it isn't able to communicate.. i should add a timeout or something like that and a proper message that communication isn't possible 🤔

mblaschke commented 2 years ago

please try 21.10.0 and reopen if you still have issues

app will now panic if model/version cannot be detected (is empty) and will print both information if it's present

btw: you can run the app with --debug to get more information what it's doing

realies commented 2 years ago

@mblaschke, strange, that makes it return:

{"file":"main.go:32","func":"main","level":"info","msg":"starting gq-gmc-exporter v21.10.0 (4af083b; go1.17.2; by webdevops.io)"}
{"file":"main.go:33","func":"main","level":"info","msg":"{\"Logger\":{\"Debug\":true,\"Verbose\":false,\"LogJson\":true},\"Serial\":{\"Port\":\"/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0\",\"BaudRate\":57600,\"DataBits\":8,\"StopBits\":1,\"InterCharacterTimeout\":1000},\"ServerBind\":\":8080\"}"}
{"file":"main.go:37","func":"main","level":"info","msg":"starting http server on :8080"}
{"file":"serial.go:62","func":"write","level":"debug","msg":"sending GETVER command"}
{"file":"serial.go:69","func":"read","level":"debug","msg":"reading 7 bytes"}
{"file":"serial.go:69","func":"read","level":"debug","msg":"reading 7 bytes"}
{"file":"probe.go:87","func":"runProbeLoop","level":"panic","msg":"no model or version detected, please check serial settings or device support"}

panic: (*logrus.Entry) 0xc0001181c0

Creating with:

docker create --name='gq-gmc-exporter' --privileged=true -e 'SERIAL_PORT'='/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0' -e 'SERIAL_BAUDRATE'='57600' -e 'SERIAL_DATABITS'='8' -e 'SERIAL_STOPBITS'='1' -p '8081:8080/tcp' -v '/dev':'/dev':'rw' --user 0:0 'webdevops/gq-gmc-exporter:latest' --debug
mblaschke commented 2 years ago

the exporter now tries to communicate with the device and if that fails (not able to read any answer) it throws a panic. Maybe your serial settings are wrong, please check what settings your device is using.

realies commented 2 years ago

When I plug a 500+ or a 600+ device into a Windows OS, it auto-connects to their GUI software: image

When plugged into the Linux OS, it can be listed with lsusb, and /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 exists. Any ideas on how to debug?

mblaschke commented 2 years ago

can you try to communicate with minicom?

minicom -b 57600 -D /dev/... and then type: <GETVER>>

realies commented 2 years ago

I don't seem to be getting a reply. Tried setting Hardware Flow Control to OFF, and get the same. Also attempted to send LF with Ctrl+J. Perhaps I'm misusing?


$ lsusb
Bus 002 Device 002: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
$ sudo minicom -b 57600 -D /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
Welcome to minicom 2.7.1                                                                        

OPTIONS: I18n                                                                                   
Compiled on Dec 23 2019, 02:06:26.                                                              
Port /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0, 16:09:36                                 

Press CTRL-A Z for help on special keys                                                         

<GETVER>                                                                                        

<GETVER>>                                                                                       

CTRL-A Z for help | 57600 8N1 | NOR | Minicom 2.7.1 | VT102 | Offline | usb-1a86_USB_Serial-if00-port0  
mblaschke commented 2 years ago

As long as you dont get any reply it's not going to work. Are you sure, it's the right dev device? And please check the baud rate in the gmc device settings. I found the information that 115200 might be the default boud rate (still strange that it works on Windows).

mblaschke commented 2 years ago

any success for getting response from the device?