GithubHelp home page GithubHelp logo

mhansen / rtl_433_prometheus Goto Github PK

View Code? Open in Web Editor NEW
19.0 5.0 14.0 5 MB

Prometheus time-series DB exporter for rtl_433 433MHz radio packet decoder

License: MIT License

Dockerfile 8.70% Go 91.30%

rtl_433_prometheus's Introduction

A Prometheus exporter for radio messages received from rtl_433.

Hosted on Docker Hub: https://hub.docker.com/r/markhnsn/rtl_433_prometheus

You can configure locations using the name+channel like this:

$ ./rtl_433_prometheus --channel_matcher=Acurite-Tower,1,Bedroom --channel_matcher=Acurite-Tower,2,Downstairs

And using name+ID like this:

$ ./rtl_433_prometheus --id_matcher=Acurite-Tower,12345,Bedroom --id_matcher=Acurite-Tower,23456,Downstairs

You can also combine --id_matcher with --channel_matcher.

Example end-to-end usage, showing prometheus plaintext format:

$ go build
$ ./rtl_433_prometheus \
   --id_matcher "Acurite-Tower,1234,Study Balcony" \
   --id_matcher "Acurite-Tower,4567,Bedroom Balcony North" \
   --id_matcher "Acurite-Tower,7890,Bedroom Balcony South"


$ curl http://localhost:9550/metrics
...
# HELP rtl_433_battery Battery high (1) or low (0).
# TYPE rtl_433_battery gauge
rtl_433_battery{channel="A",id="1234",location="Study Balcony",model="Acurite tower sensor"} 1
rtl_433_battery{channel="B",id="4567",location="Bedroom Balcony North",model="Acurite tower sensor"} 1
rtl_433_battery{channel="C",id="7890",location="Bedroom Balcony South",model="Acurite tower sensor"} 1
# HELP rtl_433_humidity Relative Humidity (0-1.0)
# TYPE rtl_433_humidity gauge
rtl_433_humidity{channel="A",id="1234",location="Study Balcony",model="Acurite tower sensor"} 0.68
rtl_433_humidity{channel="B",id="4567",location="Bedroom Balcony North",model="Acurite tower sensor"} 0.6
rtl_433_humidity{channel="C",id="7890",location="Bedroom Balcony South",model="Acurite tower sensor"} 0.68
# HELP rtl_433_packets_received Packets (temperature messages) received.
# TYPE rtl_433_packets_received counter
rtl_433_packets_received{channel="A",id="1234",location="Study Balcony",model="Acurite tower sensor"} 65200
rtl_433_packets_received{channel="B",id="4567",location="Bedroom Balcony North",model="Acurite tower sensor"} 73440
rtl_433_packets_received{channel="C",id="7890",location="Bedroom Balcony South",model="Acurite tower sensor"} 70727
# HELP rtl_433_temperature_celsius Temperature in Celsius
# TYPE rtl_433_temperature_celsius gauge
rtl_433_temperature_celsius{channel="A",id="1234",location="Study Balcony",model="Acurite tower sensor"} 24.5
rtl_433_temperature_celsius{channel="B",id="4567",location="Bedroom Balcony North",model="Acurite tower sensor"} 25.6
rtl_433_temperature_celsius{channel="C",id="7890",location="Bedroom Balcony South",model="Acurite tower sensor"} 24.5
# HELP rtl_433_timestamp_seconds Timestamp we received the message (Unix seconds)
# TYPE rtl_433_timestamp_seconds gauge
rtl_433_timestamp_seconds{channel="A",id="1234",location="Study Balcony",model="Acurite tower sensor"} 1.5825398643534584e+09
rtl_433_timestamp_seconds{channel="B",id="4567",location="Bedroom Balcony North",model="Acurite tower sensor"} 1.5825398669721768e+09
rtl_433_timestamp_seconds{channel="C",id="7890",location="Bedroom Balcony South",model="Acurite tower sensor"} 1.5825398706426628e+09

Example docker-compose.yml config:

version: '3.4'
services:
  rtl_433_prometheus:
    image: markhnsn/rtl_433_prometheus
    restart: always
    ports:
    - "9550:9550"
    devices:
    - "/dev/bus/usb"
    command: [
      "--subprocess", "/rtl_433 -F json -R 19 -R 127 -R 40",
      "--channel_matcher", "Nexus Temperature/Humidity,1,Study",
      "--channel_matcher", "Nexus Temperature/Humidity,2,Bedroom",
      "--channel_matcher", "Nexus Temperature/Humidity,3,Balcony",
      "--id_matcher", "Acurite tower sensor,6543,Dining Room",
      "--id_matcher", "Acurite tower sensor,5432,Kitchen",
      "--id_matcher", "Acurite tower sensor,4321,Balcony",
    ]

Example prometheus.yml:

scrape_configs:
  - job_name: 'rtl_433_prometheus'
      static_configs:
            - targets: ['hostname:9550']

rtl_433_prometheus's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar mhansen avatar renovate[bot] avatar zopieux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rtl_433_prometheus's Issues

Other measurements

Hello, I have just setup this exporter and integrated with a simple Grafana dashboard. I like it so far. On the other hand, I'm sometimes getting some data from rain and wind sensors, which would be great to have in my graphs. Is there a chance you could also add these features? Since I'm not familiar with Go, I can't help at all.

Tagging a release

Hello,

I'm in the process of packaging your exporter for NixOS since I find it useful โ€“ thanks for open-sourcing it!

It would be nice if at some point you could introduce a tag, say v0.1 โ€“ maybe once the tests are fixed, see #3. It's easier to reference short tags than ugly git sha1s.

Cheers,

