weaveworks / grafanalib

Python library for building Grafana dashboards
Apache License 2.0
1.86k stars 309 forks source link

`gaugePanel` `reduceOptions` undefined. #575

Open tiansu-yu-idealo opened 1 year ago

tiansu-yu-idealo commented 1 year ago

What you expected to happen?

After I set GaugePanel.calcs to be one of the options, e.g. GAUGE_CALC_MEAN = 'mean' it should return me a correct GaugePanel json.

What happened?

The GaugePanel is mal-formatted. I got the error message from frontend that TypeError: undefined is not an object (evaluating 'e.reduceOptions.values'). After I compare the differences between the code-generated Json and the json generated from UI editor, I notice the following schema difference:

The reduce function in the code-genereted json (grafanalib) one is

"fieldConfig": {
          "defaults": {
            "calcs": [
              "lastNotNull"
            ],
...

and the one generated from UI (my grafana cluster) is

"options": {
        "orientation": "auto",
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
...

You can clearly see a shift where the calcs are located between these two are different.

And one more thing I noticed that the param reduceCalc in Stat behaves correctly, which files calcs under options.reduceOptions instead of fieldConfig. So I suspect this to be a bug (un-synced components).

tulzke commented 4 months ago

+1 Option showThresholdLabels does not work now for the same reason.