I’m playing a lot with Telegraf in recent time in order to get a handle on monitoring an Exadata or the Oracle DB with it. As I don’t have an Exadata at home my source of data for my first steps with Telegraf were my IoT devices at home.

I have Youless energy monitoring devices in my home to log the energy consumption of my home. You will find some information about them at this site(sorry, it’s in Dutch). They can count LED blinks (which works really well) and they can count the passing of the red line on Ferraris wheel based power meters (which works well when it works but doesn’t work sometimes at all. I have to four meters in my house, three of them are Ferraris based, two can be read, one not … and they look absolutely identical).

To integrate them into Telegraf is really straightforward. The nice thing about the Youless devices is that they deliver the data directly as JSON output by sending a HTTP request to them like http://aaa.bbb.xxx.yyy/a?f=j

{"cnt":" 7515,292","pwr":331,"lvl":0,"dev":"","det":"","con":"","sts":"","raw":0}

What i really hate about them, is the point that they deliver the count as a string with a leading whitespace. So i had to convert the string into a float.

So i just put the following file as youless.conf into /etc/telegraf/telegraf.d in order to read the data into my InfluxDB.

  urls = [
  data_format = "json"
  interval = "60s"
  json_string_fields = ["cnt"]
   sourcedevice = "youless"

    sourcedevice = ["youless"]
    key = "cnt"
    pattern = "^\\s*([0-9]*),([0-9]*)$"
    replacement = "${1}.${2}"
    result_key = "cnt_kwh"
    drop_original = true

    sourcedevice = ["youless"]
    float = ["cnt_kwh"]

This currently works reasonably well.

Written by

Joerg Moellenkamp

Grey-haired, sometimes grey-bearded Windows dismissing Unix guy.