wymangr / blueiris_exporter

Prometheus Exporter for Blue Iris
MIT License
17 stars 2 forks source link

Add BlueIris profile monitoring and Fix Bytes format #6

Closed JulesL2 closed 4 months ago

JulesL2 commented 8 months ago

Hi, I have developped a feature to monitor the active profile of BlueIris. It can be used in grafana with this example of visualization. Capture d'écran 2024-02-22 154324

Moreover, I have updated the way the code handle the bytes units because blueiris logs have changed with the newest version old version: [300/432 hrs, 3.63T/3.63T, 5.33G free]

New version: [240/336 hrs, 459.4/460.0GB, 6.17GB free]

As there is no more the unit in the used storage and as there is also the GB vs G, I have extracted units and passed it as an argument to the function ConvertBytes. It works with a log that has got both formats.

Hope these pieces of code can be included in the code :)

wymangr commented 4 months ago

Hi @JulesL2 thank you for the contribution!

I'm getting an error when I try and run your code. Looks like an issue with the updated regex. I'll take a closer look when I get a minute.

2024.07.02 08:35:32 - [info] - starting Blue Iris Exporter with the following:
                Log Path: C:\Users\Garret\Desktop\github\log
                Metric Path: /metrics
                Port: :2112
panic: regexp: Compile(`(?P<folder>[^\s\\]*)(\s*Delete:).+(\[((\s(?P<sizeused>[\d\.]+)(?P<sizeunit>\w*)\/(?P<sizelimit>[\d\.]+)(?P<sizelimitunit>\w+)),\s((?P<diskfree>[\d\.]+)(?P<freeunit>\w+))\sfree\])`): error parsing regexp: missing closing ): `(?P<folder>[^\s\\]*)(\s*Delete:).+(\[((\s(?P<sizeused>[\d\.]+)(?P<sizeunit>\w*)\/(?P<sizelimit>[\d\.]+)(?P<sizelimitunit>\w+)),\s((?P<diskfree>[\d\.]+)(?P<freeunit>\w+))\sfree\])`

goroutine 20 [running]:
regexp.MustCompile({0x6de796, 0xb2})
        C:/Program Files/Go/src/regexp/regexp.go:317 +0xbb
github.com/wymangr/blueiris_exporter/blueiris.findObject({0xc000033d40, 0x60})
        C:/Users/User/Desktop/github/blueiris_exporter/blueiris/blueirisMetrics.go:418 +0x1009
github.com/wymangr/blueiris_exporter/blueiris.BlueIris(0xc00007e240?, {0xc00021ee00, 0x2, {0x6c1bd8, 0xb}, 0x1, {0xc000248000, 0x15, 0x15}, 0x6fb8b0, ...}, ...)
        C:/Users/User/Desktop/github/blueiris_exporter/blueiris/blueirisMetrics.go:102 +0x5c5
main.CollectMetrics(0x0?, 0x0?, {0xc00021ee00, 0x2, {0x6c1bd8, 0xb}, 0x1, {0xc000248000, 0x15, 0x15}, ...}, ...)
        C:/Users/User/Desktop/github/blueiris_exporter/metrics.go:112 +0x34b
created by main.(*ExporterBlueIris).Collect
        C:/Users/User/Desktop/github/blueiris_exporter/blueiris_exporter.go:38 +0x285
exit status 2
wymangr commented 4 months ago

@JulesL2 Okay, I've suggested a few changes (most are nit picky formatting changes, sorry about that).