Pro Tips: Using Prometheus and Grafana for Monitoring Power Usage

Published: 1 Nov 2018 RSS

Erwin de Keijzer Erwin de Keijzer - Snow

Sure, thousands of technologists around the world are using Prometheus and Grafana to monitor their business systems. But how about putting these technologies to work at home?

Erwin de Keijzer, a Linux engineer at the Dutch consulting firm Snow, gave a talk at GrafanaCon EU about how he used Prometheus and Grafana to monitor the power usage… of his washing machine. “This is a talk that’s a bit different scale than we’ve heard so far” at GrafanaCon, he quipped.

Spin Cycle

Erwin had a problem that might sound frustratingly familiar to many of us: The timer on his washing machine wasn’t accurate. “I come back two minutes after it should be done, and it’s 15 minutes left,” he said. “I come back 10 minutes later, and it’s still 10 minutes left…. It’s almost half an hour after it should have been done.”

So what’s an engineer to do? “I thought about putting a camera in there or buying a new washing machine that has an API,” he said. “But I’m also cheap, so I wanted to do it with stuff I had lying around already. So I thought, let’s get some monitoring on my power usage and determine if I can see from the graphs that come out of that if my washing machine is done.”

Erwin, who lives in the Netherlands, connected his Raspberry Pi Zero to his smart energy meter with a USB2 P1 cable, which enabled him to gather all of the data that the smart meter collected onto his Raspberry Pi. He wrote an exporter in Go using the promhttp library to get the data from the P1 port, store it, and expose the metrics to be scraped by Prometheus.

In his presentation, Erwin showed the graphs from his smart meter. “You can see some peaks. I’m using four kilowatts [here]. That’s probably because when [the washing machine] turned on, that uses three kilowatts,” he said. “There’s some more going on, I’m not sure what it is. So I put Prometheus on the other Intel NUC that I had lying around. So you have the gathering, but the visualization of Prometheus is not stored, so here comes Grafana.” Power usage Default Prometheus graph showing the 4Kw peak

Enter Grafana

With Grafana, Erwin made some graphs to show his gas usage versus the temperature. “I was interested if it’s very cold outside, do I use more gas?” he said. (Turns out, there was no correlation.) “I also wanted a method of looking at those graphs I created with Grafana, so in comes Caddy.” Caddy is an open source project that enables a web server with TLS encryption.

So did the graphs show him when his washing machine was done? “The graphs are not linear,” he said, with some disappointment. “There’s not a clear cut-off point of when it was done. So I basically failed at getting notifications when my washing machine was done.”

That said, he did have two interesting graphs about his power usage, and with those graphs, he was able to glean some insights.

Is Your Refrigerator Running?

The first graph showed the current draw and the meter reporting. “With Prometheus it is possible to do a derivative of your graph, so this [graph] is the comparison between what the meter is reporting, and what the current draw is, and as you can see they do align,” he said. “There’s a small difference between them, which also makes sense because the smart meter only reports its values every 20 seconds.”

Current draw vs what the meter reports Current draw vs what the meter reports

The graph, interestingly, showed some peaks at night, every 60-90 minutes. What was drawing power at night? His refrigerator. “At one point I was up at night and I heard it turn on,” Erwin said. “I was like, ‘Oh, let’s check [the graph] on my phone.’”

The second graph of note showed the off-peak and peak measurements. “I found out that I have two meters, and on the weekends it’s all off-peak,” he said. “I also noticed Christmas is off-peak. Apparently January 1 is off-peak. So I now have insights into when I save money and when I don’t save money.”

Peak vs off-peak usage Peak vs off-peak usage

Though he still has to get up and go to the laundry room to check if his washing machine is done, Erwin now has a secure, private web interface for exploring his power usage. If you’re interested in setting up your own power usage monitoring, you can find him on Twitter and Github.

Video: Using Prometheus and Grafana for Monitoring Power Usage

Related Posts

VP, Product at Grafana Labs, Tom Wilkie, discusses the RED Method - his microservices-oriented monitoring philosophy.
Flux, the long-awaited new functional query processing engine for InfluxDB, has finally landed, and you can try it out now with Grafana's new Flux Plugin!
A water and energy innovation company founded in 2005, Natel Energy builds hydropower turbines and designs resilient and distributed hydropower systems. In his talk at GrafanaCon EU, Natel Developer Ryan McKinley gave us a fascinating look at how the company is using Grafana to help run these next-generation power plants.

Related Case Studies

DigitalOcean gains new insight with Grafana visualizations

The company relies on Grafana to be the consolidated data visualization and dashboard solution for sharing data.

"Grafana produces beautiful graphs we can send to our customers, works with our Chef deployment process, and is all hosted in-house."
– David Byrd, Product Manager, DigitalOcean

Hiya migrated to Grafana Cloud to cut costs and gain control over its metrics

To scale Prometheus, says Senior Software Engineer Jake Utley, Grafana Cloud was ‘the most in line with what we wanted to accomplish.’

"We wanted the ability to look at our own information and understand it from top to bottom."
– Dan Sabath, Senior Software Engineer, Hiya

How Cortex helped REWE digital ensure stability while scaling grocery delivery services during the COVID-19 pandemic

Cortex’s horizontal scaling has been crucial; reads and writes increased significantly, and the platform was able to handle the added load.

"We wanted a software-as-a-service approach, with just one team that provides Cortex, which can be used by all the teams within the company."
– Martin Schneppenheim, Cloud Platform Engineer, REWE digital