smcquay / jsonds

Grafana JSON Datasource implementation
MIT License
41 stars 16 forks source link

How to build / start? #2

Open MarkoBursic opened 4 years ago

MarkoBursic commented 4 years ago

I have installed golang, but executing jsonds:

xxxxxxx:~/go/src/github.com/smcquay/jsonds$ jsonds jsonds: command not found

Gives this error. So, how should I start your program(s)?

harshathulasi commented 4 years ago

Try ./jsonds in that same directory.

MarkoBursic commented 4 years ago

There is no such file. Somehow it needs to be build by Go, before you can use it. But there is no makefile or any tutorial how to build it.

harshathulasi commented 4 years ago

You are right. I think its in $GOPATH/bin:

~/go$ cd src/
~/go/src$ ls
github.com  golang.org
~/go/src$ cd github.com/
~/go/src/github.com$ ls
labstack  mattn  smcquay  streadway  valyala
~/go/src/github.com$ cd smcquay/
~/go/src/github.com/smcquay$ ls
jsonds
~/go/src/github.com/smcquay$ cd jsonds/
~/go/src/github.com/smcquay/jsonds$ ls
cors.go  json.go  LICENSE  main.go  README.md  server.go
~/go/src/github.com/smcquay/jsonds$ cd ../../../../bin
~/go/bin$ ls
jsonds
~/go/bin$ ./jsonds 
^C
~/go/bin$ 

Try that.

harshathulasi commented 4 years ago

Although on a separate note, building/running from the source code is not working for me either. I'm a golang noob. Any advice on what I am doing wrong?

~/go/src/github.com/smcquay/jsonds$ go run main.go 
# command-line-arguments
./main.go:17:7: undefined: newServer
./main.go:26:23: undefined: cors
./main.go:27:34: undefined: cors
~/go/src/github.com/smcquay/jsonds$ 
MarkoBursic commented 4 years ago

You are correct the jsonds is in the bin folder, still I don't know how it came there. I have the same results as user @ozn0417 . I would like to insert your code in a Go application, it has to send 3 float values to Grafana, single stat panel for monitoring actual values. Your code seems excellent candidate, since it is very small. Unfortunately I am a noob in Go and your code is not documented. Although it is alive on port:8000 and gives OK response on /search. It would be a big help if you could make an application that sends random numbers to grafana to better understand.

harshathulasi commented 4 years ago

I agree as well. Could use better documentation. @MarkoBursic , Im trying to figure out using a json data source as well for grafana. I'll let you know if I find a good alternative. With regards to how the jsonds came in bin dirctory, I think it gets installed when you do the "go get ...". I think golang is much more complicated than I thought it would be. Lot of crazy way to manage packages/dependencies/codestructure.

MarkoBursic commented 4 years ago

@ozn0417 Yes, I have found documentation about go get, it does download and then invoke go install, so that's why binaries were produced. Feel free to post a way on how to make a server for grafana simple json. I already have influxdb as database for log, but it's a pain to show actual data on single stat panel. This is what I am looking for: data from database (trend, table - already done) and UI panel for actual data.

smcquay commented 4 years ago

I have installed golang, but executing jsonds:

The README suggests a different approach. Did you try that?

harshathulasi commented 4 years ago

I see the search working and annotations too but you haven't implemented the /query. But pretty well made and I think can be easily integrated. I'll forked one copy and will update it. @MarkoBursic , I used this to get a better sense on how grafana interacts with the json data source: https://gitlab.com/oz123/grafana-python-datasource Hope it helps.