【问题标题】:how to get scripted dashboard with graphite as data source?如何获取以石墨为数据源的脚本仪表板?
【发布时间】:2017-06-03 00:59:30
【问题描述】:

如何从石墨数据源获取指标? 我有这个脚本,但它从假数据源生成随机指标。

图片:

我可以在这个脚本中设置石墨数据源的地方

'use strict';
var window, document, ARGS, $, jQuery, moment, kbn;
var dashboard;
var ARGS;
dashboard = {
  rows : [],
  schemaVersion: 13,
};
dashboard.title = 'Scripted and templated dash';
dashboard.time = {
  from: "now-6h",
  to: "now"
};
var rows = 1;
var seriesName = 'argName';
if(!_.isUndefined(ARGS.name)) {
  seriesName = ARGS.name;
}
  dashboard.rows.push({
    title: 'Chart',
    height: '300px',
    panels: [
      {
        title: 'Events',
        type: 'graphite',
        span: 12,
        fill: 1,
        linewidth: 2,
        targets: [
          {
            'target': 'stats.gauges.WidgetOccurrences.places.300'
          }
        ],
      }
    ]
  });
return dashboard;

【问题讨论】:

    标签: data-visualization graphite grafana


    【解决方案1】:

    尝试使用数据源值。

       // Intialize a skeleton with nothing but a rows array and service object
       dashboard = {
           __inputs: [{
               'name': "DS",
               'label': "datasource_label",
               'description': "",
               'type': "datasource",
               'pluginId': "datasource_plugin_id",
               'pluginName': "datasource_plugin_name"
           }],
           __requires: [{
                   'type': 'panel',
                   'id': 'graph',
                   'name': 'Graph',
                   'version': ''
               },
               {
                   'type': 'datasource',
                   'id': 'datasource_plugin_id',
                   'name': 'datasource_plugin_name',
                   'version': '1.0.0'
               }
           ],
           editable: true,
           rows: [],
       };
    
       dashboard.title = 'Scripted';
       dashboard.time = {
           from: 'now-36h',
           to: 'now'
       };
    
       dashboard.rows.push({
           title: 'Chart',
           height: '300px',
           panels: [{
               title: 'Variable Importance',
               type: 'graph',
               span: 12,
               fill: 1,
               linewidth: 2,
               datasource: 'datasource_label',
               targets: [{
                   "target": "target"
               }],
               seriesOverrides: [],
               tooltip: {
                   shared: true,
                   sort: 0,
                   value_type: 'individual'
               },
               xaxis: {
                   "buckets": null,
                   "mode": "time",
                   "name": null,
                   "show": true,
                   "values": []
               },
               yaxes: [{
                       "format": "short",
                       "label": null,
                       "logBase": 1,
                       "max": null,
                       "min": null,
                       "show": true
                   },
                   {
                       "format": "short",
                       "label": null,
                       "logBase": 1,
                       "max": null,
                       "min": null,
                       "show": true
                   }
               ]
           }]
       });
       return dashboard;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-27
      • 1970-01-01
      • 1970-01-01
      • 2019-07-13
      相关资源
      最近更新 更多