Recreating a dashboard only from salvaged json

Dear Grafanistas,

I am writing in the hope of hearing from you some short cuts in solving this problem. (Rather than the usual heuristics cycles :yawning_face: :nerd_face:)

Scenario,
Due to a data loss incident, there is no current grafana.{ini,db}
In fact the only up to date assets are the full set of json for the dashboard.
This includes the library panels

In case you are wondering how come this json data is available?
Well, we salvaged it from a browser window that had the dashboard open at the time of the data loss. so far I have opnly tried to salvage the main dashboard json and the library panel json.
This has not proven to be a problem.

We want to take the dashboard and its associated library panels and folders from a system and importing them into a virgin system which has not users,folders or other assets defined. We know the folder name for the library panels.

The dashboard json salvaged references a libraryPanel ln this fashion:

      "id": 421,
      "libraryPanel": {
        "name": "My Panel Name",
        "uid": "abb2a1df-fed0-4ef9-9037-e56d8f9fb8ff"

For example here is data from a random libraryPanel from salvaged json

"id": 443,                                                                                                                                       "libraryPanel": {
    "id": 24,
    "orgId": 207,
    "folderId": 396,
    "folderUid": "a26e59e0-a1b4-4b5b-9d80-e214de159d5b",
    "uid": "edl3yqlbp8kqob",
    "name": "some name",
    "kind": 1,
    "type": "gauge",
    "description": "",
    "model": {


and more:

    "version": 1,
    "meta": {
      "folderName": "My Folder ",
      "folderUid": "a26e59e0-a1b4-4b5b-9d80-e214de159d5b",
      "connectedDashboards": 1,
      "created": "2022-05-08T17:46:14Z",
      "updated": "2022-05-08T17:46:14Z",
      "createdBy": {
        "avatarUrl": "/avatar/b1e2683efeb1c1f6f116b0d3c0ace29c",
        "id": 1,
        "name": "admin"
      },

In summary, we are without a grafana.db and in a virgin system and have the json files defining the dashboard and the library panels that it references.

FWIW, the folder and user information from grafana.db is not available in this new system.

Obvious idea is to rename the id and uid and uuid where required so that they correspond.
This for the folder and library panel referencing.

What is the best way to recreate the library panels? I guess extract from the library panel the data for an actual native panel.
Then create library anel from that so created native panel?

A first trivial importing of the dashboard json expectedly delivers errors.
Templating
Failed to upgrade legacy queries
For the library panels, the following errors:
Panel plugin not found:

Is an elegant approach to fix this problem of recreating the dashboard?

Many thanks for any pointers

E

oof, that’s a tough one. I don’t think there’s going to be a magic/easy solution, but some things to consider:

  1. Before attempting to create the dashboards, I’d re-create all of the necessary dependent data sources, and then jot down some notes on ID mapping. I.e. your dashboard JSON will have bits like this in it:

image

and your dashboard revival won’t work because those “uids” won’t match the data sources on your pristine new Grafana. So you’ll have to create new datasources, and figure out what the IDs in the JSON should be.

  1. Exactly the same thing above, but for plugins, not data sources.

  2. I don’t know what all is in your legacy queries or what could be going wrong there - but Grafana changes fast and adds lots of interesting new stuff. I would start with a pristine instance that is of the grafana version you were running when you lost this stuff so you have some version-to-version compatibility. I.e. restore it in an old version of Grafana first, then worry about upgrading later. Do not attempt to put Grafana 8 dashboard JSON into a shiny new Grafana 11 instance, because that’ll add layers to what you need to debug & fix in heuristic mode.

Hope this helps a little bit.

1 Like

@davidallen5

Its a useful answer in many ways.
I have a single datasource and thsi si the first thing that I did, worked almost immediately.

Then I figured that I deliberately went to the version 11.0 and realised this aint agood idea, so I will roll back to the 10.x that I had.
Its easy as I start Grafana with a shell script and mapped volumes.

Really love the hand holding :heart_hands:, helps to stop me going into infinite loops.

Let me know see if I can get up the non-library panels with the seemingly working data source.

Then let you know how that went.

Thank you @davidallen5

Hi

All the native panels – those without library panels – are working well.

Next problem that I have not been able to solve by trying to figure it out and rial and error is the library panel. As I mentioned in the first post, I do not know how to create a library panel with the json that I have I cannot make a placeholder library panel and then edit that with the source code as I cannot find a way to edit the sources to match dashboard and library panel.

Is anyone able to give a quick and directive how to take the json of the library panel and convert that to a native panel?
:grinning:

Thanks!
E

FWIW, here are the top level elements in the library panel json. The only significant element that is only in the library panel is libraryPanel. But much if the contents of libraryPanel is duplicated/available elsewhere in the json.

:g/^\s\s\S
  "gridPos": {
  },
  "id": 443,
  "libraryPanel": {
  },
  "targets": [
  ],
  "options": {
  },
  "fieldConfig": {
  },
  "datasource": {
  },
  "description": "",
  "pluginVersion": "10.4.2",
  "repeat": "analytes",
  "repeatDirection": "v",
  "type": "gauge",
  "scopedVars": {
  }

similarly, here are the top level elements in a standard native panel:

:g/^\s\s\S
  "datasource": {
  },
  "fieldConfig": {
  },
  "gridPos": {
  },
  "id": 227,
  "options": {
  },
  "pluginVersion": "10.4.2",
  "targets": [
  ],
  "type": "gauge"