How to retrieve a dynamic list of values from a data source?

i am writing a backend plugin for grafana and I would like to have one of the queries QueryEditor AsyncSelect retrieve a dynamic list of values that it can acquire from the data source. the best I could find to set the queryeditor variables from the datasource plugin (after fetching results) is here - Add support for variables in plugins | Grafana Labs - but its in typescript and mine is written using the go sdk.

this is as far as i got

<AsyncSelect
            loadOptions={this.loadAsyncOptions}
            defaultOptions
            value={value}
            onChange={this.onSelectChange}
          />
  loadAsyncOptions = () => {
    return new Promise<Array<SelectableValue<string>>>((resolve) => {
      setTimeout(() => {
        const { onRunQuery,  } = this.props
        resolve([
          ...this.additional_options
        ]);
        onRunQuery();
      }, 2000);
    });
  };

Can anyone help point me in the right direction?

Thanks

How would you like to use the values? If you’re looking to add something like auto-completion, I wrote a post about how to do this using resource handlers.

1 Like

This looks promising. I’ll check it out and get back sometime. Thanks

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.