[Feature Request] id and channel matcher (strict) mode

Consider adding a "strict" id and channel matcher mode to restrict to only the specific sensors you wish to monitor.

Use Case:
I've observed Acurite-Tower sensors occasionally changing the channel they use when they broadcast - even though for instance they are set to channel "A" it shows up as "B" or even "C", leading to extra devices showing up in the metrics that match the same ID. This can lead to an occasional "stuck" metric showing up (showing a static temperature/humidity reading) in Prometheus metrics collection until a restart of the rtl_433_prometheus tool.

If a strict mode that uses both the ID and the channel to determine metrics creation were to be implimented, it would eliminate creating metrics for a device that randomly changes the channel in the transmission and creates new, undesirable metrics to be scraped.

Perhaps something like this as a configuration value?
--id_channel_matcher "[device],[id],[channel],[description]"
example:
--id_channel_matcher "Acurite-Tower,1234,A,Study Balcony"

Could not parse JSON, bad ID (expected float or string), got: <nil>

rtl_433_prometheus_1 | 2020/09/28 23:35:13 channelMatchers: Hideki-TS04,3,Shed
rtl_433_prometheus_1 | 2020/09/28 23:35:13 idMatchers:
rtl_433_prometheus_1 | rtl_433 version 18.12-217-gcbbca50 branch master at 201905251412 inputs file rtl_tcp RTL-SDR
rtl_433_prometheus_1 | Trying conf file at "rtl_433.conf"...
rtl_433_prometheus_1 | Trying conf file at "/root/.config/rtl_433/rtl_433.conf"...
rtl_433_prometheus_1 | Trying conf file at "/usr/local/etc/rtl_433/rtl_433.conf"...
rtl_433_prometheus_1 | Trying conf file at "/etc/rtl_433/rtl_433.conf"...
rtl_433_prometheus_1 |
rtl_433_prometheus_1 | Consider using "-M newmodel" to transition to new model keys. This will become the default someday.
rtl_433_prometheus_1 | A table of changes and discussion is at merbanan/rtl_433#986.
rtl_433_prometheus_1 |
rtl_433_prometheus_1 | Registered 100 out of 127 device decoding protocols [ 1-4 8 11-12 15-17 19-21 23 25-26 29-36 38-60 62-63 67-71 73-100 102-103 108-116 119 121 124-127 ]
rtl_433_prometheus_1 | Found Rafael Micro R820T tuner
rtl_433_prometheus_1 | Exact sample rate is: 250000.000414 Hz
rtl_433_prometheus_1 | [R82XX] PLL not locked!
rtl_433_prometheus_1 | Sample rate set to 250000 S/s.
rtl_433_prometheus_1 | Tuner gain set to Auto.
rtl_433_prometheus_1 | Tuned to 433.920MHz.
rtl_433_prometheus_1 | Allocating 15 zero-copy buffers
rtl_433_prometheus_1 | Failed to allocate zero-copy buffer for transfer 0
rtl_433_prometheus_1 | Falling back to buffers in userspace
rtl_433_prometheus_1 | 2020/09/28 23:35:22 Could not parse JSON, bad ID (expected float or string), got:

And the command/docker dies.

the raw rtl_433 is dumping json from the command line.
root@storage:/storage/prometheus/rtl_433_prometheus# rtl_433 -F json
rtl_433 version 20.02-65-g02a009c branch master at 202006142311 inputs file rtl_tcp RTL-SDR
Use -h for usage help and see https://triq.org/ for documentation.
Trying conf file at "rtl_433.conf"...
Trying conf file at "/root/.config/rtl_433/rtl_433.conf"...
Trying conf file at "/usr/local/etc/rtl_433/rtl_433.conf"...
Trying conf file at "/etc/rtl_433/rtl_433.conf"...
Registered 125 out of 153 device decoding protocols [ 1-4 8 11-12 15-17 19-21 23 25-26 29-36 38-60 63 67-71 73-100 102-105 108-116 119 121 124-128 130-149 151-153 ]
Found Rafael Micro R820T tuner
Exact sample rate is: 250000.000414 Hz
[R82XX] PLL not locked!
Sample rate set to 250000 S/s.
Tuner gain set to Auto.
Tuned to 433.920MHz.
{"time" : "2020-09-28 16:34:44", "model" : "Acurite-Tower", "id" : 15406, "channel" : "C", "battery_ok" : 1, "temperature_C" : 22.300, "humidity" : 55, "mic" : "CHECKSUM"}
{"time" : "2020-09-28 16:34:44", "model" : "Acurite-Tower", "id" : 15406, "channel" : "C", "battery_ok" : 1, "temperature_C" : 22.300, "humidity" : 55, "mic" : "CHECKSUM"}
...

Using this in the docker compose testing for one device:
root@storage:/storage/prometheus/rtl_433_prometheus# cat docker-compose.yml
version: '3.4'
services:
rtl_433_prometheus:
image: markhnsn/rtl_433_prometheus
restart: always
ports:
- "9550:9550"
devices:
- "/dev/bus/usb"
command: [
"--subprocess", "/rtl_433 -F json",
"--channel_matcher","Hideki-TS04,3,Test"
]

Set up CI

Would be nice for pushes to automatically push to docker hub

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

dockerfile
Dockerfile
  • golang 1.22
github-actions
.github/workflows/package.yml
  • actions/checkout v4
  • docker/setup-qemu-action v3
  • docker/setup-buildx-action v3
  • docker/login-action v3
  • docker/build-push-action v6
.github/workflows/test.yml
  • actions/checkout v4
  • actions/setup-go v5
gomod
go.mod
  • go 1.20
  • github.com/prometheus/client_golang v1.19.1

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.