Can't find output of console.log called from scripted dashboard


#1

Thanks in advance for any help you can provide on this.
This is a showstopper for me – can’t really proceed with scripted dashboard without this.
I’m troubleshooting a larger problem, and can’t make progress on it without console.log.

I’ve added a single logging statement as the 2nd last line of /usr/app/grafana-4.3.2/public/dashboards/scripted.js

console.log('Hello world!');
return dashboard;

…the scripted dashboard renders correctly, but I can’t find Hello world! in any log anywhere.

I have enabled this:
# Log web requests
router_logging = true

…that correctly shows the following output with my modified scripted.js, see below.
But still no “Hello world!”

t=2017-07-19T10:53:13-0500 lvl=info msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=GET path=/dashboard/script/scripted.js status=200 remote_addr=10.132.214.119 time_ms=13 size=11133
t=2017-07-19T10:53:13-0500 lvl=info msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=GET path=/api/tsdb/testdata/random-walk status=200 remote_addr=10.132.214.119 time_ms=14 size=61722

Thanks again.


#2

Still can’t get console.log to write to log file, but I found a away around it.
I captured the error in a try/catch like this:

var error = ‘uninit’;
try {
dbGetTestIdsAndTimes(“jmeter”,“CeB”,“jmeter.a.avg”);
} catch (err) {
console.log("##### Exception: " + err);
error = err;
}

…and then later assigned “error” to the title of the dashboard that was rendered.


#3

javascript console.log logs to browser javascript console (open browser dev tools to access js console)


#4

Torkel, that worked great, thanks. Would be nice to start a wiki/FAQ page or similar for development of scripted dashboards…and this would be helpful for that page. Suggestions on where we could keep that page?
–Erik