flant / grafana-statusmap

Grafana panel plugin to visualize status of multiple objects over time
MIT License
831 stars 43 forks source link

Fix v8 tableresult empty #239

Closed peishaofeng closed 2 years ago

peishaofeng commented 2 years ago

Overview

What this PR does / why we need it

To fix issue #227 Empty results in status map panel post grafana version upgrade from v7.4 to v8.1. #227

Special notes for your reviewer

1. auto-convert data format according Grafana version

on v7 keep existing data format, no conversion.

on v8 made changes below:

${GRAFANA}/public/app/plugins/panel/graph/data_processor.ts

I have verified the same plugin package build on both Grafana v8.0.6 and v7.4.2, it works fine.

2. SDK 8.3.0 report fail

@grafana SDK 8.3.0 report error, so i use 8.2.5 instead

✖ PostCSS plugin postcss-discard-comments requires PostCSS 8.
Migration guide for end-users:
https://github.com/postcss/postcss/wiki/PostCSS-8-for-end-users
  Trace: Error: PostCSS plugin postcss-discard-comments requires PostCSS 8.
  Migration guide for end-users:
  https://github.com/postcss/postcss/wiki/PostCSS-8-for-end-users

Does this PR introduce a user-facing change?

NONE
diafour commented 2 years ago

Thank you for this PR! DataFrames support is a long-awaited feature.

I've got some findings about data frames and Grafana versions (not precise, sorry):

  1. Panels plugins with dataFrames are supported since Grafana 6.7.
  2. @grafana/data module appears in plugins with migration to PanelEvents.
  3. Adding import @grafana/data make plugin not working in Grafana <=6.3. It is not possible to check if module is not injected and change plugin behavior for that older versions.

How these facts affect your PR?

  1. Update README.md: set minimum supported version to Grafana 6.7.
  2. V8 detection is not needed, use data frames for data handling. Set this.useDataFrames = true and remove onDataReceived.
  3. Import PanelEvents and CoreEvents from @grafana/data, no need to fallback to string-based events. Remove all Polygrafill hackery: fallbackToStringEvents, ./util/grafana/events, etc.

Do you have time to make these changes?

peishaofeng commented 2 years ago

Yes, I'd like to be of help to make this panel plugin better. Also need to prepare both v6 & v7 environment to verify modification, next week should have spare time to do further optimization as you mentioned above.

peishaofeng commented 2 years ago

submit changes according your suggestion, the same plugin build are verified on v6.7.1/v7.4.2/v8.2.5

1. convert DataFrame to series list

2. remove string-based events polyfill

Grafana v6.* has built-in graphHover and graphHoverClear defined which cause event name conflict with self-defined events.

3. move renderComplete to utils/grafana/events/events.ts

4. fix prettier warnings

5. README.md

6. plugin.json

  "dependencies": {
    "grafanaDependency": ">=6.7.0",
    "grafanaVersion": "6.7+",
    "plugins": [ ]
  }