Altinity / clickhouse-grafana

Altinity Grafana datasource plugin for ClickHouse®
MIT License
718 stars 120 forks source link

Tooltip is not formatted - TimeSeries panel - 9.3.X+ #478

Open sbengo opened 1 year ago

sbengo commented 1 year ago

Hi @Slach ,

Description:

After upgrading to Grafana 9.3.X, with the latest version of plugin (2.5.3), on TimeSeries panel, the tooltip information is not formated as the legend:

image

It happens when the user tries to change the timerange or the series changes due to variables/templating.

I have tried to debug a bit and test other Datasources and the problems seems to the way that the Dataframe is built and the current Grafana version is not able to format it...

Apologies for opening this issue here instead of Grafana, but wanted to share with you, as I'm not sure that the Draframe is being built as it should

Tested with:

Note:

Repro case:

  1. Create a Dashboard with altinity-grafana as DS and use some query like the following:
  SELECT
      $timeSeries as t,
      count(<field>) as field,
      <group_column>
  FROM $table
  WHERE $timeFilter

  GROUP BY t, <group_column>
  ORDER BY t, <group_column>
  1. Validate that when the user changes the timeRange the tooltip differs from legend and it takes format as:

    {name="<group_column_value>"}
  2. Extract the Dataframe image

  3. Create new panel using TestDB as Datasource, select RAW Frame and paste the extracted Dataframe: image

  4. Validate that the problem is directly related with the current Dataframe spec

Example:

The following Dataframe has been extracted from CH query and modified in order to let you to reproduce the case: group_column_value = {"serie A"|"serie B"}

[
  {
    "schema": {
      "name": "serie A",
      "fields": [
        {
          "name": "Time",
          "type": "time",
          "config": {}
        },
        {
          "name": "Value",
          "type": "number",
          "config": {}
        }
      ]
    },
    "data": {
      "values": [
        [
          1681776060000
        ],
        [
          1
        ]
      ]
    }
  },
  {
    "schema": {
      "name": "serie B",
      "fields": [
        {
          "name": "Time",
          "type": "time",
          "config": {}
        },
        {
          "name": "Value",
          "type": "number",
          "config": {}
        }
      ]
    },
    "data": {
      "values": [
        [
          1681776060000
        ],
        [
          1
        ]
      ]
    }
  }
]
sbengo commented 1 year ago

Hi @Slach , to add more info, I found that on the following Grafana dashboard there is the same behaviour, as the legend values is different than the shown tooltip

https://play.grafana.org/d/data-frame-scenarios-timeseries-panel/data-frame-scenarios-timeseries-panel?orgId=1&var-scenario=multi-frame&var-resultState=success&var-generator=frontend

Note that if you edit the panel and you add a "dummy" transformation like Join by fields -> OUTER Time and then you disable it again, the tooltip is well formatted. For some reason its the first time that it renders the panel...

image

cjw296 commented 1 year ago

My experience has been that the tooltips are correctly formatted on first load, but any change after that causes this issue to occur. That includes an automatic reload of the data on the page...

sbengo commented 1 year ago

@Slach , @cjw296 as I supposed, it was a Grafana problem. The following PR https://github.com/grafana/grafana/pull/69289 fixes it (tested locally with docker :main) and working fine.

Note the related issue, as some other DS plugin owner reported it to Grafana

@Slach , as it is suggested, a legacy format (Time/Value) is being used, it would be convenient to adapt to the recommended dataframe format

Closing this issue. Thanks, Regards

Slach commented 1 year ago

@sbengo thanks for sharing your feedback

sbengo commented 1 year ago

Hi @Slach , we have upgraded Grafana to 10.0.3 and I was wrong: the issue has been fixed when the user changes the variables, but for some reason, when the user changes the range time, the panel renders with bad format, as explained on this issue.

I think that Grafana team missed that case, as I reproduced it on the play.grafana dashboard:

https://play.grafana.org/d/data-frame-scenarios-timeseries-panel/data-frame-scenarios-timeseries-panel?orgId=1&var-scenario=multi-frame&var-resultState=success&var-generator=frontend

sbengo commented 1 year ago

@Slach , I have already asked on the original issue: https://github.com/grafana/grafana/issues/69207#issuecomment-1700392085

Slach commented 1 year ago

@sbengo let's wait when https://github.com/grafana/grafana/issues/74281 will resolve