Skip to content

Commit

Permalink
[TechDebt] Small documentation update. (#220)
Browse files Browse the repository at this point in the history
* Changing config search path order precedence
* Adding files that were missed in the previous release (Documentation) and link fixing.
  • Loading branch information
safaci2000 authored Nov 3, 2023
1 parent f58025e commit f76d8f5
Show file tree
Hide file tree
Showing 7 changed files with 464 additions and 4 deletions.
6 changes: 4 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"encoding/json"
"errors"
"fmt"
"github.com/esnet/gdg/internal/tools"
"github.com/thoas/go-funk"
Expand Down Expand Up @@ -164,7 +165,7 @@ func (app *AppConfig) GetContextMap() map[string]interface{} {

var (
configData *Configuration
configSearchPaths = []string{".", "../../config", "../config", "config", "/etc/gdg"}
configSearchPaths = []string{"config", ".", "../config", "../../config", "/etc/gdg"}
)

// GetCloudConfiguration Returns storage type and configuration
Expand Down Expand Up @@ -264,7 +265,8 @@ func InitConfig(override, defaultConfig string) {
var err error

configData.defaultConfig, configData.AppConfig, err = readViperConfig(appName, configDirs)
_, ok := err.(viper.ConfigFileNotFoundError)
var configFileNotFoundError viper.ConfigFileNotFoundError
ok := errors.As(err, &configFileNotFoundError)

if err != nil && ok {
log.Info("No configuration file has been found, creating a default configuration")
Expand Down
187 changes: 187 additions & 0 deletions website/content/en/docs/gdg/backup_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
---
title: "Backup Commands Guide"
weight: 16
---

Every namespace supporting CRUD operations has the functions: list, download, upload, clear operating on only the monitored folders.



### Alert Notifications (DEPRECATED)

This will stop working soon both as a concept in grafana and something that GDG will support.

Allows you to manage alertnotifications (an) if you have any setup

```sh
./bin/gdg backup an list -- Lists all alert notifications
./bin/gdg backup an download -- retrieve and save all alertnotifications from grafana
./bin/gdg backup an upload -- writes all local alert notifications to grafana
./bin/gdg backup an clear -- Deletes all alert notifications
```

### Connections
#### (was: DataSources)

Note: Starting with 0.4.6 this was renamed to connections.

Connections credentials are keyed by the name of the DataSource. See see [config example](https://github.com/esnet/gdg/blob/master/conf/importer-example.yml). If the connection JSON doesn't have auth enabled, the credentials are ignored. If Credentials are missing, we'll fall back on default credentials if any exist. The password is set as a value for basicAuthPassword in the API payload.
Datasources are imported or exported from _organization_ specified in configuration file otherwise current organization user is used.


All commands can use `connection` or `c` to manage datasources. (Legacy options of `datasource` and `ds` are also supported)

```sh
./bin/gdg backup c list -- Lists all current connections
./bin/gdg backup c download -- Import all connections from grafana to local file system
./bin/gdg backup c upload -- Exports all dashboard from local filesystem (matching folder filter) to Grafana
./bin/gdg backup c clear -- Deletes all connections
```


### Dashboards

Dashboards are imported or exported from _organization_ specified in configuration file otherwise current organization user is used.

All commands can use `dashboards` or `dash` to manage dashboards

```sh
./bin/gdg backup dash list -- Lists all current dashboards
./bin/gdg backup dash download -- Import all dashboards from grafana to local file system
./bin/gdg backup dash upload -- Exports all dashboard from local filesystem (matching folder filter) to Grafana
./bin/gdg backup dash clear -- Deletes all dashboards
```

You can also use filtering options to list or import your dashboard by folder or by tags.

```sh
./bin/gdg backup dash download -f myFolder
./bin/gdg backup dash download -t myTag
./bin/gdg backup dash download -t tagA -t tagB -t tagC
```



### Folders

Mostly optional as Dashboards will create/delete these are needed but if there is additional metadata you wish to persist you can use this to manage them.

```sh
./bin/gdg backup folders list -- Lists all current folders
./bin/gdg backup folders download -- Import all folders from grafana to local file system
./bin/gdg backup folders upload -- Exports all folders from local filesystem
./bin/gdg backup folders clear -- Deletes all folders
```

### Folder Permissions

This CRUD allows you to import / export folder permissions. Initial release will be part of v0.4.4. There are a lot of nested relationship that go with this.

Expectations:
- Users have to already exist.
- Teams (if used) need to already exist.
- Folders also need to already exist.

The Folder Permissions will list, import and re-apply permissions. But the expectations is that all other entities are already there. Next few iteration will try to add more concurrency for
this tool and more error checking when entities that don't exist are being referenced.

**NOTE:** Unlike other command, permissions does not have a `clear` function. Theoretically you could have a folder name with an emtpy array under folder-permissions to clear all known permissions to the folder, but otherwise
clearing permissions from all folders seems too destructive to really be a useful function.

```sh
./bin/gdg backup folders list -- Lists all current folder permissions
./bin/gdg backup folders download -- Retrieve all folders permissions from Grafana
./bin/gdg backup folders upload -- Exports all folders from local filesystem
```

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ FOLDER ID β”‚ FOLDERUID β”‚ FOLDER NAME β”‚ USERID β”‚ TEAM NAME β”‚ ROLE β”‚ PERMISSION NAME β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 2272 β”‚ dfba969d-565b-481e-a930-53aa5684992c β”‚ sub-flow β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ PERMISSION---> β”‚ admin β”‚ β”‚ Admin β”‚
β”‚ 520 β”‚ GPmSOQNnk β”‚ EngageMap (internal beta) β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ PERMISSION---> β”‚ β”‚ Admin β”‚ Edit β”‚
β”‚ β”‚ PERMISSION---> β”‚ β”‚ Editor β”‚ Edit β”‚
β”‚ β”‚ PERMISSION---> β”‚ β”‚ Viewer β”‚ View β”‚
β”‚ 2031 β”‚ n3xS8TwVk β”‚ Team CMS - US dumb dumb β”‚ β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ PERMISSION---> β”‚ β”‚ authscope_team_cms β”‚ β”‚ Edit β”‚
β”‚ 1746 β”‚ pASPyoQVk β”‚ Team DOE-IN-PNNL - DOE-IN Pacific Northwest National Laboratory β”‚ β”‚ β”‚ β”‚ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

The listing includes the folder name, followed by several lines with "PERMISSION--->" which will each list a permission. It can a user being granted access or a team being granted a role etc.



### Library Elements

Library elements are components that can be shared among multiple dashboards. Folder matching will still be applied, so any folders not monitored will be ignored unless explicitly specified. If wildcard flag is enabled, all elements will be acted on irrelevant of folder location

All commands can use `libraryelements` aliased to `library` and `lib` for laziness purposes.

```sh
./bin/gdg backup lib list -- Lists all library components
./bin/gdg backup lib download -- Import all library components from grafana to local file system
./bin/gdg backup lib upload -- Exports all library components from local filesystem (matching folder filter) to Grafana
./bin/gdg backup lib clear -- Deletes all library components
./bin/gdg backup lib list-connections <Lib Element UID> -- Will list all of the dashboards connected to the Lib Element (Coming in v0.4.2)
```



### Organizations
#### Auth: Requires Grafana Admin (Tokens not supported, Org Admins don't have access)
Command can use `organizations` or `org` to manage organizations.

NOTE: this only manages top level of the orgs structure. It's mainly useful to maintain consistency.

```sh
./bin/gdg backup org list -- Lists all organizations
./bin/gdg backup org upload -- Upload Orgs to grafana
./bin/gdg backup org download -- Download Orgs to grafana
```

### Teams

{{< alert icon="πŸ‘‰" text="Admin team members are unable to be exported back. Currently all members except the server admin will be exported as regular members" />}}

{{< alert icon="πŸ‘‰" text="Users need to be created before team export can succeed" />}}

```sh
./bin/gdg backup team list -- Lists all known team members
./bin/gdg backup team download -- download all known team members
./bin/gdg backup team upload -- upload all known team members
./bin/gdg backup team clear -- Delete all known team except admin
```

{{< details "Team Listing" >}}
```
β”Œβ”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ID β”‚ NAME β”‚ EMAIL β”‚ ORGID β”‚ CREATED β”‚ MEMBERCOUNT β”‚ MEMBER LOGIN β”‚ MEMBER PERMISSION β”‚
β”œβ”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ 4 β”‚ engineers β”‚ β”‚ 1 β”‚ 2 β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ admin β”‚ Admin β”‚ β”‚
β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ tux β”‚ Member β”‚ β”‚
β”‚ 5 β”‚ musicians β”‚ β”‚ 1 β”‚ 1 β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ admin β”‚ Admin β”‚ β”‚
β””β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```
{{< /details >}}


### Users

Only supported with basic auth. Users is the only one where basic auth is given priority. API Auth is not supported, so will try to use basic auth if configured otherwise will warn the user and exit.

NOTE: admin user is always ignored.

```sh
./bin/gdg backup users list -- Lists all known users
./bin/gdg backup users download -- Lists all known users
./bin/gdg backup users upload -- Export all users (Not yet supported)
./bin/gdg backup users clear -- Delete all known users except admin
```

2 changes: 1 addition & 1 deletion website/content/en/docs/gdg/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This project requires Go to be installed. On OS X with Homebrew you can just run



make a copy of [conf/importer-example.yml](https://github.com/esnet/gdg/blob/master/conf/importer-example.yml) and name it `conf/importer.yml` You'll need GRAFANA ADMINISTRATIVE privileges to proceed.
make a copy of [config/importer-example.yml](https://github.com/esnet/gdg/blob/master/config/importer-example.yml) and name it `config/importer.yml` You'll need GRAFANA ADMINISTRATIVE privileges to proceed.


### Authentication
Expand Down
Loading

0 comments on commit f76d8f5

Please sign in to comment.