grafana / plugin-tools

Create Grafana plugins with ease.
https://grafana.com/developers/plugin-tools/
Apache License 2.0
57 stars 28 forks source link

Outdated info in 'Add support for variables' topic #829

Closed josmperez closed 2 months ago

josmperez commented 5 months ago
  1. There are some documentation sections that are outdated.

Example: Add support for variables. At the end of the page it mentions using setVariableQueryEditor for configuring plugin's query editor for variables. But actually it's deprecated (you get deprecation message when you start using it and it mentions the new way) and there is a new way of adding variables, which is not documented. Once you go to the code to understand this new method - it's also not clear, methods / properties are not documented, comments are not clear. So you need to check some examples and play around with it until you get something you want.

There is a slack thread I started a while ago, it has some more info.

  1. Incorrect docs. For example on the same page about adding support for variables, there is this:

The metricFindQuery function returns an array of MetricFindValue which has a single property, text: async metricFindQuery(query: MyVariableQuery, options?: any) { // Retrieve DataQueryResponse based on query. const response = await this.fetchMetricNames(query.namespace, query.rawQuery);

// Convert query results to a MetricFindValue[] const values = response.data.map(frame => ({ text: frame.name }));

return values; }

But in reality MetricFindValue has not only text, it also has value and expandable : interface MetricFindValue { text: string; value?: string | number; expandable?: boolean; }

Reported by Andriy Urbanas