Commit 5da3276d by Kirchen99 Committed by GitHub

Dashboard: Use same min refresh interval fallback in the API as in provisioning (#25926)

* Dashboard: Solve the discrepancy between provisioning and the API, Handle min refresh interval when creating/updating dashboard via API

* Docs: Add refresh field in the example dashboard http api docs

* Update create dashboard API docs

Add refresh field in the create dashboard example response

* Fix create dashboard API docs

* Fix create dashboard API docs

* Update docs/sources/http_api/dashboard.md

Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com>
Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
parent 900eb807
...@@ -44,7 +44,8 @@ Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk ...@@ -44,7 +44,8 @@ Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
"tags": [ "templated" ], "tags": [ "templated" ],
"timezone": "browser", "timezone": "browser",
"schemaVersion": 16, "schemaVersion": 16,
"version": 0 "version": 0,
"refresh": "25s"
}, },
"folderId": 0, "folderId": 0,
"overwrite": false "overwrite": false
...@@ -59,6 +60,7 @@ JSON Body schema: ...@@ -59,6 +60,7 @@ JSON Body schema:
- **folderId** – The id of the folder to save the dashboard in. - **folderId** – The id of the folder to save the dashboard in.
- **overwrite** – Set to true if you want to overwrite existing dashboard with newer version, same dashboard title in folder or same dashboard uid. - **overwrite** – Set to true if you want to overwrite existing dashboard with newer version, same dashboard title in folder or same dashboard uid.
- **message** - Set a commit message for the version history. - **message** - Set a commit message for the version history.
- **refresh** - Set the dashboard refresh interval. If this is lower than [the minimum refresh interval]({{< relref "../administration/configuration.md#min_refresh_interval">}}), then Grafana will ignore it and will enforce the minimum refresh interval.
For adding or updating an alert rule for a dashboard panel the user should declare a For adding or updating an alert rule for a dashboard panel the user should declare a
`dashboard.panels.alert` block. `dashboard.panels.alert` block.
......
...@@ -277,6 +277,11 @@ func (dr *dashboardServiceImpl) SaveFolderForProvisionedDashboards(dto *SaveDash ...@@ -277,6 +277,11 @@ func (dr *dashboardServiceImpl) SaveFolderForProvisionedDashboards(dto *SaveDash
} }
func (dr *dashboardServiceImpl) SaveDashboard(dto *SaveDashboardDTO, allowUiUpdate bool) (*models.Dashboard, error) { func (dr *dashboardServiceImpl) SaveDashboard(dto *SaveDashboardDTO, allowUiUpdate bool) (*models.Dashboard, error) {
if err := validateDashboardRefreshInterval(dto.Dashboard); err != nil {
dr.log.Warn("Changing refresh interval for imported dashboard to minimum refresh interval", "dashboardUid", dto.Dashboard.Uid, "dashboardTitle", dto.Dashboard.Title, "minRefreshInterval", setting.MinRefreshInterval)
dto.Dashboard.Data.Set("refresh", setting.MinRefreshInterval)
}
cmd, err := dr.buildSaveDashboardCommand(dto, true, !allowUiUpdate) cmd, err := dr.buildSaveDashboardCommand(dto, true, !allowUiUpdate)
if err != nil { if err != nil {
return nil, err return nil, err
......
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