How to use SimpleJson plugin?


#1

I feel like an absolute moron here.

I have added the SimpleJson plugin and provided a datasource which was tested successfully.

The datasource I used was https://api.mybitx.com/api/1/ticker?pair=XBTZAR .

I cannot for the life of me figure out how to use the data from the JSON output. Is there something I am missing here? Does the JSON output have to be in a specific format?

Any assistance would be appreciated.


#2

Do you mean simple-json-datasource? https://github.com/grafana/simple-json-datasource

Read the plugin README for the data format it expects, and the the example backend implementation.


#3

Thank you. So I found this question asked by scavern. I am very new to Grafana, so please forgive my ignorance. My goal is also to develop something like simple-json-datasource plugin. Finally, it will be our own homegrown backend-webserver communicating with Grafana (via http/https requests). I understand that we will have to implement our_url/ , our_ur/search, our_ur/query and our_ur/annotations. But before doing that I would like to see all the above in action to investigate what the example-source sends. Is there some publicly available simple-json-datasource on the internet?

This is what I did so far:

  1. I installed grafana on windows mashine in directory c:\grafana-4.2.0 .
  2. I changed in c:\grafana-4.2.0\conf\custom.ini : http_port = 8080
  3. I copied directory simple-json-datasource-master (from GitHub) into C:\grafana-4.2.0\data\plugins
  4. I start the Grafana server C:\grafana-4.2.0\bin>grafana-server.exe
  5. I login as admin/admin and trying to add datasource. I am happy to see that one of the choices is SimpleJson, which means that Grafana successfully found the directory C:\grafana-4.2.0\data\plugins\simple-json-datasource-master.
  6. The next question below Grafana asks me is “http settings” and “http auth”. I understand that “access” should be “direct”, but I do not know what to answer in “Url” and “Http Auth” to view the example. Can you give me publicly available URL example on the internet>

Thank you very much
cloudviewnms


#4

In the README for https://github.com/grafana/simple-json-datasource there is links to example implementation and details for what the returned json should look like.

The next question below Grafana asks me is “http settings” and “http auth”. I understand that “access” should be “direct”, but I do not know what to answer in “Url” and “Http Auth” to view the example. Can you give me publicly available URL example on the internet

The URL is the address to your simple-json data source http server. If you specify direct access make sure your data source http server supports CORS (need to return the correct CORS headers to be usable from another domain). If not specify proxy.


#5

Thank you.

>In the README there is a link to example implementation

Actually I saw the link in the README you mentioned. But it is not a link to a “live” implementation. It is a link to a GitHub “implementation code” using node.js . I do not not have node.js experience, but probably will have to get it…, thank you, So I take it that there is no “live implementation” available which would allow me to see the example right away…

>make sure your data source http server supports CORS (need to return the correct CORS headers…)

Thank you for pointing my attention to this. I will add the CORS headers to our server responses…


#6

Please forgive me for bugging you with this again. I installed node.js, started the example from https://github.com/bergquist/fake-simple-json-datasource, successfully added a datasource, added a dashboard with two rows : graph and table. Both “graph” and “table” show “no data points” no matter which time range I select (including last 5 years) How can I see something in the graph? Thank you


#7

I am new to Grafana as well, and unfortunately I am not a dev either, so this is a bit challenging for me.

I had a read through the simplejson docs but I am still not certain how to proceed.

I am using the hosted Grafana so I am not sure how to read any error messages etc. or see how the plugin is parsing the JSON output.

Below is an example of the JSON ouput. Is the format correct?

{“timestamp”:1490686556996,“bid”:“14262.00”,“ask”:“14265.00”,“last_trade”:“14300.00”,“rolling_24_hour_volume”:“377.851419”,“pair”:“XBTZAR”}


#8

{ “timestamp”:1490686556996,“bid”:“14262.00”,“ask”:“14265.00”,“last_trade”:“14300.00”,“rolling_24_hour_volume”:“377.851419”,“pair”:“XBTZAR”}

Does not look like anything in the example in the README I told you to look at :slight_smile:
https://github.com/grafana/simple-json-datasource, See example response!

and unfortunately I am not a dev either

I am sorry you need to be a dev to do this.


#9

Hi, I’m on the exact step as you are. Just getting to installing node.js. Is there any examples that you found online that helps? Anything guidance would be helpful. Thanks.


#10

Hi jjsung,
As you see above nobody answered me back in March. I finally succeeded to see the data but sometimes it worked and sometimes did not. The GUI, though looked beautiful, was not that simple even for experienced user… So for now, I stopped with Grafana…
cloudviewnms


#11

Hi I am running java program in a server which response with json format , I am able to see the data in browser .
but when I give same url to simple json plugin …
it showing error " No data points from data query " .
can I know what might be problem .


#12

The json needs to be in the specified format detailed in the simple json readme


#13

For everyone struggling with SimpleJson plugin -

  1. If you looks at the code of the index.js
    else {
    var k = _.filter(timeserie, function(t) {
    return t.target === target.target;
    });
    So k will be initialized only if the each element of the passed input has a parameter target of targets
    …targets: [{“target”: “upper_75” , “type”: “timeserie”}]

  2. To plot the value in the Graphana dashboard you need to pass on the input - “metric” from each panel. Click the panel title -> Edit and then select metric type and value
    Save it and you will have the data plotted.

I am also planning to build something cool with this plugin and it took me a while to figure this out. I guess I will open a pull request on the SimpleJson README

Thanks,
Vineet


#15

after going through the exchanges, pl correct me …all the changes are to be done to the server side index.js from where requested json is generating.