rtl_433
rtl_433 copied to clipboard
Influxdb configurable prefix
I'm feeding data from various weather sensors to VictoriaMetrics (and Grafana). I did not like metric names that are based on free-text model names because they make it harder to plot, say, temperature across multiple sensor types. Without this patch, I might get multiple metrics about, say, temperature:
-
Fineoffset-WS90_temperature_C
, -
Fineoffset-WN34_temperature_C
.
Since this project already has a concept of unified property names, I would prefer to see metrics named like rtl433_temperature_C
which would be further parametrized ("labels" in PromQL/Grafana terms) by the protocol (-M proto
), sensor ID, channel #, etc.
This patch implements just that. I ended up making the pattern format string customizable a la MQTT which is one step further than what I needed, but it came essentially free, so why not. That means that I can now run rtl_433
this like:
rtl_433 -f 868.35M -M time:utc -s 300k -F 'influx://[::1]:8428/write?.,metric=rtl433' \
-M protocol -M level -R 142 -R 221 -R 244 -R 113 -Y autolevel
...and I will get nice, unified metric names which enable me to plot a graph like this with a single metric, despite the fact that it's aggregating battery health from three different HW types:
Here's how this PR implements that:
- fix
-Wstringop-truncation
which would silenty truncate URLs longer than 399 characters (because my compiler bugs me about this) - make the MQTT formatter reusable
- use the MQTT formatter by adding the
metric
option to theinlfux://
reporter - add some additional metadata like
protocol
to PromQL/MetricsQL labels
Great stuff! This was already requested IIRC.