maikelm
maikelm

Reputation: 403

Put maxDataPoints in grafana datasource

I am using grafana 5.1.4. I build a custom datasource. But the property maxDataPoints no are show in datasource config.

This is my file structure:

enter image description here

My code in 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>

In my pluging.json:

"queryOptions": {
   "maxDataPoints": true
}

Upvotes: 0

Views: 575

Answers (1)

Samuel Toh
Samuel Toh

Reputation: 19298

Q: Can I access the property values of plugin.json? If so how can I access the maxDataPoints property from my controller?

A: You can only access some of the property values in the plugin.json. These values can be found in the PluginMeta class, an instance of it can be found in theinstanceSettings.meta variable of the Datasource class. Example

Unfortunately the maxDataPoints property is not one of those property which you can have access to.

If you have a valid use-case you can try putting in a pull request to ask the Grafana team to expose it for you.

This piece of Grafana server code determines what is made available to the client from all plugin.json. And yes, if you want to expose maxDataPoint property, you'll have to extend that code.

Upvotes: 1

Related Questions