|
@@ -3,6 +3,8 @@ package grafana
|
3
|
3
|
import (
|
4
|
4
|
"encoding/json"
|
5
|
5
|
"fmt"
|
|
6
|
+
|
|
7
|
+ "grafana/helpers"
|
6
|
8
|
)
|
7
|
9
|
|
8
|
10
|
|
|
@@ -129,12 +131,9 @@ func (c *Client) GetDashboard(URI string) (db *Dashboard, err error) {
|
129
|
131
|
|
130
|
132
|
|
131
|
133
|
|
132
|
|
-
|
133
|
|
-
|
134
|
|
-
|
135
|
134
|
|
136
|
135
|
|
137
|
|
-func (c *Client) CreateOrUpdateDashboard(slug string, contentJSON []byte) (err error) {
|
|
136
|
+func (c *Client) CreateOrUpdateDashboard(contentJSON []byte) (err error) {
|
138
|
137
|
reqBody := dbCreateOrUpdateRequest{
|
139
|
138
|
Dashboard: rawJSON(contentJSON),
|
140
|
139
|
Overwrite: true,
|
|
@@ -161,6 +160,11 @@ func (c *Client) CreateOrUpdateDashboard(slug string, contentJSON []byte) (err e
|
161
|
160
|
return
|
162
|
161
|
}
|
163
|
162
|
|
|
163
|
+ slug, err := helpers.GetDashboardSlug(contentJSON)
|
|
164
|
+ if err != nil {
|
|
165
|
+ return
|
|
166
|
+ }
|
|
167
|
+
|
164
|
168
|
if respBody.Status != "success" && isHttpUnknownError {
|
165
|
169
|
return fmt.Errorf(
|
166
|
170
|
"Failed to update dashboard %s (%d %s): %s",
|