grafana / mqtt-datasource

MQTT Datasource for Grafana allows streaming data from any MQTT broker running either locally or remotely.
Apache License 2.0
171 stars 51 forks source link

not working withing docker images #10

Closed JFP-SG closed 3 years ago

JFP-SG commented 3 years ago

Hello,

i'm trying to get this plugin work with Grafana 8 in docker. I'm using the official Grafana Image Version 8.0.4 (Alpine and Ubuntu).

After installing yarn i can install and build the plugin as described. It fails with error " /bin/sh: mage: not found error Command failed with exit code 127. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. "

But after a restart of Grafana, the plugin is there (and has to be allowed by env var, because it's not signed). I can configure this, but while saving there is the error: plugin unavailable. In Log i get: t=2021-07-07T10:25:54+0000 lvl=eror msg="Plugin unavailable" logger=context userId=1 orgId=1 uname=admin error="plugin unavailable" remote_addr=XXX

So after testing Alpine Version, i downloaded the ubuntu one, but same error.

mage is not installed, but there is no package to install. So i tried to install golang and downloaded mage, but installation throws errors: " root@grafana:~/mage# go run bootstrap.go Running target: Install exec: go env GOBIN exec: go env GOPATH Error: failed to create "/root/go/bin": mkdir /root/go/bin: no such file or directory exit status 1 "

So is there a way to get this run in docker environment with the official images? Or can you bring this as a grafana plugin?

netwpl commented 3 years ago

same problem here :-/

HimbeersaftLP commented 3 years ago
export GOROOT=/usr/lib/go
export GOPATH=/go
export PATH=/go/bin:$PATH
go run bootstrap.go

that worked for me

(Credits: https://stackoverflow.com/a/53405005/)

JFP-SG commented 3 years ago

Thanks for your hint here. I've got mage running now, For yarn install, there are only warnings and infos: bash-5.1# yarn install yarn install v1.22.10 [1/5] Validating package.json... [2/5] Resolving packages... [3/5] Fetching packages... warning Pattern ["@grafana/ui@next"] is trying to unpack in the same destination "/usr/local/share/.cache/yarn/v6/npm-@grafana-ui-8.0.0-beta.3-2b293c3824b22fbca3a1d64d74893f1f27f75eb8-integrity/node_modules/@grafana/ui" as pattern ["@grafana/ui@8.0.0-beta.3","@grafana/ui@8.0.0-beta.3"]. This could result in non-deterministic behavior, skipping. warning Pattern ["@types/lodash@latest"] is trying to unpack in the same destination "/usr/local/share/.cache/yarn/v6/npm-@types-lodash-4.14.170-0d67711d4bf7f4ca5147e9091b847479b87925d6-integrity/node_modules/@types/lodash" as pattern ["@types/lodash@^4.14.146"]. This could result in non-deterministic behavior, skipping. info fsevents@1.2.13: The platform "linux" is incompatible with this module. info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation. info fsevents@2.3.2: The platform "linux" is incompatible with this module. info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation. [4/5] Linking dependencies... warning "@grafana/ui > @visx/gradient@1.0.0" has incorrect peer dependency "react@^15.0.0-0 || ^16.0.0-0". warning "@grafana/ui > @visx/shape@1.4.0" has incorrect peer dependency "react@^16.3.0-0". warning "@grafana/ui > @visx/tooltip@1.7.2" has incorrect peer dependency "react@^16.8.0-0". warning "@grafana/ui > @visx/tooltip@1.7.2" has incorrect peer dependency "react-dom@^16.8.0-0". warning "@grafana/ui > rc-cascader@1.0.1" has incorrect peer dependency "react@^15.0.0 || ^16.0.0". warning "@grafana/ui > rc-cascader@1.0.1" has incorrect peer dependency "react-dom@^15.0.0 || ^16.0.0". warning "@grafana/ui > react-beautiful-dnd@13.0.0" has incorrect peer dependency "react@^16.8.5". warning "@grafana/ui > react-beautiful-dnd@13.0.0" has incorrect peer dependency "react-dom@^16.8.5". warning "@grafana/ui > react-custom-scrollbars@4.2.1" has incorrect peer dependency "react@^0.14.0 || ^15.0.0 || ^16.0.0". warning "@grafana/ui > react-custom-scrollbars@4.2.1" has incorrect peer dependency "react-dom@^0.14.0 || ^15.0.0 || ^16.0.0". warning "@grafana/ui > react-highlight-words@0.16.0" has incorrect peer dependency "react@^0.14.0 || ^15.0.0 || ^16.0.0-0". warning "@grafana/ui > react-storybook-addon-props-combinations@1.1.0" has incorrect peer dependency "react@^15.x || ^16.x". warning "@grafana/ui > react-table@7.0.0" has incorrect peer dependency "react@^16.8.3". warning "@grafana/runtime > @grafana/ui > @emotion/css > @emotion/babel-plugin@11.3.0" has unmet peer dependency "@babel/core@^7.0.0". warning "@grafana/runtime > @grafana/ui > @grafana/slate-react > slate-react-placeholder@0.2.9" has unmet peer dependency "slate-react@>=0.22.0". warning "@grafana/runtime > @grafana/ui > @visx/shape > @visx/group@1.0.0" has incorrect peer dependency "react@^15.0.0-0 || ^16.0.0-0". warning "@grafana/runtime > @grafana/ui > @visx/tooltip > @visx/bounds@1.7.0" has incorrect peer dependency "react@^15.0.0-0 || ^16.0.0-0". warning "@grafana/runtime > @grafana/ui > @visx/tooltip > @visx/bounds@1.7.0" has incorrect peer dependency "react-dom@^15.0.0-0 || ^16.0.0-0". warning "@grafana/runtime > @grafana/ui > @emotion/css > @emotion/babel-plugin > @babel/plugin-syntax-jsx@7.12.13" has unmet peer dependency "@babel/core@^7.0.0-0". warning "@grafana/runtime > @grafana/ui > rc-cascader > rc-trigger > rc-motion@1.1.2" has incorrect peer dependency "react@^16.0.0". warning "@grafana/runtime > @grafana/ui > rc-cascader > rc-trigger > rc-motion@1.1.2" has incorrect peer dependency "react-dom@^16.0.0". [5/5] Building fresh packages... Done in 21.82s. So seems to te fine for now...

but after "yarn build" i got: bash-5.1# yarn build yarn run v1.22.10 $ rm -rf dist && grafana-toolkit plugin:build && mage build:backend Using Node.js v14.17.3 Using @grafana/toolkit v8.0.0-beta.3 ✔ Preparing ✔ Linting ts-jest[config] (WARN) The optiontsConfigis deprecated and will be removed in ts-jest 27, usetsconfig` instead PASS src/handleEvent.test.ts

Test Suites: 1 passed, 1 total Tests: 2 passed, 2 total Snapshots: 2 passed, 2 total Time: 2.899 s Ran all test suites with tests matching "". ✔ Running tests ⠙ Compiling... Starting type checking service... Using 1 worker with 2048MB memory limit ⠏ Compiling... Hash: 6b5a018b08c2ac55e195 Version: webpack 4.41.5 Time: 11094ms Built at: 07/28/2021 1:35:05 PM Asset Size Chunks Chunk Names CHANGELOG.md 53 bytes [emitted] LICENSE 11.1 KiB [emitted] README.md 2.64 KiB [emitted] img/mqtt.svg 1.31 KiB [emitted] module.js 3.8 KiB 0 [emitted] module module.js.LICENSE.txt 808 bytes [emitted] module.js.map 24 KiB 0 [emitted] [dev] module plugin.json 1000 bytes [emitted] Entrypoint module = module.js module.js.map [0] external "react" 42 bytes {0} [built] [1] external "@grafana/ui" 42 bytes {0} [built] [2] external "lodash" 42 bytes {0} [built] [3] external "@grafana/data" 42 bytes {0} [built] [4] external "@grafana/runtime" 42 bytes {0} [built] [5] ./module.ts + 5 modules 14.5 KiB {0} [built] | ./module.ts 296 bytes [built] | ./datasource.ts 352 bytes [built] | ./ConfigEditor.tsx 2.78 KiB [built] | ./QueryEditor.tsx 658 bytes [built] | ../node_modules/tslib/tslib.es6.js 10 KiB [built] | ./handleEvent.ts 395 bytes [built]

✔ Compiling... No .go files marked with the mage build tag in this directory. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. `

JFP-SG commented 3 years ago

Ok, seems to be some kind of error in between, so I recommend to redownload/pull the plugin again. Now it was build without error. I will test this and will give feedback with a quick guide.

HimbeersaftLP commented 3 years ago

btw I made this Dockerfile that automatically makes an image with this datasource. Also comes with a docker-compose for running grafana and mosquitto. https://gist.github.com/HimbeersaftLP/82b2a1be7708ddcf71746cd86f2c5de0

JFP-SG commented 3 years ago

That sounds great, i will try this tomorrow! Thank you in advance!

JFP-SG commented 3 years ago

@HimbeersaftLP Thank you for your work. Using the helper Go Container helps a lot. Now the datasource is available and can be used.

As i was trying to get running with newest version 8.0.6, the streaming was not usable, because of new "Live" Settings. So for them, who are experience the same: You have to set it like described here: https://grafana.com/docs/grafana/latest/administration/configuration/#live

sommbeer commented 3 years ago

Thanks, I had the same problem but it worked for me with the files from @HimbeersaftLP But now I am also facing the issue that stream is not refreshing live. Exactly the same problem as described in #20.

@JFP-SG Can you please explain more detailed which settings you changed in the configuration?

sommbeer commented 3 years ago

I have just figured it out myself. It had nothing to do with this plugin, also the Grafana example Live stream was not refreshing. I am using Grafana v8.1.2 and here I had to change the allowed HTTP origins in configuration, as described here: https://github.com/grafana/grafana/issues/36929