Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No data on a stat panel when displaying 'Time' instead of value itself (Public dashboard) #62479

Closed
Tracked by #66586
spookyrecharge opened this issue Jan 30, 2023 · 4 comments

Comments

@spookyrecharge
Copy link

spookyrecharge commented Jan 30, 2023

What happened:
I'm trying to make a public dashboard where my neighbors can see if there is electricity in the building and when there is no electricity. Everything is ok except one moment: I would like to display the timestamp of the last value I've got from my sensor. I got it displaying on original grafana dashboard when I'm logged in, but it doesn't work on a public dashboard as anonymous user.

image
FYI: There is no problem when displaying the value itself by using this query, but when I'm selecting 'Time' in 'Fields' - I've got 'no data' displaying on the panel

image
how it's looking when I'm logged in (non public dashboard view)

image
and this is what I got when seeing it as public dashboard

Environment:

  • Grafana version: 9.3.6
  • Data source type & version: InfluxDB 1.8.10
  • OS Grafana is installed on:
  • User OS & Browser:
  • Grafana plugins:
  • Others:
@mellieA
Copy link
Contributor

mellieA commented Jan 30, 2023

@spookyrecharge are you able to use the panel > get help button to share a copy of this panel that we can review?

Have you noticed if you use developer tools in the browser and inspect the request/response in the network tab while logged in and viewing publicly if there is a difference in the return values or error messages?

@mellieA mellieA added triage/needs-confirmation used for OSS triage rotation - reported issue needs to be reproduced area/public-dashboards needs more info Issue needs more information, like query results, dashboard or panel json, grafana version etc labels Jan 30, 2023
@spookyrecharge
Copy link
Author

spookyrecharge commented Jan 30, 2023

