DEV Community

Cover image for I Built a Rube Goldburg Machine to Monitor My Smoker using k8s, Prometheus, and Grafana πŸ–πŸ–πŸ–πŸ–
Austin Vance for Focused

Posted on β€’ Edited on β€’ Originally published at focusedlabs.io

2 1

I Built a Rube Goldburg Machine to Monitor My Smoker using k8s, Prometheus, and Grafana πŸ–πŸ–πŸ–πŸ–

Or: How you can use the power of Kubernetes and a good monitoring stack to do just about everything

I just got a smoker and let's say I've gone ham for it. Well, not ham, but I have had the thing for 6 weeks and have made 5 briskets. Each one is getting a little better and I'll say the experience of smoking meat is pretty fun; there's a ton you have to pay attention to and you want to make small adjustments without letting anything too dramatic happen.

Along with the smoker, I also got an iGrill v2. It's effectively a Bluetooth thermometer that has both meat and ambient temperature probes. iGrill has an app that lets you do some basic stuff but you are tied to the Bluetooth range of the little unit, which is pretty small, maybe like 30 feet on a good day. What this meant was I couldn't even walk around my house and still get the temperatures and alerts from the thermometer.

Our Goal

Create a simple way to monitor the real-time temperatures of the smoker from anywhere.

AE8C4920-7606-44F6-8A2C-6CE6C37DDA25.png

Our tech stack

Our solution

First, we need to connect the iGrill to something other than a phone. I have a handful of Raspberry Pi B+'s laying around that should work perfectly. They have built-in Bluetooth and BTLE.

Some people have already done the heavy lifting when it comes to talking to the iGrill, this repo by bjoernhoefer looks good, so let's start there.

import time

from igrill import IGrillV2Peripheral
from prometheus_client import Gauge, push_to_gateway, CollectorRegistry

registry = CollectorRegistry()
probe_one = Gauge('bbq_probe_one_temp', 'Temp of probe one', registry=registry)
probe_two = Gauge('bbq_probe_two_temp', 'Temp of probe two', registry=registry)
probe_three = Gauge('bbq_probe_three_temp', 'Temp of probe three', registry=registry)
probe_four = Gauge('bbq_probe_four_temp', 'Temp of probe four', registry=registry)

probes = [ probe_one, probe_two, probe_three, probe_four ]
battery = Gauge('bbq_battery', 'Battery of the iGrill', registry=registry)

if __name__ == '__main__':
    periph = IGrillV2Peripheral('XX:XX:XX:XX:XX:XX')
    while True:

        temperature=periph.read_temperature()

        # Probe 1
        if temperature[1] != 63536.0:
            print("bbq/probe1", temperature[1])
            probe_one.set(temperature[1])

        # Probe 2
        if temperature[2] != 63536.0:
            print("bbq/probe2", temperature[2])
            probe_two.set(temperature[2])

        # Probe 3
        if temperature[3] != 63536.0:
            print("bbq/probe3", temperature[3])
            probe_three.set(temperature[3])

        # Probe 4
        if temperature[4] != 63536.0:
            print("bbq/probe4", temperature[4])
            probe_four.set(temperature[4])

        print("bbq/battery", periph.read_battery())
        battery.set(periph.read_battery())
        push_to_gateway('https://grillstats-url', job="igrill", registry=registry )

        time.sleep(5)
Enter fullscreen mode Exit fullscreen mode

We don't need the MQTT server. Instead, we can add Prometheus Gateway to our Kubernetes cluster and push our metrics straight there.

Now let's set up our Prometheus Operator with a sidecar that is ready to receive metrics.

In a values.yaml file we add

  -
    prometheus:
      additionalServiceMonitors:
        -
          name: igrill-monitor
          selector:
            matchLabels:
              app: prometheus-pushgateway
          namespaceSelector:
            matchNames:
              - metrics
          endpoints:
            -
              honorLabels: true
            -
              port: '9091'
            -
              targetPort: '9091'
              interval: 5s
Enter fullscreen mode Exit fullscreen mode

This tells Prometheus that it should scrape new endpoints.

Last, let's set up the Prometheus Gateway to give us a place to push metrics to. We use helm to deploy the Prometheus Gateway.

We can document the whole thing with a helmfile:

  releases:
  - name: metrics
    namespace: metrics
    chart: stable/prometheus-operator
    values:
      - prometheus-node-exporter:
          service:
            port: 30206
            targetPort: 30206
      - prometheus:
          additionalServiceMonitors:
            - name: igrill-monitor
              selector:
                matchLabels:
                  app: prometheus-pushgateway
              namespaceSelector:
                matchNames:
                  - metrics
              endpoints:
                - honorLabels: true
                - port: "9091"
                - targetPort: "9091"
                  interval: 5s
  - name: push-gateway
    namespace: metrics
    chart: stable/prometheus-pushgateway
Enter fullscreen mode Exit fullscreen mode

A simple helmfile sync deploys everything.

Now we can set up the charts in Grafana:

Chart Setup

And of course - a glamor shot of the final product! Over all it took me about 14 hours to smoke and people loved it!
Final Product

Image of Quadratic

The native AI interface for your structured data

Simply type in your prompt and generate insights with the latest LLMs and built-in Python functionality.

Try Quadratic free

Top comments (2)

Collapse
 
rizwan_manzoor_b542b0ac81 profile image
Rizwan Manzoor β€’

Thanks For Sharing This i will use in my bbq.

Collapse
 
austinbv profile image
Austin Vance β€’

Share a picture when you get it set up!

Playwright CLI Flags Tutorial

5 Playwright CLI Flags That Will Transform Your Testing Workflow

  • 0:56 --last-failed
  • 2:34 --only-changed
  • 4:27 --repeat-each
  • 5:15 --forbid-only
  • 5:51 --ui --headed --workers 1

Learn how these powerful command-line options can save you time, strengthen your test suite, and streamline your Playwright testing experience. Click on any timestamp above to jump directly to that section in the tutorial!

Watch Full Video πŸ“ΉοΈ

πŸ‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay