blob: a65a45420cb24652332da805105371bcd11698f9 [file] [log] [blame]
koder aka kdanilovf4b82c22015-04-11 13:35:25 +03001/* global _ */
2
3/*
4 * Complex scripted dashboard
5 * This script generates a dashboard object that Grafana can load. It also takes a number of user
6 * supplied URL parameters (int ARGS variable)
7 *
8 * Return a dashboard object, or a function
9 *
10 * For async scripts, return a function, this function must take a single callback function as argument,
11 * call this callback function with the dashboard object (look at scripted_async.js for an example)
12 */
13
14
15
16// accessable variables in this scope
17var window, document, ARGS, $, jQuery, moment, kbn;
18
19// Setup some variables
20var dashboard;
21
22// All url parameters are available via the ARGS object
23var ARGS;
24
25// Intialize a skeleton with nothing but a rows array and service object
26dashboard = {rows : []};
27
28// Set a title
29dashboard.title = 'Tests dash';
30
31// Set default time
32// time can be overriden in the url using from/to parameteres, but this is
33// handled automatically in grafana core during dashboard initialization
34dashboard.time = {
35 from: "now-5m",
36 to: "now"
37};
38
39dashboard.rows.push({
40 title: 'Chart',
41 height: '300px',
42 panels: [{"span": 12, "title": "writes_completed", "linewidth": 2, "type": "graph", "targets": [{"alias": "192.168.0.104 io sda1", "interval": "", "target": "disk io", "rawQuery": true, "query": "select value from \"writes_completed\" where $timeFilter and host='192.168.0.104' and device='sda1' order asc"}, {"alias": "192.168.0.104 io rbd1", "interval": "", "target": "disk io", "rawQuery": true, "query": "select value from \"writes_completed\" where $timeFilter and host='192.168.0.104' and device='rbd1' order asc"}], "tooltip": {"shared": true}, "fill": 1}, {"span": 12, "title": "sectors_written", "linewidth": 2, "type": "graph", "targets": [{"alias": "192.168.0.104 io sda1", "interval": "", "target": "disk io", "rawQuery": true, "query": "select value from \"sectors_written\" where $timeFilter and host='192.168.0.104' and device='sda1' order asc"}, {"alias": "192.168.0.104 io rbd1", "interval": "", "target": "disk io", "rawQuery": true, "query": "select value from \"sectors_written\" where $timeFilter and host='192.168.0.104' and device='rbd1' order asc"}], "tooltip": {"shared": true}, "fill": 1}]
43});
44
45
46return dashboard;
47