github.com/esnet/gdg@v0.6.1-0.20240412190737-6b6eba9c14d8/website/content/docs/tutorials/library_elements.md (about)

     1  ---
     2  title: "Working with Library Panels"
     3  weight: 2
     4  ---
     5  
     6  Starting with version 0.4, library panels are going to be supported. It's a bit special and the behavior is somewhat unique.
     7  
     8  Rules:
     9    - Library Panels are immutable.  They cannot be moved to a different folder.  They are linked to one or multiple dashboards.
    10    - The only way I can see to move a lib element is to unlink the panel, delete the panel and re-create it in a different folder, then re-link it.
    11    - In theory it's supposed to move with the dashboards but I haven't been able to re-create that behavior.
    12    - You cannot delete a library element while a dashboard is still using it.
    13  
    14  
    15  ## Import components
    16  
    17  will retrieve all the components from Grafana and save to local file system.
    18  
    19  
    20  
    21  ```sh
    22  gdg lib download
    23  ┌─────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────┐
    24  │ TYPE    │ FILENAME                                                                                              │
    25  ├─────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────┤
    26  │ library │ testing_data/libraryelements/General/dashboard-makeover-extra-cleaning-duty-assignment-today.json     │
    27  │ library │ testing_data/libraryelements/General/dashboard-makeover-lighting-status.json                          │
    28  │ library │ testing_data/libraryelements/General/dashboard-makeover-side-dish-prep-times-past-7-days.json         │
    29  │ library │ testing_data/libraryelements/General/dashboard-makeover-time-since-we-purchased-these-spices.json     │
    30  │ library │ testing_data/libraryelements/General/extreme-dashboard-makeover-grill.json                            │
    31  │ library │ testing_data/libraryelements/General/extreme-dashboard-makeover-mac-oven.json                         │
    32  │ library │ testing_data/libraryelements/General/extreme-dashboard-makeover-refrigerator-temperature-f.json       │
    33  │ library │ testing_data/libraryelements/General/extreme-dashboard-makeover-room-temperature-f.json               │
    34  │ library │ testing_data/libraryelements/General/extreme-dashboard-makeover-salmon-cooking-times-past-7-days.json │
    35  └─────────┴───────────────────────────────────────────────────────────────────────────────────────────────────────┘
    36  ```
    37  
    38  ## Importing Dashboards
    39  Now that we the library components, pulled let's pull the Dashboard.
    40  
    41  ```sh
    42  gdg dash download
    43  INFO[0002] Importing dashboards for context: 'local'
    44  ┌───────────┬───────────────────────────────────────────────────────────────────┐
    45  │ TYPE      │ FILENAME                                                          │
    46  ├───────────┼───────────────────────────────────────────────────────────────────┤
    47  │ dashboard │ testing_data/dashboards/General/bandwidth-dashboard.json          │
    48  │ dashboard │ testing_data/dashboards/General/bandwidth-patterns.json           │
    49  │ dashboard │ testing_data/dashboards/Other/dashboard-makeover-challenge.json   │ <== uses library panels
    50  │ dashboard │ testing_data/dashboards/Other/flow-analysis.json                  │
    51  │ dashboard │ testing_data/dashboards/Other/flow-data-for-circuits.json         │
    52  │ dashboard │ testing_data/dashboards/Other/flow-data-for-projects.json         │
    53  │ dashboard │ testing_data/dashboards/Other/flow-data-per-country.json          │
    54  │ dashboard │ testing_data/dashboards/Other/flow-data-per-organization.json     │
    55  │ dashboard │ testing_data/dashboards/Other/flow-information.json               │
    56  │ dashboard │ testing_data/dashboards/Other/flows-by-science-discipline.json    │
    57  │ dashboard │ testing_data/dashboards/General/individual-flows.json             │
    58  │ dashboard │ testing_data/dashboards/General/individual-flows-per-country.json │
    59  │ dashboard │ testing_data/dashboards/Ignored/latency-patterns.json             │
    60  │ dashboard │ testing_data/dashboards/General/loss-patterns.json                │
    61  │ dashboard │ testing_data/dashboards/General/other-flow-stats.json             │
    62  │ dashboard │ testing_data/dashboards/General/science-discipline-patterns.json  │
    63  │ dashboard │ testing_data/dashboards/General/top-talkers-over-time.json        │
    64  └───────────┴───────────────────────────────────────────────────────────────────┘
    65  ```
    66  
    67  The dashboards will have a reference to the library panel linked by UID.
    68  
    69  Here's the json from the dashboard JSON:
    70  
    71  ```json
    72        "libraryPanel": {
    73          "description": "",
    74          "meta": {
    75            "connectedDashboards": 3,
    76            "created": "2022-05-17T19:35:06Z",
    77            "createdBy": {
    78              "avatarUrl": "/avatar/579fc54abdc9ab34fb4865322f2870a1",
    79              "id": 13,
    80              "name": "mike.johnson@grafana.com"
    81            },
    82            "folderName": "mj",
    83            "folderUid": "R0bMCcW7z",
    84            "updated": "2022-05-17T19:37:14Z",
    85            "updatedBy": {
    86              "avatarUrl": "/avatar/579fc54abdc9ab34fb4865322f2870a1",
    87              "id": 13,
    88              "name": "mike.johnson@grafana.com"
    89            }
    90          },
    91          "name": "Extreme Dashboard Makeover - Grill",
    92          "type": "graph",
    93          "uid": "y1C0A5unz",
    94          "version": 2
    95        },
    96  ```
    97  
    98  Please note, this is the Grill panel.
    99  
   100  ```json
   101  {
   102           "name": "Extreme Dashboard Makeover - Grill",
   103          "orgId": 1,
   104          "type": "graph",
   105          "uid": "y1C0A5unz",
   106          "version": 1
   107  }
   108  ```
   109  ## Deleting Elements
   110  If we try to delete all the Library elements, that won't be allowed.
   111  
   112  ```sh
   113  ./bin/gdg lib clear
   114  ERRO[0000] Failed to delete library panel titled: Dashboard Makeover - Extra Cleaning Duty Assignment Today  ErrorMessage="the library element has connections"
   115  ERRO[0000] Failed to delete library panel titled: Dashboard Makeover - Lighting Status  ErrorMessage="the library element has connections"
   116  ERRO[0000] Failed to delete library panel titled: Dashboard Makeover - Side Dish Prep Times, past 7 days  ErrorMessage="the library element has connections"
   117  ERRO[0000] Failed to delete library panel titled: Dashboard Makeover - Time since we purchased these spices  ErrorMessage="the library element has connections"
   118  ERRO[0000] Failed to delete library panel titled: Extreme Dashboard Makeover - Grill  ErrorMessage="the library element has connections"
   119  ERRO[0000] Failed to delete library panel titled: Extreme Dashboard Makeover - Mac Oven  ErrorMessage="the library element has connections"
   120  ERRO[0000] Failed to delete library panel titled: Extreme Dashboard Makeover - Refrigerator Temperature (F)  ErrorMessage="the library element has connections"
   121  ERRO[0000] Failed to delete library panel titled: Extreme Dashboard Makeover - Room Temperature (F)  ErrorMessage="the library element has connections"
   122  ERRO[0000] Failed to delete library panel titled: Extreme Dashboard Makeover - Salmon Cooking Times, past 7 days  ErrorMessage="the library element has connections"
   123  INFO[0000] No library were found.  0 librarys removed
   124  ```
   125  
   126  ### Deleting related dashboard
   127  
   128  
   129  (Future version will allow you to inspect which dashboard has a link to which dashboards)
   130  
   131  ```sh
   132  ./bin/gdg dash clear -d dashboard-makeover-challenge                                                                                  (gke_esnet-sd-dev_us-central1-c_dev-staging-kafka-3/default)
   133  INFO[0000] 1 dashboards were deleted
   134  ┌───────────┬──────────────────────────────┐
   135  │ TYPE      │ FILENAME                     │
   136  ├───────────┼──────────────────────────────┤
   137  │ dashboard │ Dashboard Makeover Challenge │
   138  └───────────┴──────────────────────────────┘
   139  ```
   140  
   141  Please note the -d, we're explicitly only deleting one dashboard.  We can verify the list.
   142  
   143  ```sh
   144  ./bin/gdg dash list
   145  ┌────┬──────────────────────────────┬──────────────────────────────┬─────────┬───────────┬────────────────────────────────────────────────────────────────┐
   146  │ ID │ TITLE                        │ SLUG                         │ FOLDER  │ UID       │ URL                                                            │
   147  ├────┼──────────────────────────────┼──────────────────────────────┼─────────┼───────────┼────────────────────────────────────────────────────────────────┤
   148  │ 80 │ Bandwidth Dashboard          │ bandwidth-dashboard          │ General │ 000000003 │ http://localhost:3000/d/000000003/bandwidth-dashboard          │
   149  │ 81 │ Bandwidth Patterns           │ bandwidth-patterns           │ General │ 000000004 │ http://localhost:3000/d/000000004/bandwidth-patterns           │
   150  │ 90 │ Flow Analysis                │ flow-analysis                │ Other   │ VuuXrnPWz │ http://localhost:3000/d/VuuXrnPWz/flow-analysis                │
   151  │ 91 │ Flow Data for Circuits       │ flow-data-for-circuits       │ Other   │ xk26IFhmk │ http://localhost:3000/d/xk26IFhmk/flow-data-for-circuits       │
   152  │ 92 │ Flow Data for Projects       │ flow-data-for-projects       │ Other   │ ie7TeomGz │ http://localhost:3000/d/ie7TeomGz/flow-data-for-projects       │
   153  │ 93 │ Flow Data per Country        │ flow-data-per-country        │ Other   │ fgrOzz_mk │ http://localhost:3000/d/fgrOzz_mk/flow-data-per-country        │
   154  │ 94 │ Flow Data per Organization   │ flow-data-per-organization   │ Other   │ QfzDJKhik │ http://localhost:3000/d/QfzDJKhik/flow-data-per-organization   │
   155  │ 95 │ Flow Information             │ flow-information             │ Other   │ nzuMyBcGk │ http://localhost:3000/d/nzuMyBcGk/flow-information             │
   156  │ 96 │ Flows by Science Discipline  │ flows-by-science-discipline  │ Other   │ WNn1qyaiz │ http://localhost:3000/d/WNn1qyaiz/flows-by-science-discipline  │
   157  │ 83 │ Individual Flows             │ individual-flows             │ General │ -l3_u8nWk │ http://localhost:3000/d/-l3_u8nWk/individual-flows             │
   158  │ 82 │ Individual Flows per Country │ individual-flows-per-country │ General │ 80IVUboZk │ http://localhost:3000/d/80IVUboZk/individual-flows-per-country │
   159  │ 88 │ Latency Patterns             │ latency-patterns             │ Ignored │ 000000005 │ http://localhost:3000/d/000000005/latency-patterns             │
   160  │ 84 │ Loss Patterns                │ loss-patterns                │ General │ 000000006 │ http://localhost:3000/d/000000006/loss-patterns                │
   161  │ 85 │ Other Flow Stats             │ other-flow-stats             │ General │ CJC1FFhmz │ http://localhost:3000/d/CJC1FFhmz/other-flow-stats             │
   162  │ 86 │ Science Discipline Patterns  │ science-discipline-patterns  │ General │ ufIS9W7Zk │ http://localhost:3000/d/ufIS9W7Zk/science-discipline-patterns  │
   163  │ 87 │ Top Talkers Over Time        │ top-talkers-over-time        │ General │ b35BWxAZz │ http://localhost:3000/d/b35BWxAZz/top-talkers-over-time        │
   164  └────┴──────────────────────────────┴──────────────────────────────┴─────────┴───────────┴────────────────────────────────────────────────────────────────┘
   165  ```
   166  
   167  ### Removing related components
   168  
   169  
   170  ```sh
   171  ./bin/gdg lib clear                                                                                                                   (gke_esnet-sd-dev_us-central1-c_dev-staging-kafka-3/default)
   172  INFO[0000] 9 library were deleted
   173  ┌─────────┬────────────────────────────────────────────────────────────────┐
   174  │ TYPE    │ FILENAME                                                       │
   175  ├─────────┼────────────────────────────────────────────────────────────────┤
   176  │ library │ Dashboard Makeover - Extra Cleaning Duty Assignment Today      │
   177  │ library │ Dashboard Makeover - Lighting Status                           │
   178  │ library │ Dashboard Makeover - Side Dish Prep Times, past 7 days         │
   179  │ library │ Dashboard Makeover - Time since we purchased these spices      │
   180  │ library │ Extreme Dashboard Makeover - Grill                             │
   181  │ library │ Extreme Dashboard Makeover - Mac Oven                          │
   182  │ library │ Extreme Dashboard Makeover - Refrigerator Temperature (F)      │
   183  │ library │ Extreme Dashboard Makeover - Room Temperature (F)              │
   184  │ library │ Extreme Dashboard Makeover - Salmon Cooking Times, past 7 days │
   185  └─────────┴────────────────────────────────────────────────────────────────┘
   186  ```