grafana-dashboards icon indicating copy to clipboard operation
grafana-dashboards copied to clipboard

Changing datasource is not updating job

Open smutel opened this issue 4 years ago • 3 comments

Hello,

I have setup this dashboard with 2 prometheus datasources. When I switch from one datasource to another one, the jobs are not updated.

Thanks.

smutel avatar May 06 '20 10:05 smutel

Same here

shmish111 avatar Mar 04 '21 13:03 shmish111

yes. same here. seems like changing the datasource is not working.

volserverRay avatar Aug 03 '21 09:08 volserverRay

i have fixed the problem manually. not sure whether it's the correct way or not, but it's working well to change datasource.

basically I just find and replace all the lines of:

"datasource": "your-datasource-name",

to:

"datasource": "$DS_PROMETHEUS",

seems like your-datasource-name is set when you import the dashboard.

volserverRay avatar Aug 03 '21 09:08 volserverRay

How can I do this in Grafana v8.5

AdamDiouri avatar Jan 13 '23 17:01 AdamDiouri

In Json editor press ctrl + H, then you need to replace all instances of this filed (that contains an uuid which will vary in yours):

"datasource": {
            "type": "prometheus",
            "uid": "fd1b579f-668g-4763-9c61-cbg6c6e605t7"
          },

with this:

"datasource": "$DS_PROMETHEUS",

hossein1376 avatar Jun 25 '23 05:06 hossein1376

Also finding this. The datasource fix mentioned by @hossein1376 didn't work for me. Rev33 Grafana is version 10.1.5

EDIT: It does actually work. There were a bunch of uids of 00000001 or similar. I replaced them too and it started to work as expected.

This is surely a bug?

Crumb5 avatar Nov 04 '23 13:11 Crumb5

I have the same problem. The reason seems to be that after importing, Grafana somehow rewrites the dashboard’s DS_PROMETHEUS variable to some fixed data source,... and it also shows the variable then to be unused (under Settings/Variables).

So possibly a bug in Grafana itself?

calestyo avatar Nov 24 '23 04:11 calestyo

I also found https://community.grafana.com/t/dashboard-import-with-datasource-variable/4896 but not sure whether this really solves anything.

calestyo avatar Nov 24 '23 16:11 calestyo

For me, this fixes the issue. At least it seems so. (Ignore 65e38a6... I had only fetched the current upstream master and forgot to merge it when I branched off).

I'm a bit unsure about these 00000001 UIDs that come up when one imported the old version (i.e. the one where ${DS_PROMETHEUS} is replaced with the datasource UID chosen in the import dialogue by Grafana).
Only some were 00000001 and other were some UUID.

I guess with my commit, all would be the UUID (from the datasource selected in the dashboard) or maybe even he real name of the datasource as string?!

Nevertheless, it seems to work.

calestyo avatar Nov 28 '23 02:11 calestyo

Maybe related to https://github.com/grafana/grafana/issues/80666

rc5hack avatar Mar 11 '24 07:03 rc5hack