rtl_433 icon indicating copy to clipboard operation
rtl_433 copied to clipboard

Influxdb configurable prefix

Open jktjkt opened this issue 1 year ago • 1 comments

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:

image

Here's how this PR implements that:

  1. fix -Wstringop-truncation which would silenty truncate URLs longer than 399 characters (because my compiler bugs me about this)
  2. make the MQTT formatter reusable
  3. use the MQTT formatter by adding the metric option to the inlfux:// reporter
  4. add some additional metadata like protocol to PromQL/MetricsQL labels

jktjkt avatar Aug 03 '23 00:08 jktjkt

Great stuff! This was already requested IIRC.

zuckschwerdt avatar Aug 03 '23 08:08 zuckschwerdt