I’ve only recently cracked the ice in developing under grafana, with an experimental fork to enhance the singlestat panel.
I worked through the instructions on ‘Installation/Building Grafana from source’ first in linux and then again in Windows 10 (for anyone new to this, linux is much easier to get working). The only thing I coundn’t get working is the bra run step to automatically rebuild on source changes - no big loss to me, but something someone might want to take a look at.
Where I did get confused though is with the next step to deploy a self-build package. The docs says:
go run build.go build package It runs then seems to error on the grafana-server build
C:\Users\mdmoo\go\src\github.com\mygrafana\grafana>go run build.go build package
GOPATH is C:\Users\mdmoo\go
Version: 4.4.0-pre1, Linux Version: 4.4.0, Package Iteration: 1497395954pre1
rm -r dist
rm -r tmp
rm -r C:\Users\mdmoo\go\pkg\windows_amd64\github.com\grafana
rm -r ./bin/grafana-server.exe
rm -r ./bin/grafana-server.exe.md5
go version
go version go1.8.1 windows/amd64
go build -ldflags -w -X main.version=4.4.0-pre1 -X main.commit=192c447 -X main.buildstamp=1497280620 -o ./bin/grafana-server.exe ./pkg/cmd/grafana-server
rm -r ./bin/grafana-cli.exe
rm -r ./bin/grafana-cli.exe.md5
go version
go version go1.8.1 windows/amd64
go build -ldflags -w -X main.version=4.4.0-pre1 -X main.commit=192c447 -X main.buildstamp=1497280620 -o ./bin/grafana-cli.exe ./pkg/cmd/grafana-cli
# github.com/mygrafana/grafana/pkg/cmd/grafana-cli pkg\cmd\grafana-cli\main.go:47: cannot use commands.Commands (type []“github.com/grafana/grafana/vendor/github.com/codegangsta/cli”.Command) as type []“github.com/mygrafana/grafana/vendor/github.com/codegangsta/cli”.Command in assignment
exit status 2
exit status 1
More importantly though, what is a package and how could I use it to (say) do a test install of my fork? It is not at all obvious what needs to be done to create installation-ready binaries for linux and/or windows installs.
Thanks guys - I figured it out in the end. The REAL problem was that my base folder was called "mygrafana’ not plain old “grafana”.
I don’t know if this is by design, or an oversight, but cloning the git repo into any folder other than one called grafana causes an error when running the go run build.go build package command
after renaming the base folder to grafana, it builds successfully under linux mint
(If anyone is following this, you might need to install the rpmbuild utility too - sudo apt-get install rpm)
Building under Windows is still proving problematic, even after the base folder rename. I’m looking into this and may have an update later. So far, I get this:
C:\Users\mdmoo\go\src\github.com\grafana\grafana>go run build.go build package
Version: 4.4.0-pre1, Linux Version: 4.4.0, Package Iteration: 1497468241pre1
rm -r dist
rm -r tmp
rm -r C:\Users\mdmoo\go\pkg\windows_amd64\github.com\grafana
rm -r ./bin/grafana-server.exe
rm -r ./bin/grafana-server.exe.md5
go version
go version go1.8.1 windows/amd64
go build -ldflags -w -X main.version=4.4.0-pre1 -X main.commit=3b8e2e5 -X main.buildstamp=1497393015 -o ./bin/grafana-server.exe ./pkg/cmd/grafana-server
rm -r ./bin/grafana-cli.exe
rm -r ./bin/grafana-cli.exe.md5
go version
go version go1.8.1 windows/amd64
go build -ldflags -w -X main.version=4.4.0-pre1 -X main.commit=3b8e2e5 -X main.buildstamp=1497393015 -o ./bin/grafana-cli.exe ./pkg/cmd/grafana-cli
./node_modules/.bin/grunt release --pkgVer=4.4.0-1497468241pre1
‘.’ is not recognized as an internal or external command,
operable program or batch file.
exit status 1
exit status 1
I’ve set the PYTHON environment variable to my Python27 directory (another dependency). So far, I can’t see where the “.” command is coming from.
Why didn’t bra work (the command below)? Are you sure your path is set correctly?
go get github.com/Unknwon/bra
bra run
By changing grafana to mygrafana you are breaking the go conventions for remote import paths which means that you will not be able to build Grafana. It’s a design decision made by the Go team that has its advantages and disadvantages.
Not sure what you mean about Python? It’s not a Grafana dependency as far as I know anyway…
It’s been a long, strange trip - but the step
yarn install --pure-lockfile
fails, saying
Error: Python executable "C:\Users\mdmoo\AppData\Local\Programs\Python\Python36-32\python.EXE" is v3.6.1, which is not supported by gyp.
The fix (found on Google) is to define the PYTHON environment variable to point to the Python 2 exe.
But go run build.go build package fails, trying to execute the command “.”
c:\Users\mdmoo\go\src\github.com\grafana\grafana>go run build.go build package
Version: 4.4.0-pre1, Linux Version: 4.4.0, Package Iteration: 1497471716pre1
rm -r dist
rm -r tmp
rm -r C:\Users\mdmoo\go\pkg\windows_amd64\github.com\grafana
rm -r ./bin/grafana-server.exe
rm -r ./bin/grafana-server.exe.md5
go version
go version go1.8.3 windows/amd64
go build -ldflags -w -X main.version=4.4.0-pre1 -X main.commit=3b8e2e5 -X main.buildstamp=1497393015 -o ./bin/grafana-server.exe ./pkg/cmd/grafana-server
rm -r ./bin/grafana-cli.exe
rm -r ./bin/grafana-cli.exe.md5
go version
go version go1.8.3 windows/amd64
go build -ldflags -w -X main.version=4.4.0-pre1 -X main.commit=3b8e2e5 -X main.buildstamp=1497393015 -o ./bin/grafana-cli.exe ./pkg/cmd/grafana-cli
./node_modules/.bin/grunt release --pkgVer=4.4.0-1497471716pre1
‘.’ is not recognized as an internal or external command,
operable program or batch file.
exit status 1
exit status 1
Yes, thought that was what the problem was. Surprised that you got anything to work at all without having $GOPATH/bin in your path.
Oh, had forgotten about node-gyp. When I used node-gyp on Windows I always used it together with Visual Studio rather than Python but it looks like you need both these days: GitHub - nodejs/node-gyp: Node.js native addon build tool
Interesting to know that Grafana has a potential dependency on Python.
OK, after much hair puling etc., I’m finally ready to publish a brand new
panel (michaeldmoore-annunciator-panel) based on SingleStat but with a
number of visual enhancements to work with upper and lower warning and
limit thresholds, suitable for real-time process monitoring etc. of a
simple time series data set.
In future, I’m thinking of adding an optional trend-prediction display so
that users could see when the current rate of change of a monitored value
is expected to exceed one of the limits within some selectable time frame.
I created a pull request on repo.json with (I think) all the required
details. Feel free to critique anything you find problematic - I have a
pretty thick skin
Also, note that a lot of the code for this panel has been lifted more or
less directly from SingleStat. If this is a problem, or if there are any
additional acknowledgements needed etc., please let me know.
Developing this has been a fun/educational experience and I can anticipate
adding a number of plugins for Grafana in the coming months.
jeder@wks: ~/go/src/grafana (oauth) $ time go run build.go build package
Version: 5.0.0-pre1, Linux Version: 5.0.0, Package Iteration: 1513816735pre1
rm -r dist
rm -r tmp
rm -r /home/jeder/go/pkg/linux_amd64/github.com/grafana
rm -r ./bin/grafana-server
rm -r ./bin/grafana-server.md5
go version
go version go1.9.2 linux/amd64
go build -ldflags -w -X main.version=5.0.0-pre1 -X main.commit=43e62b329 -X main.buildstamp=1513816062 -o ./bin/grafana-server ./pkg/cmd/grafana-server
rm -r ./bin/grafana-cli
rm -r ./bin/grafana-cli.md5
go version
go version go1.9.2 linux/amd64
go build -ldflags -w -X main.version=5.0.0-pre1 -X main.commit=43e62b329 -X main.buildstamp=1513816062 -o ./bin/grafana-cli ./pkg/cmd/grafana-cli
grafana/pkg/cmd/grafana-cli
pkg/cmd/grafana-cli/main.go:59:15: cannot use commands.Commands (type “github.com/grafana/grafana/vendor/github.com/codegangsta/cli”.Command) as type “grafana/vendor/github.com/codegangs
ta/cli”.Command in assignment
exit status 2
exit status 1
@jeremyeder saw that Dan Cech figured it out on Slack and that you had the Grafana code outside of your Go workspace (very confusing if you are not used to Go ).
So for anyone else who finds this via Google, it is important to follow this part of the instructions to make sure grafana is installed in the workspace (GOPATH points to the workspace location):