Skip to content

Commit fd85ab9

Browse files
authored
Merge pull request #6 from grafana/update-readme
Update SDK and readme
2 parents 30a3dee + c3cd892 commit fd85ab9

File tree

4 files changed

+16
-24
lines changed

4 files changed

+16
-24
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
The MQTT data source plugin allows you to visualize streaming MQTT data from within Grafana.
66

7+
This datasource is under active development, all feedback and help is encouraged!
8+
79
## Requirements
810

911
The MQTT data source has the following requirements:
@@ -15,9 +17,15 @@ The MQTT data source has the following requirements:
1517

1618
- The plugin currently does not support all of the MQTT CONNECT packet options.
1719
- The plugin currently does not support TLS.
20+
- Including multiple topics in a panel is not yet well supported.
21+
- This plugin automatically supports topics publishing json formatted messages.
1822

1923
## Install the plugin
2024

25+
1. Clone the plugin to your Grafana plugins directory.
26+
2. Build the plugin by running `yarn install` and then `yarn build`.
27+
3. Run `mage reloadPlugin` or restart Grafana for the plugin to load.
28+
2129
1. Navigate to [The plugin on Github](https://github.com/MasslessParticle/ciac-datasource).
2230
1. Clone the plugin to your grafana plugins directory
2331
1. Restart Grafana
@@ -58,11 +66,3 @@ The query editor allows you to specify which MQTT topics the panel will subscrib
5866
for more information about valid topic names and filters.
5967

6068
![mqtt dashboard](./test_broker.gif)
61-
62-
63-
## Learn more
64-
65-
- Add [Annotations](https://grafana.com/docs/grafana/latest/dashboards/annotations/).
66-
- Add [Transformations](https://grafana.com/docs/grafana/latest/panels/transformations/).
67-
- Set up alerting; refer to [Alerts overview](https://grafana.com/docs/grafana/latest/alerting/).
68-
- [MQTT v3.1.1 specification](http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ go 1.16
44

55
require (
66
github.com/eclipse/paho.mqtt.golang v1.3.4
7-
github.com/grafana/grafana-plugin-sdk-go v0.97.0
7+
github.com/grafana/grafana-plugin-sdk-go v0.102.0
88
github.com/stretchr/testify v1.7.0
99
)

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z
124124
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
125125
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
126126
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
127-
github.com/grafana/grafana-plugin-sdk-go v0.97.0 h1:V9307Grs2QLvzcldC4hwe3Q1jh6vEMIwONq+l0iy+mk=
128-
github.com/grafana/grafana-plugin-sdk-go v0.97.0/go.mod h1:kgJSx8txPM+3lxLdSp+E9mdnB0xbXkM7VWr7FSHJY0k=
127+
github.com/grafana/grafana-plugin-sdk-go v0.102.0 h1:Pknh7mlOaJvdhPgKHxcimDOSd9h29eSpA34W0/sOF6c=
128+
github.com/grafana/grafana-plugin-sdk-go v0.102.0/go.mod h1:D7x3ah+1d4phNXpbnOaxa/osSaZlwh9/ZUnGGzegRbk=
129129
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
130130
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw=
131131
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y=
@@ -467,8 +467,8 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
467467
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
468468
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
469469
google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
470-
google.golang.org/grpc v1.37.0 h1:uSZWeQJX5j11bIQ4AJoj+McDBo29cY1MCoC1wO3ts+c=
471-
google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
470+
google.golang.org/grpc v1.37.1 h1:ARnQJNWxGyYJpdf/JXscNlQr/uv607ZPU9Z7ogHi+iI=
471+
google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
472472
google.golang.org/grpc/cmd/protoc-gen-go-grpc v0.0.0-20200910201057-6591123024b3/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
473473
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
474474
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=

pkg/plugin/datasource.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (ds *MQTTDatasource) SubscribeStream(ctx context.Context, req *backend.Subs
112112
}, nil
113113
}
114114

115-
func (ds *MQTTDatasource) RunStream(ctx context.Context, req *backend.RunStreamRequest, sender backend.StreamPacketSender) error {
115+
func (ds *MQTTDatasource) RunStream(ctx context.Context, req *backend.RunStreamRequest, sender *backend.StreamSender) error {
116116
defer ds.Client.Unsubscribe(req.Path)
117117

118118
for {
@@ -175,7 +175,7 @@ func (m *MQTTDatasource) Query(query backend.DataQuery) backend.DataResponse {
175175
return response
176176
}
177177

178-
func (m *MQTTDatasource) SendMessage(msg mqtt.StreamMessage, req *backend.RunStreamRequest, sender backend.StreamPacketSender) error {
178+
func (m *MQTTDatasource) SendMessage(msg mqtt.StreamMessage, req *backend.RunStreamRequest, sender *backend.StreamSender) error {
179179
if !m.Client.IsSubscribed(req.Path) {
180180
return nil
181181
}
@@ -186,15 +186,7 @@ func (m *MQTTDatasource) SendMessage(msg mqtt.StreamMessage, req *backend.RunStr
186186
}
187187

188188
frame := ToFrame(msg.Topic, []mqtt.Message{message})
189-
bytes, err := data.FrameToJSON(frame, true, true) // send schema every frame - for now!
190-
if err != nil {
191-
return err
192-
}
193-
194-
packet := &backend.StreamPacket{
195-
Data: bytes,
196-
}
197189

198190
log.DefaultLogger.Debug(fmt.Sprintf("Sending message to client for topic %s", msg.Topic))
199-
return sender.Send(packet)
191+
return sender.SendFrame(frame, data.IncludeAll)
200192
}

0 commit comments

Comments
 (0)