mqtt2graphite fork

Jan-Piet Mens b273c32863 log illegal payloads 12 سال پیش
README.md 704b5dd6d7 fix 12 سال پیش
jmbp-532.png d5b345a3ae Add obligatory screenshot 12 سال پیش
map 58bc8585f6 Initial import 12 سال پیش
mqtt2graphite.py b273c32863 log illegal payloads 12 سال پیش

README.md

mqtt2graphite

This program subscribes to any number of MQTT topics, extracts a value from the messages' payload and sends that off to Graphite via Carbon over a UDP socket.

Values in the payload can be simple numbers (92, 12.7) or JSON strings. In the latter case, all JSON names/keys are extracted and if their values are numeric, these are then sent off to Carbon (see example below)

Requirements

  • mosquitto.py
  • A running Carbon/Graphite server with UDP-enabled reception
  • Access to an MQTT broker (I use Mosquitto)

Running

  • Set the environment variable MQTT_HOST to the name/IP of your MQTT broker. (localhost is default.)
  • Edit the map file
  • Run ./mqtt2graphite.py

Handling JSON payloads

mosquitto_pub  -t test/jp/j2 -m '{ "size":69,"temp": 89.3, "gas": " 88", "name": "JP Mens" }'

produces the following Carbon keys

test.jp.j2.gas 88.000000 1363169282
test.jp.j2.temp 89.300000 1363169282
test.jp.j2.size 69.000000 1363169282

Todo

A lot.

  • I'm not experienced enough with high volume of messages, so this should maybe transmit to Carbon via StatsD?