baaym / openhab2-prometheus-exporter

Prometheus Exporter for OpenHAB 2
MIT License
4 stars 7 forks source link

Handle UNDEFs #1

Open imaginator opened 5 years ago

imaginator commented 5 years ago

This is exactly what I was looking for. Thanks.

Small issue: some of my values are UNDEF:

openhab2_metric_number{name="Hs110GlassCubeLight_Current"} 0.034 1557829413308
openhab2_metric_number{name="Hs110IndustrialLight_EnergyUsage"} 0.287 1557829413308
openhab2_metric_number{name="LocalSun_EveningNightDuration"} UNDEF 1557829413308
openhab2_metric_number{name="Hs110Fridge_Rssi"} -41 1557829413308
openhab2_metric_number{name="XiaomiImagiSuck_ConsumablesMainBrushTime"} 258.0 1557829413308
openhab2_metric_number{name="ChromecastMiniMainbath_EpisodeNumber"} UNDEF 1557829413308
openhab2_metric_number{name="LocalSun_PositionElevation"} 54.990202533513 1557829413308
openhab2_metric_number{name="LocalSun_NoonDuration"} 1 1557829413308

Which leads to this:

May 14 10:23:33 bunker prometheus[14105]: level=warn ts=2019-05-14T10:23:33.665419592Z caller=scrape.go:686 component="scrape manager" scrape_pool=openhab target=http://bunker.imagilan:9997/metrics msg="append failed" err="strconv.ParseFloat: parsing \"UNDEF\": invalid syntax"
gersilex commented 5 years ago

Hmm yes. UNDEF is basically hard to display. What would be the right thing to do with the metric when it’s not defined? Simply leaving it out of the output is my first thought about this. Pretty sure that using a pre-defined number would be wrong.

imaginator commented 5 years ago

I agree with you - leave out.

I sent you a PR to just leave it out as I see you are already doing with null values.

On Tue, 14 May 2019, 21:06 Leroy Förster, notifications@github.com wrote:

Hmm yes. UNDEF is basically hard to display. What would be the right thing to do with the metric when it’s not defined? Simply leaving it out of the output is my first thought about this. Pretty sure that using a pre-defined number would be wrong.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/baaym/openhab2-prometheus-exporter/issues/1?email_source=notifications&email_token=AADSURFV732SND6XLT2E2XDPVMETDA5CNFSM4HMYQKG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVMPG5Y#issuecomment-492368759, or mute the thread https://github.com/notifications/unsubscribe-auth/AADSURHEE23SYAXN7SDLDYDPVMETDANCNFSM4HMYQKGQ .