Commit b646a1d6 by Maksim Nabokikh Committed by GitHub

Provisioning: describe which folder caused an error while provisioning from…

Provisioning: describe which folder caused an error while provisioning from files structure (#26771)

* Provisioning: describe which folder caused an error while provisioning from files structure

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>

* Apply suggestions from code review

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>

* Remove unused DashType constants

Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
parent 49c4edb2
......@@ -275,6 +275,8 @@ providers:
When Grafana starts, it will update/insert all dashboards available in the configured path. Then later on poll that path every **updateIntervalSeconds** and look for updated json files and update/insert those into the database.
> **Note:** Dashboards are provisioned to the General folder if the `folder` option is missing or empty.
#### Making changes to a provisioned dashboard
It's possible to make changes to a provisioned dashboard in the Grafana UI. However, it is not possible to automatically save the changes back to the provisioning source.
......@@ -333,6 +335,8 @@ providers:
> **Note.** `folder` and `folderUid` options should be empty or missing to make `foldersFromFilesStructure` work.
> **Note:** To provision dashboards to the General folder, store them in the root of your `path`.
## Alert Notification Channels
Alert Notification Channels can be provisioned by adding one or more yaml config files in the [`provisioning/notifiers`](/administration/configuration/#provisioning) directory.
......@@ -541,4 +545,4 @@ The following sections detail the supported settings and secure settings for eac
| Name |
| ---- |
| url |
\ No newline at end of file
| url |
......@@ -12,6 +12,8 @@ import (
"github.com/grafana/grafana/pkg/util"
)
const RootFolderName = "General"
// Typed errors
var (
ErrDashboardNotFound = DashboardErr{
......@@ -101,7 +103,6 @@ var (
Reason: "Unique identifier needed to be able to get a dashboard",
StatusCode: 400,
}
RootFolderName = "General"
)
// DashboardErr represents a dashboard error.
......@@ -141,10 +142,8 @@ func (d UpdatePluginDashboardError) Error() string {
return "Dashboard belong to plugin"
}
var (
DashTypeJson = "file"
const (
DashTypeDB = "db"
DashTypeScript = "script"
DashTypeSnapshot = "snapshot"
)
......@@ -218,8 +217,8 @@ func NewDashboardFolder(title string) *Dashboard {
}
// GetTags turns the tags in data json into go string array
func (dash *Dashboard) GetTags() []string {
return dash.Data.Get("tags").MustStringArray()
func (d *Dashboard) GetTags() []string {
return d.Data.Get("tags").MustStringArray()
}
func NewDashboardFromJson(data *simplejson.Json) *Dashboard {
......@@ -274,14 +273,14 @@ func (cmd *SaveDashboardCommand) GetDashboardModel() *Dashboard {
}
// GetString a
func (dash *Dashboard) GetString(prop string, defaultValue string) string {
return dash.Data.Get(prop).MustString(defaultValue)
func (d *Dashboard) GetString(prop string, defaultValue string) string {
return d.Data.Get(prop).MustString(defaultValue)
}
// UpdateSlug updates the slug
func (dash *Dashboard) UpdateSlug() {
title := dash.Data.Get("title").MustString()
dash.Slug = SlugifyTitle(title)
func (d *Dashboard) UpdateSlug() {
title := d.Data.Get("title").MustString()
d.Slug = SlugifyTitle(title)
}
func SlugifyTitle(title string) string {
......@@ -305,8 +304,8 @@ func (dash *Dashboard) GetUrl() string {
}
// Return the html url for a dashboard
func (dash *Dashboard) GenerateUrl() string {
return GetDashboardUrl(dash.Uid, dash.Slug)
func (d *Dashboard) GenerateUrl() string {
return GetDashboardUrl(d.Uid, d.Slug)
}
// GetDashboardFolderUrl return the html url for a folder if it's folder, otherwise for a dashboard
......
......@@ -10,14 +10,12 @@ import (
"strings"
"time"
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/util"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/util"
)
var (
......@@ -148,7 +146,7 @@ func (fr *FileReader) storeDashboardsInFoldersFromFileStructure(filesFoundOnDisk
folderID, err := getOrCreateFolderID(fr.Cfg, fr.dashboardProvisioningService, folderName)
if err != nil && err != ErrFolderNameMissing {
return err
return fmt.Errorf("can't provision folder %q from file system structure: %w", folderName, err)
}
provisioningMetadata, err := fr.saveDashboard(path, folderID, fileInfo, dashboardRefs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment