将 maxDataPoints 放入 grafana 数据源
Posted
技术标签:
【中文标题】将 maxDataPoints 放入 grafana 数据源【英文标题】:Put maxDataPoints in grafana datasource 【发布时间】: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
【问题讨论】:
【参考方案1】:问:我可以访问plugin.json
的属性值吗?如果是这样,我如何从我的控制器访问 maxDataPoints
属性?
答:您只能访问plugin.json
中的部分属性值。这些值可以在PluginMeta
类中找到,它的一个实例可以在Datasource
类的instanceSettings.meta
变量中找到。 Example
很遗憾,maxDataPoints
属性不是您可以访问的属性之一。
如果您有一个有效的use-case
,您可以尝试提出一个拉取请求,要求 Grafana 团队为您公开它。
这个piece of Grafana server code 决定了所有plugin.json
向客户提供的内容。是的,如果您想公开 maxDataPoint
属性,您必须扩展该代码。
【讨论】:
以上是关于将 maxDataPoints 放入 grafana 数据源的主要内容,如果未能解决你的问题,请参考以下文章
Ubuntu Server 18.04.1 Docker使用