Unable to get response from json request

Using json request post successful test of simplejson datasource ,conection is direct.
but when query json request,the url tag is showing /query,.
This additional query apped to url does not let this url move, i mean it does not show anything.

I am not sure of the issue here why query is getting appended to url.
any resolution out htere pl suggest.

Hi,

Don’t really understand what you mean. Could you please include some more information like query inspector result and/or chrome dev tools failing requests details. Screenshots which highlights the problem are in general good.

Thanks

Marcus

query inspector output:
{
“data”: “”,
“status”: 200,
“statusText”: “OK”,
“xhrStatus”: “complete”,
“request”: {
“method”: “POST”,
“url”: “http://23.251.130.215/AEL/api/api_adani_v6.php?type_id=71&access_key=Gp4xFrQqEvUu2N1/query”,
“data”: {
“timezone”: “browser”,
“panelId”: 1,
“range”: {
“from”: “2018-02-19T18:43:46.767Z”,
“to”: “2018-02-21T18:43:46.768Z”,
“raw”: {
“from”: “now-2d”,
“to”: “now”
}
},
“rangeRaw”: {
“from”: “now-2d”,
“to”: “now”
},
“interval”: “2m”,
“intervalMs”: 120000,
“targets”: [
{
“target”: “myjason”,
“refId”: “A”,
“hide”: false,
“type”: “timeserie”
}
],
“format”: “json”,
“maxDataPoints”: 1920,
“scopedVars”: {
"__interval": {
“text”: “2m”,
“value”: “2m”
},
"__interval_ms": {
“text”: 120000,
“value”: 120000
}
}
}
}
}

Hi,

Could you please include a screenshot of simplejson data source configuration?

Marcus

Am using direct method and basic authentication which is successful .It passes even for proxy.As you can see from status tag of query inspector it’s ok.
find attached screenshot.


Thanks
Sunita

Tap to get Yahoo Mail

Hi,

Now I understand what your problem is. Reading the readme of Simple JSON Datasource plugin it says the following:

Your backend needs to implement 4 urls:

  • / should return 200 ok. Used for “Test connection” on the datasource config page.
  • /search used by the find metric options on the query tab in panels.
  • /query should return metrics based on input.
  • /annotations should return annotations.

This means that when you configure your simple json data source you should insert a base url. When the data source are then querying for data it will append /search, /query or /annotations to the url automatically.

Marcus

Could you pl elaborate on “Your backend needs to implement 4 urls”.Is it automatically taken care by the grafana or do I have to implement these.
Appreciate if there is some some demo sort is there.
grafana do append /query /search to base url but because of these appends base url is not parsed and response is not there.
How can I get the data be shown when type is timseries OR table.

Thanks

sunita

Hi,

You have to implement those.

Please have a look at some example implementations:

Marcus

Marcus,

I tried implementing fake-simple-json-datasource(node) to see who does it work on my windows10 before going to implement on linux .I am struct at script: start tag.

Read the on possible issue that could be there but it says there is issue with the fake…

find below info from log for investigation.
0 info it worked if it ends with ok
1 verbose cli [ ‘C:\Program Files\nodejs\node.exe’,
1 verbose cli ‘C:\Users\Sanchit 12145\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js’,
1 verbose cli ‘run’,
1 verbose cli ‘start’ ]
2 info using npm@5.6.0
3 info using node@v6.10.2
4 verbose config Skipping project config: C:\Users\Sanchit 12145/.npmrc. (matches userconfig)
5 verbose run-script [ ‘prestart’, ‘start’, ‘poststart’ ]
6 info lifecycle fake-simple-json-datasource@1.0.0~prestart: fake-simple-json-datasource@1.0.0
7 info lifecycle fake-simple-json-datasource@1.0.0~start: fake-simple-json-datasource@1.0.0
8 verbose lifecycle fake-simple-json-datasource@1.0.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle fake-simple-json-datasource@1.0.0~start: PATH: C:\Users\Sanchit 12145\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Sanchit 12145\node_modules.bin;C:\Program Files (x86)\Lenovo\FusionEngine;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Intel\Intel® Management Engine Components\DAL;C:\Program Files\Intel\Intel® Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel® Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel® Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files (x86)\Common Files\lenovo\easyplussdk\bin;C:\Program Files (x86)\PuTTY;C:\Program Files (x86)\Skype\Phone;C:\Program Files\nodejs;“C:\Users\Sanchit 12145\AppData\Local\Microsoft\WindowsApps;c:\Python27”;“C:\Users\Sanchit 12145\AppData\Roaming\npm;C:\Program Files\nodejs”;
10 verbose lifecycle fake-simple-json-datasource@1.0.0~start: CWD: C:\Users\Sanchit 12145
11 silly lifecycle fake-simple-json-datasource@1.0.0~start: Args: [ ‘/d /s /c’, ‘nodemon server.js’ ]
12 silly lifecycle fake-simple-json-datasource@1.0.0~start: Returned: code: 3221226356 signal: null
13 info lifecycle fake-simple-json-datasource@1.0.0~start: Failed to exec start script
14 verbose stack Error: fake-simple-json-datasource@1.0.0 start: nodemon server.js
14 verbose stack Exit status 3221226356
14 verbose stack at EventEmitter. (C:\Users\Sanchit 12145\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess. (C:\Users\Sanchit 12145\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:886:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid fake-simple-json-datasource@1.0.0
16 verbose cwd C:\Users\Sanchit 12145
17 verbose Windows_NT 10.0.16299
18 verbose argv “C:\Program Files\nodejs\node.exe” “C:\Users\Sanchit 12145\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js” “run” "start"
19 verbose node v6.10.2
20 verbose npm v5.6.0
21 error code ELIFECYCLE
22 error errno 3221226356
23 error fake-simple-json-datasource@1.0.0 start: nodemon server.js
23 error Exit status 3221226356
24 error Failed at the fake-simple-json-datasource@1.0.0 start script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 3221226356, true ]

Hi,

Just tested it on Ubuntu and it works as expected. Did you installed and run like this:

npm install
node index.js

Marcus

I diagnose it to some modules not there as mentioned in package.json.

I am doing it.

In between ,could I request you to share the url th as t is passed to gharana data source.

I ma quite new to express.

Thanks

Sunita

Tap to get Yahoo Mail

mefraimsson
Leader

    February 23

Hi,

Just tested it on Ubuntu and it works as expected. Did you installed and run like this:

> npm install
> node index.js

Hi,

I just wrote a comprehensive answer in another topic regarding how to use/implement the Simple JSON Datasource plugin. Please see Grafana simplejson dashboard

Marcus

Thanks Marcus.

Its working at my end.

Thanks

Sunita

Tap to get Yahoo Mail

1 Like