Skip to content

Golang app for monitoring MQTT topics with Prometheus and Grafana

License

Notifications You must be signed in to change notification settings

philenius/mqtt-topic-monitoring

Repository files navigation

MQTT Hackathon Topic Monitoring

Disclaimer: this app was created during a MQTT hackathon.

This repository contains a small app written in Golang for monitoring a list of MQTT topics. Basically, this app counts the number of received messages for each given topic in order to calculate the throughput in messages per second. Metrics are exposed through a Prometheus endpoint which can then be visualized through a Grafana dashboard included in this repository.

Grafana Dashboard

Start a local MQTT broker

docker run -it -p 1883:1883 eclipse-mosquitto

Build and run this app

go get
go build

LOGXI=* ./mqtt-monitoring -broker "tcp://127.0.0.1:1883" -topics "test"

If you don't have a MQTT client for publishing messages, you can use MQTT.fx. Publish some messages to the topic test and watch the console output of the Golang app or take a look at the Grafana dashboard.

Start Prometheus & Grafana

  • Start Prometheus:

    docker run \
        -d \
        --rm \
        --network host \
        -p 9090:9090 \
        -v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml \
        --name prometheus \
        prom/prometheus
  • Start Grafana:

    docker run \
      -d \
      --rm \
      -p 3000:3000 \
      --name=grafana \
      grafana/grafana
  • Open Grafana in your browser on localhost:3000 and login with the credentials admin and admin.

  • Create a Prometheus datasource to connect to Prometheus:

    Prometheus Datasource in Grafana

  • Import the Grafana dashboard from the file grafana-dashboard.json into Grafana.

About

Golang app for monitoring MQTT topics with Prometheus and Grafana

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages