node-exporter-textfile-collector-scripts icon indicating copy to clipboard operation
node-exporter-textfile-collector-scripts copied to clipboard

lvm-prom-collector: Fix text format error

Open sr opened this issue 4 years ago • 1 comments

This fixes the following error:

level=error ts=2021-02-07T10:44:19.990Z caller=textfile.go:209 collector=textfile msg="failed to collect textfile data" file=metrics.prom err="failed to parse textfile data from \"/var/lib/node-exporter/lvm.prom\": text format parsing error in line 15: expected float as value, got \"\""

For deactivated thin LVs, the data_percent field is empty, which causes the script to emit a metric without a value.

This handles this case by simply not emitting node_lvm_thin_pools_allocated if data_percent is empty.

Another approach could be to filter out inactive LVs, like this:

lvs --noheadings --select 'lv_attr=~[^t.*] && lv_active=active' --units b --nosuffix --unquoted --nameprefixes --options lv_uuid,vg_name,lv_name,data_percent

However this works just fine and is probably easier to understand.

/cc @badrabubker

sr avatar Feb 07 '21 15:02 sr

@sr Can you please rebase this on current master, and confirm whether it is still an issue?

dswarbrick avatar May 19 '23 14:05 dswarbrick