Hi,
I’ve been working to add new features to an existing HomeAssistant plugin. One value that I’ve added is a datetime value.
I use the Prometheus plugin for HomeAssistant so that Prometheus can scrape all of the metrics I’m interested in and push them into a shared metrics database that I use for other monitoring.
I’ve noticed that Timestamps (or anything non-numeric) doesn’t seem to be exported by the Prometheus plugin.
Does anyone know if this is a specific implementation choice of the Prometheus plugin or is there a way to make it also export non-numeric values?
Another example of this is the “Sun” entity for Home Assistant. All of the stats associated with it are exported e.g. last_updated_time_seconds
but not the actual value of it e.g. “Above Horizon”.
Does anyone know how to make it export all the values? Strings included.
Screengrab below of the Sun entities displayed in Prometheus:
Answering my own question on this one (considered deleting it but thought it would be better to leave the info here in case someone else has the same thoughts as me in the future).
Prometheus does not, nor will it ever support non-numeric values. It defeats the whole point of the application. Therefore strings like datetimes and “Above horizon” etc are correctly NOT exported by the plugin, meta-values are e.g. the last time the state of the metric was updated/modified, but not the actual metric itself.
I hope this helps someone else in the future.
NOTE - If you desperately want some mapping of a string into Prometheus it’s best creating an ENUM or something for each of the possible string states e.g. “Above horizon” = 1, “Below horizon = 0” but these sorts of custom enums sit outside the scope of the Hass project and should probably be dealt with by writing a custom endpoint for Prometheus to hit that scrapes values from Hass and then interprets them in a defined way for Prometheus to consume.