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

Invalid dashboard UID in the request error on custom home dashboard #54574

Open
piotrp opened this issue Sep 1, 2022 · 13 comments
Open

Invalid dashboard UID in the request error on custom home dashboard #54574

piotrp opened this issue Sep 1, 2022 · 13 comments
Labels

Comments

@piotrp
Copy link

piotrp commented Sep 1, 2022

What happened:

I set custom home dashboard using default_home_dashboard_path, now when entering Grafana I see an error in UI: "Invalid dashboard UID in the request"
obraz

What you expected to happen:

No error

How to reproduce it (as minimally and precisely as possible):

docker-compose.yml

version: '3.8'
services:
  grafana:
    image: grafana/grafana:9.1.2
    volumes:
      - ./Home.json:/tmp/Home.json
    ports:
      - "3000:3000"
    environment:
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/tmp/Home.json

Home.json - empty dashboard from the same Grafana version, with Annotations & Alerts removed for simplicity (the same happens when I leave it)

{
  "annotations": {
    "list": []
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": 1,
  "links": [],
  "liveNow": false,
  "panels": [],
  "schemaVersion": 37,
  "style": "dark",
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "Custom Home",
  "uid": "JqqE7eWVk",
  "version": 2,
  "weekStart": ""
}

Environment:

  • Grafana version: 9.1.2
  • Data source type & version: -
  • OS Grafana is installed on: Docker (grafana:9.1.2)
  • User OS & Browser: Windows, Firefox 104.0.1
  • Grafana plugins: -
  • Others: -
@ivanahuckova ivanahuckova added area/dashboard area/backend needs investigation for unconfirmed bugs. use type/bug for confirmed bugs, even if they "need" more investigating labels Sep 5, 2022
@threechord82
Copy link

Same error here.
If I pass the board already as a variable I get the error message.
If I import the board manually I get no message.
Since we deploy Grafana automatically it would be good if the board could be set automatically.

@yangkb09
Copy link
Contributor

yangkb09 commented Sep 7, 2022

Hi @piotrp! Are you using the absolute path when setting your custom home dashboard using default_home_dashboard_path? And do you have any organization dashboard preferences for the home dashboard set already?

@piotrp
Copy link
Author

piotrp commented Sep 9, 2022

I'm using absolute path:

[dashboards]
default_home_dashboard_path = /var/lib/grafana/home.json

There are no such preferences set. You can verify all of this by checking out reproduction steps above, which use official Docker image.

@yangkb09
Copy link
Contributor

yangkb09 commented Sep 9, 2022

Hi @piotrp, I was able to reproduce what you're seeing - thanks for the well written reproduction!

The problem is that the dashboard must exist before you can configure it as the home dashboard; Grafana does not automatically create that dashboard.

You can either configure Grafana to provision the dashboard from that same json file, or create the dashboard in the UI. The documentation for provisioning dashboards from files can be found here.

This wasn't clear from the documentation, so I've re-labeled this as a docs issue.
Thanks!

@mildwonkey mildwonkey removed the needs investigation for unconfirmed bugs. use type/bug for confirmed bugs, even if they "need" more investigating label Sep 12, 2022
@piotrp
Copy link
Author

piotrp commented Sep 20, 2022

Then isn't this also a design issue of this functionality? If this dashboard must be already existing, then configuration should only point to dashboard's UID, not file path. Or in other words, default_home_dashboard_path should be deprecated and a new default_home_dashboard_uid should be introduced, because current method of setting default home dashboard makes little sense.

@ggear
Copy link

ggear commented Sep 22, 2022

I agree, and given this is the first time I have seen this issue with version 9.1.2 I would consider it a regression.

@osg-grafana osg-grafana added the migrate/status-new-issues Temporary label that can be deleted after 2022 Nov label Nov 2, 2022
@leodking
Copy link

leodking commented Dec 6, 2022

I have the same issue. From my tests this issue happens when I spin up a Grafana server on version 9.1.0. Whereas 9.0.9 and earlier is fine.

Error is: "Invalid dashboard UID in the request"

@jacksongoode
Copy link

Is there a resolution to this? We provision the custom home page with GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH.

@jphx
Copy link

jphx commented Feb 15, 2023

I fixed this in our setup just yesterday. According to my investigation, the error message is coming from a failed annotations query, the "built-in" query that is normally done for all dashboards. But it can be disabled for a dashboard.

Our home dashboard json had this section near the top:

      "annotations": {
        "list": [
          {
            "builtIn": 1,
            "datasource": {
              "type": "grafana",
              "uid": "-- Grafana --"
            },
            "enable": true,
            "hide": true,
            "iconColor": "rgba(0, 211, 255, 1)",
            "name": "Annotations & Alerts",
            "target": {
              "limit": 100,
              "matchAny": false,
              "tags": [],
              "type": "dashboard"
            },
            "type": "dashboard"
          }
        ]
      },

All I did was to change enable to false and the built-in query is suppressed. The error message no longer appears.

@Thrinadh-Kumpatla
Copy link

        "annotations": {
          "list": [
            {
              "builtIn": 1,
              "datasource": {
                "type": "datasource",
                "uid": "grafana"
              },
              "enable": true,
              "hide": true,
              "iconColor": "rgba(0, 211, 255, 1)",
              "limit": 100,
              "name": "Annotations & Alerts",
              "showIn": 0,
              "target": {
                "limit": 100,
                "matchAny": false,
                "tags": [],
                "type": "dashboard"
              },
              "type": "dashboard"

I removed the line "showIn": 0, and I'm not seeing error anymore

@activedecay
Copy link

activedecay commented Mar 15, 2023

The problem is that the dashboard must exist before you can configure it as the home dashboard; Grafana does not automatically create that dashboard.

To which dashboard are you referring? The error message now says "Invalid dashboard UID in annotation request" which changed every so slightly from the original description.

The workaround steps are the same; just add "enable": false to the dashboard JSON and the error goes away.

It seems like changing the Home dashboard during creation of the default/empty/clean Grafana image is not supported. Is there a clean way to change the landing page (home dashboard) from a clean installation of the docker image? My Grafana version is 9.4.3 (Edit: The goal would be to create a new grafana docker instance and configure the home dashboard using some dashboard JSON as input. I guess you'd have to POST a dashboard API hit to create a dashboard? And from there configured it somehow?)

@darks00ul
Copy link

darks00ul commented Jul 23, 2023

EDIT 1: I didn't verify if this behavior also happen with a dashboard exported from General Folder... If I probe this I will update this post to clarify this..

Hi everyone, I was having this same issue and I find out that this happened to me under the following circumstances:

  • My original dashboard (home.json) was created in a Grafana instance where the dashboard was located in a folder different than General, for example "myfolder"
  • Then I exported this dashboard and import it in a new Grafana instance using the following options:
environment:
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/tmp/home.json

But i didn't configure the provisioning needed in order to recreate the folder name from my older Grafana instance from where I exported the dashboard "home.json"

So I fix this as soon I configured the provisioning information, using a volume pointing to /etc/grafana/provisioning with the dashboard provisioning information like this:

apiVersion: 1

providers:
- name: Prometheus
  orgId: 1
  folder: 'myfolder'
  folderUid: 'myfolder'
  type: file
  options:
    path: /var/lib/grafana/dashboards

Hope this helps

@andoks
Copy link

andoks commented Nov 9, 2023

If I am reading dashboard.go:561 and the call-tree of that function right, Grafana should not need the same dashboard definition to be provisioned as a dashboard in addition to be specified using the default_home_dashboard_path configuration parameter, as it reads the file specified, and returns it.

After doing some spelunking - assuming I am in the right place at all in the code - it should be possible to add a config for UID similarly as how it is done for user preferences (dashboard.go:537 and preferences.go:35)

I however found that setting home_page in the "users" setting instead (from settings.go:1700) covers my use-case, as I can just set the relative path to the desired dashboard here, and everything works as I need it to.

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

No branches or pull requests