Key Value
Panel stat @ 9.3.6
Grafana 9.3.6 (978237e) // Open Source
Panel debug snapshot dashboard
{
  "panels": [
    {
      "id": 2,
      "gridPos": {
        "h": 13,
        "w": 15,
        "x": 0,
        "y": 0
      },
      "type": "stat",
      "title": "Reproduced with embedded data",
      "datasource": {
        "type": "grafana",
        "uid": "grafana"
      },
      "pluginVersion": "9.3.6",
      "timeFrom": "7d",
      "hideTimeOverride": true,
      "fieldConfig": {
        "defaults": {
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "color": {
            "fixedColor": "red",
            "mode": "fixed"
          },
          "unit": "none"
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "values": false,
          "calcs": [
            "lastNotNull"
          ],
          "fields": "/^Time$/",
          "limit": 1
        },
        "orientation": "horizontal",
        "textMode": "value",
        "colorMode": "value",
        "graphMode": "none",
        "justifyMode": "center"
      },
      "targets": [
        {
          "refId": "A",
          "datasource": {
            "type": "grafana",
            "uid": "grafana"
          },
          "queryType": "snapshot",
          "snapshot": [
            {
              "schema": {
                "refId": "A",
                "meta": {
                  "executedQueryString": "SELECT last(\"free_heap\") FROM \"sys\" WHERE time >= now() - 7d and time <= now() fill(none)"
                },
                "name": "sys.last",
                "fields": [
                  {
                    "name": "Time",
                    "type": "time",
                    "config": {}
                  },
                  {
                    "name": "Value",
                    "type": "number",
                    "config": {
                      "displayNameFromDS": "sys.last"
                    }
                  }
                ]
              },
              "data": {
                "values": [
                  [
                    1675112640804
                  ],
                  [
                    34344
                  ]
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "gridPos": {
        "h": 7,
        "w": 9,
        "x": 15,
        "y": 0
      },
      "id": 5,
      "options": {
        "content": "<table width=\"100%\">\n    <tr>\n      <th width=\"2%\">Panel</th>\n      <td >stat @ 9.3.6</td>\n    </tr>\n    <tr>\n      <th>Queries</th>\n      <td>A[influxdb]</td>\n    </tr>\n    \n    <tr><th>Data</th><td> 1 frames, 2 fields, 1 rows </td></tr>\n    \n    <tr>\n      <th>Grafana</th>\n      <td>9.3.6 (978237e7cb) // Open Source</td>\n    </tr>\n  </table>",
        "mode": "html"
      },
      "title": "Debug info",
      "type": "text"
    },
    {
      "id": 6,
      "title": "Original Panel JSON",
      "type": "text",
      "gridPos": {
        "h": 13,
        "w": 9,
        "x": 15,
        "y": 7
      },
      "options": {
        "content": "{\n  \"id\": 8,\n  \"gridPos\": {\n    \"h\": 4,\n    \"w\": 4,\n    \"x\": 14,\n    \"y\": 8\n  },\n  \"type\": \"stat\",\n  \"title\": \"Last power ON state\",\n  \"datasource\": {\n    \"uid\": \"nnX4Q0D4z\",\n    \"type\": \"influxdb\"\n  },\n  \"pluginVersion\": \"9.3.6\",\n  \"timeFrom\": \"7d\",\n  \"hideTimeOverride\": true,\n  \"fieldConfig\": {\n    \"defaults\": {\n      \"mappings\": [],\n      \"thresholds\": {\n        \"mode\": \"absolute\",\n        \"steps\": [\n          {\n            \"color\": \"green\",\n            \"value\": null\n          }\n        ]\n      },\n      \"color\": {\n        \"fixedColor\": \"red\",\n        \"mode\": \"fixed\"\n      },\n      \"unit\": \"none\"\n    },\n    \"overrides\": []\n  },\n  \"options\": {\n    \"reduceOptions\": {\n      \"values\": false,\n      \"calcs\": [\n        \"lastNotNull\"\n      ],\n      \"fields\": \"/^Time$/\",\n      \"limit\": 1\n    },\n    \"orientation\": \"horizontal\",\n    \"textMode\": \"value\",\n    \"colorMode\": \"value\",\n    \"graphMode\": \"none\",\n    \"justifyMode\": \"center\"\n  },\n  \"targets\": [\n    {\n      \"datasource\": {\n        \"type\": \"influxdb\",\n        \"uid\": \"nnX4Q0D4z\"\n      },\n      \"groupBy\": [\n        {\n          \"params\": [\n            \"10s\"\n          ],\n          \"type\": \"time\"\n        },\n        {\n          \"params\": [\n            \"none\"\n          ],\n          \"type\": \"fill\"\n        }\n      ],\n      \"hide\": false,\n      \"measurement\": \"sys\",\n      \"orderByTime\": \"ASC\",\n      \"policy\": \"default\",\n      \"refId\": \"A\",\n      \"resultFormat\": \"time_series\",\n      \"select\": [\n        [\n          {\n            \"params\": [\n              \"free_heap\"\n            ],\n            \"type\": \"field\"\n          },\n          {\n            \"params\": [],\n            \"type\": \"last\"\n          }\n        ]\n      ],\n      \"tags\": [],\n      \"query\": \"SELECT last(\\\"free_heap\\\") FROM \\\"sys\\\" WHERE $timeFilter fill(none)\",\n      \"rawQuery\": true\n    }\n  ]\n}",
        "mode": "code",
        "code": {
          "language": "json",
          "showLineNumbers": true,
          "showMiniMap": true
        }
      }
    },
    {
      "id": 3,
      "title": "Data from panel above",
      "type": "table",
      "datasource": {
        "type": "datasource",
        "uid": "-- Dashboard --"
      },
      "gridPos": {
        "h": 7,
        "w": 15,
        "x": 0,
        "y": 13
      },
      "options": {
        "showTypeIcons": true
      },
      "targets": [
        {
          "datasource": {
            "type": "datasource",
            "uid": "-- Dashboard --"
          },
          "panelId": 2,
          "withTransforms": true,
          "refId": "A"
        }
      ]
    }
  ],
  "schemaVersion": 37,
  "title": "Debug: Last power ON state // 2023-01-30 23:04:12",
  "tags": [
    "debug",
    "debug-stat"
  ],
  "time": {
    "from": "2023-01-02T21:04:12.563Z",
    "to": "2023-01-30T21:04:12.563Z"
  }
}

Thank you for your response

I have removed GROUP BY from query so I could put it into github as a comment, we don't need historical data anyway, now querry is grabbing the latest value from DB. So far doesn't affect anything, I can still display value in public dashboard but not it's timestamp

Sorry, I'm not familiar with the chrome dev tools and how to check and compare request/response content

And here is public dashboard URL just in case
https://grafana.panov.dev/public-dashboards/668177c16a754a5cbb219045d28e4083?orgId=1

@evictorero evictorero mentioned this issue May 4, 2023
21 tasks
@evictorero evictorero self-assigned this May 23, 2023
@evictorero
Copy link
Contributor

evictorero commented May 23, 2023

I was able to reproduce this error with this JSON
The issue occurs because the influxDB data source is querying the backend using a proxy. There is an ongoing effort targeting this Q about migrating to query without the proxy using the backend endpoint which is what public dashboards need to be fully compatible.
This could be turned on and tested using a feature flag influxdbBackendMigration which is in alpha stage.
Using this flag, I couldn't see any difference between the original dashboard and the public version.

@evictorero evictorero added area/dashboard and removed needs more info Issue needs more information, like query results, dashboard or panel json, grafana version etc triage/needs-confirmation used for OSS triage rotation - reported issue needs to be reproduced labels May 23, 2023
@evictorero
Copy link
Contributor

Closing this issue since the influxDB querying using a proxy won't be supported by Public Dashboards. We expect to have this particular case working once the influxDB backend query is delivered. In the meantime, this could be tested with the feature flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

3 participants