【问题标题】:Put maxDataPoints in grafana datasource将 maxDataPoints 放入 grafana 数据源
【发布时间】:2019-06-10 14:12:07
【问题描述】:

我正在使用 grafana 5.1.4。我构建了一个自定义数据源。但是属性 maxDataPoints no 显示在数据源配置中。

这是我的文件结构:

我在 query.options.html 中的代码:

<section class="grafana-metric-options">
<div class="gf-form">
</div>
<div class="gf-form-inline">
    <div class="gf-form max-width-15">
        <span class="gf-form-label">Max data points</span>
        <input type="text"
               class="gf-form-input"
               ng-model="ctrl.panelCtrl.panel.maxDataPoints"
               bs-tooltip="'Override max data points, automatically set to graph width in pixels.'"
               data-placement="right"
               ng-model-onblur ng-change="ctrl.panelCtrl.refresh()"
               spellcheck='false'
               placeholder="auto">
        </input>
    </div>
</div>

在我的 pluging.json 中:

"queryOptions": {
   "maxDataPoints": true
}

【问题讨论】:

    标签: javascript dashboard grafana


    【解决方案1】:

    问:我可以访问plugin.json 的属性值吗?如果是这样,我如何从我的控制器访问 maxDataPoints 属性?

    答:您只能访问plugin.json 中的部分属性值。这些值可以在PluginMeta 类中找到,它的一个实例可以在Datasource 类的instanceSettings.meta 变量中找到。 Example

    很遗憾,maxDataPoints 属性不是您可以访问的属性之一。

    如果您有一个有效的use-case,您可以尝试提出一个拉取请求,要求 Grafana 团队为您公开它。

    这个piece of Grafana server code 决定了所有plugin.json 向客户提供的内容。是的,如果您想公开 maxDataPoint 属性,您必须扩展该代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-08
      • 1970-01-01
      • 2018-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-20
      相关资源
      最近更新 更多