grafana / grafana

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
https://grafana.com
GNU Affero General Public License v3.0
61.44k stars 11.73k forks source link

Add ability to move library panels to a different folder #43933

Open amy-super opened 2 years ago

amy-super commented 2 years ago

There is no way in the UI to move a library panel into another folder. Once it's created into a folder, it cannot be moved into another folder.

This makes it difficult for admins to keep their Grafana instance organised, but also enforce proper permissions models through folders.


This following is the original issue description, which is now outdated. Moving a dashboard no longer moves library panels along with it.

Today, you cannot move a library panel to a different folder. Here's how it works.

Except - when you:

This exception is odd and unexpected. We should either 1) give users the ability to move library panels to different folders (which opens up a host of potential permissions issues but could be addressed through warnings/messaging) or 2) remove the odd "workaround".

johndunderhill commented 1 year ago

@amy-super Thanks for logging this issue. The linked task was closed, but the necessary changes were not implemented.

Moving library panels from one folder to another seems like basic functionality to me. I've run into trouble with this on several occasions; the work-arounds are hideous.

There is some confusion about permissions for library panels, however the idea that library panels inherit their permissions from the folder they're contained in seems straightforward and workable to me, and I believe recent updates now enforce this (see https://github.com/grafana/grafana/issues/61011). A user needs View permission on the panel to load it into a dashboard, potentially stored elsewhere.

Do you think this should be prioritized, or maybe linked to another Epic relating to core UI capabilities and/or permissions?

amy-super commented 1 year ago

@johndunderhill good point - we are working on some tangentially related items on the dashboard browse view in #62024 so I'll link this into that epic. It may get moved as we scope that work but it will be good to keep eyes on those hideous workarounds 😉

liangway commented 10 months ago

I have run into this issue. What are the workarounds to move library panels to a different folder?

bminer commented 10 months ago

I have run into this issue. What are the workarounds to move library panels to a different folder?

Best way is to stop the Grafana server, hop into the Grafana sqlite database and write an UPDATE query to move it. Then, close the sqlite database and start the server.

paulfirstimpression commented 3 months ago

Too bad it is not yet possible in the Grafana frontend. But what worked for me is using the API.

First create a Service account with a token under Administration in your Grafana frontend. Use the token in the header of the API calls below. Authorization: Bearer eyabcdefgUlY2RnVKZTFV12345677890XdE9ZWmNrMkZYbk

Then check what library panel you want to move and to what folder you want to move it (folderId / FolderUid). GET /api/library-elements

Next, PATCH the library panel you want to move. Make sure you also include the kind and version. PATCH /api/library-elements/:uid

Example body:

{
"name": "Logging_Details",
"kind": 1,
"version": 8,
"folderId": 184,
"folderUid": "AhAVsacAz"
}
johndunderhill commented 2 weeks ago

@amy-super Now this is causing additional grief. All my library panels were in the General folder, but that folder is no longer visible in Grafana (Cloud, v11.1.0). If I try to create it, the system says it's a reserved name. So (1) I cannnot change the permissions on this folder, which controls access to my library panels; and (2) I can no longer save new library panels into this folder, because it no longer appears in the picklist. Why did you remove access to a folder with user content in it? This makes no sense.

joshhunt commented 2 weeks ago

@johndunderhill I think there's a misunderstanding here, due to the confusing history of the General 'folder', and a shortcoming of our current Browse design.

Just for context - as briefly alluded to in What's New in 10.2, there's never actually been a General "folder". General was always a fiction of the UI to show items that weren't in a folder. This is why some things, such as Alerts, could never be saved into the General folder because Alerts must be saved into a folder, and General was not a real folder. To avoid this confusion, we removed the concept of a fake General folder from the UI and prefer showing items at the root of Browse Dashboards.

So nothing should be lost, but some things in the UI have been shuffled around in a way that might be confusing:

Additionally, recently we've squashed the last few places where we still referred to General https://github.com/grafana/grafana/pull/89017 https://github.com/grafana/grafana/pull/89220

We know that organising and finding non-Dashboard things in our current folder structure is confusing, so there's an effort under way to address this a lot more broadly, but nothing more to say about that yet. In the mean time, I think it would be great if @grafana/dashboards-squad could manage to get in a move library panel UI.