mqtt-topic-monitoring

command module
v0.0.0-...-042cacc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

README

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.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL